]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/adapter/AWTFocusAdapter.java
Merge commit 'd186091'
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / g2d / events / adapter / AWTFocusAdapter.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.scenegraph.g2d.events.adapter;\r
13 \r
14 import java.awt.event.FocusEvent;\r
15 import java.awt.event.FocusListener;\r
16 \r
17 import org.simantics.scenegraph.g2d.events.IEventHandler;\r
18 import org.simantics.scenegraph.g2d.events.IEventQueue;\r
19 import org.simantics.scenegraph.g2d.events.FocusEvent.FocusGainedEvent;\r
20 import org.simantics.scenegraph.g2d.events.FocusEvent.FocusLostEvent;\r
21 \r
22 /**\r
23  * Adapts AWT focus event to G2D event\r
24  * \r
25  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>\r
26  */\r
27 public class AWTFocusAdapter extends AbstractEventAdapter implements FocusListener {\r
28 \r
29     public AWTFocusAdapter(Object sender, IEventHandler delegator) {\r
30         super(sender, delegator);\r
31     }\r
32 \r
33     public AWTFocusAdapter(Object sender, IEventQueue queue) {\r
34         super(sender, queue);\r
35     }\r
36 \r
37     @Override\r
38     public void focusGained(FocusEvent e) {\r
39         handleEvent(new FocusGainedEvent(sender, System.currentTimeMillis()));\r
40     }\r
41 \r
42     @Override\r
43     public void focusLost(FocusEvent e) {\r
44         handleEvent(new FocusLostEvent(sender, System.currentTimeMillis()));\r
45     }\r
46 \r
47 }\r