]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/EnabledImpl.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / impl / EnabledImpl.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.g2d.element.handler.impl;\r
13 \r
14 import org.simantics.g2d.diagram.IDiagram;\r
15 import org.simantics.g2d.element.ElementHints;\r
16 import org.simantics.g2d.element.IElement;\r
17 import org.simantics.g2d.element.handler.Stateful;\r
18 import org.simantics.g2d.element.handler.LifeCycle;\r
19 \r
20 /**\r
21  * @author Toni Kalajainen\r
22  */\r
23 public class EnabledImpl implements Stateful, LifeCycle {\r
24 \r
25     private static final long serialVersionUID = -9001251146906678336L;\r
26 \r
27     public static final EnabledImpl ENABLED_BY_DEFAULT = new EnabledImpl();\r
28     public static final EnabledImpl DISABLED_BY_DEFAULT = new EnabledImpl();\r
29 \r
30     @Override\r
31     public boolean isEnabled(IElement e) {\r
32         Boolean b = e.getHint(ElementHints.KEY_ENABLED); \r
33         return b==null ? false : b;\r
34     }\r
35 \r
36     @Override\r
37     public void setEnabled(IElement e, boolean enabled) {\r
38         e.setHint(ElementHints.KEY_ENABLED, enabled);\r
39     }\r
40 \r
41     @Override\r
42     public void onElementActivated(IDiagram d, IElement e) {\r
43     }\r
44 \r
45     @Override\r
46     public void onElementCreated(IElement e) {\r
47         e.setHint(ElementHints.KEY_ENABLED, true);\r
48     }\r
49 \r
50     @Override\r
51     public void onElementDeactivated(IDiagram d, IElement e) {\r
52     }\r
53 \r
54     @Override\r
55     public void onElementDestroyed(IElement e) {\r
56     }\r
57 \r
58 }\r