/******************************************************************************* * Copyright (c) 2010-2015 Henshin developers. 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: * TU Berlin, University of Luxembourg, SES S.A. *******************************************************************************/ package de.tub.tfs.henshin.tggeditor.tools; import org.eclipse.emf.ecore.EClass; import org.eclipse.gef.commands.Command; import org.eclipse.gef.requests.CreationFactory; import org.eclipse.gef.tools.CreationTool; import org.eclipse.swt.widgets.Shell; import de.tub.tfs.henshin.tggeditor.commands.create.CreateNodeCommand; import de.tub.tfs.henshin.tggeditor.commands.create.rule.CreateRuleNodeCommand; import de.tub.tfs.henshin.tggeditor.util.dialogs.DialogUtil; /** * The RuleNodeCreationTool creates nodes in a rule. * @see de.tub.tfs.henshin.tggeditor.commands.create.rule.CreateRuleNodeCommand */ public class RuleNodeCreationTool extends CreationTool { /** * the constructor */ public RuleNodeCreationTool() { super(); } /** * the constructor * @param factory */ public RuleNodeCreationTool(CreationFactory factory) { super(factory); } /* (non-Javadoc) * @see org.eclipse.gef.tools.AbstractTool#executeCommand(org.eclipse.gef.commands.Command) */ @Override protected void executeCommand(final Command command) { if (command instanceof CreateNodeCommand || command instanceof CreateRuleNodeCommand) { final CreateNodeCommand c = (CreateNodeCommand) command; //Module trafoSys; if (c.getGraph().eContainer() == null){ return; } //trafoSys = (Module) EcoreUtil.getRootContainer(c.getGraph()); Shell shell = new Shell(); String nodeName = ""; EClass eClass = (DialogUtil.runNodeCreationDialog(shell, c)); shell.dispose(); if (eClass != null) { c.setName(nodeName); c.setNodeType(eClass); super.executeCommand(command); } } } /* * (non-Javadoc) * * @see org.eclipse.gef.tools.AbstractTool#handleFinished() */ @Override protected void handleFinished() { reactivate(); // super.handleFinished(); } }