/******************************************************************************* * Copyright (c) 2007, 2010 Association for Decentralized Information Management * in Industry THTH ry. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ package org.simantics.g2d.element.handler.impl; import org.simantics.g2d.diagram.IDiagram; import org.simantics.g2d.element.ElementHints; import org.simantics.g2d.element.IElement; import org.simantics.g2d.element.handler.Stateful; import org.simantics.g2d.element.handler.LifeCycle; /** * @author Toni Kalajainen */ public class EnabledImpl implements Stateful, LifeCycle { private static final long serialVersionUID = -9001251146906678336L; public static final EnabledImpl ENABLED_BY_DEFAULT = new EnabledImpl(); public static final EnabledImpl DISABLED_BY_DEFAULT = new EnabledImpl(); @Override public boolean isEnabled(IElement e) { Boolean b = e.getHint(ElementHints.KEY_ENABLED); return b==null ? false : b; } @Override public void setEnabled(IElement e, boolean enabled) { e.setHint(ElementHints.KEY_ENABLED, enabled); } @Override public void onElementActivated(IDiagram d, IElement e) { } @Override public void onElementCreated(IElement e) { e.setHint(ElementHints.KEY_ENABLED, true); } @Override public void onElementDeactivated(IDiagram d, IElement e) { } @Override public void onElementDestroyed(IElement e) { } }