1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g2d.element.handler.impl;
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;
21 * @author Toni Kalajainen
23 public class EnabledImpl implements Stateful, LifeCycle {
25 private static final long serialVersionUID = -9001251146906678336L;
27 public static final EnabledImpl ENABLED_BY_DEFAULT = new EnabledImpl();
28 public static final EnabledImpl DISABLED_BY_DEFAULT = new EnabledImpl();
31 public boolean isEnabled(IElement e) {
32 Boolean b = e.getHint(ElementHints.KEY_ENABLED);
33 return b==null ? false : b;
37 public void setEnabled(IElement e, boolean enabled) {
38 e.setHint(ElementHints.KEY_ENABLED, enabled);
42 public void onElementActivated(IDiagram d, IElement e) {
46 public void onElementCreated(IElement e) {
47 e.setHint(ElementHints.KEY_ENABLED, true);
51 public void onElementDeactivated(IDiagram d, IElement e) {
55 public void onElementDestroyed(IElement e) {