]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/EnabledImpl.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / impl / EnabledImpl.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g2d.element.handler.impl;
13
14 import org.simantics.g2d.diagram.IDiagram;
15 import org.simantics.g2d.element.ElementHints;
16 import org.simantics.g2d.element.IElement;
17 import org.simantics.g2d.element.handler.Stateful;
18 import org.simantics.g2d.element.handler.LifeCycle;
19
20 /**
21  * @author Toni Kalajainen
22  */
23 public class EnabledImpl implements Stateful, LifeCycle {
24
25     private static final long serialVersionUID = -9001251146906678336L;
26
27     public static final EnabledImpl ENABLED_BY_DEFAULT = new EnabledImpl();
28     public static final EnabledImpl DISABLED_BY_DEFAULT = new EnabledImpl();
29
30     @Override
31     public boolean isEnabled(IElement e) {
32         Boolean b = e.getHint(ElementHints.KEY_ENABLED); 
33         return b==null ? false : b;
34     }
35
36     @Override
37     public void setEnabled(IElement e, boolean enabled) {
38         e.setHint(ElementHints.KEY_ENABLED, enabled);
39     }
40
41     @Override
42     public void onElementActivated(IDiagram d, IElement e) {
43     }
44
45     @Override
46     public void onElementCreated(IElement e) {
47         e.setHint(ElementHints.KEY_ENABLED, true);
48     }
49
50     @Override
51     public void onElementDeactivated(IDiagram d, IElement e) {
52     }
53
54     @Override
55     public void onElementDestroyed(IElement e) {
56     }
57
58 }