| /* |
| * Copyright (c) 2007, 2009 Borland Software Corporation |
| * |
| * 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: |
| * bblajer (Borland) - initial API and implementation |
| */ |
| |
| «IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'» |
| |
| /** |
| * TODO: Move to lite runtime (will need an extra param in constructor for model id) |
| */ |
| «DEFINE NodeToolEntry FOR gmfgen::Palette-» |
| «EXPAND xpt::Common::generatedClassComment» |
| private static class NodeToolEntry «EXPAND supertypes» { |
| «EXPAND attrs-» |
| |
| «EXPAND ctor-» |
| |
| «EXPAND createTool-» |
| |
| «EXPAND additions-» |
| } |
| «ENDDEFINE» |
| |
| «DEFINE supertypes FOR gmfgen::Palette»extends org.eclipse.gef.palette.CombinedTemplateCreationEntry«ENDDEFINE» |
| |
| «DEFINE attrs FOR gmfgen::Palette-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| private final int[] myVisualIDs; |
| «ENDDEFINE» |
| |
| «DEFINE ctor FOR gmfgen::Palette-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| private NodeToolEntry(String title, String description, int[] visualIDs) { |
| super(title, description, new org.eclipse.gmf.runtime.lite.requests.ModelCreationFactory(org.eclipse.gmf.runtime.notation.Node.class), null, null); |
| myVisualIDs = visualIDs; |
| } |
| «ENDDEFINE» |
| |
| «DEFINE createTool FOR gmfgen::Palette-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| public org.eclipse.gef.Tool createTool() { |
| org.eclipse.gef.Tool result = new org.eclipse.gef.tools.CreationTool() { |
| protected org.eclipse.gef.Request createTargetRequest() { |
| org.eclipse.gmf.runtime.lite.requests.CreateRequestEx request = new org.eclipse.gmf.runtime.lite.requests.CreateRequestEx(«EXPAND xpt::editor::VisualIDRegistry::modelID FOR diagram», myVisualIDs); |
| request.setFactory(getFactory()); |
| return request; |
| } |
| protected void performCreation(int button) { |
| super.performCreation(button); |
| final org.eclipse.gef.EditPart createdEditPart = (org.eclipse.gef.EditPart)getCurrentViewer().getEditPartRegistry().get(getCreateRequest().getNewObject()); |
| if (createdEditPart != null) { |
| getCurrentViewer().getControl().getDisplay().asyncExec(new Runnable() { |
| public void run() { |
| if (createdEditPart.isActive()) { |
| createdEditPart.performRequest(new org.eclipse.gef.Request(org.eclipse.gef.RequestConstants.REQ_DIRECT_EDIT)); |
| } |
| } |
| }); |
| } |
| } |
| }; |
| result.setProperties(getToolProperties()); |
| return result; |
| } |
| «ENDDEFINE» |
| |
| «DEFINE additions FOR gmfgen::Palette»«ENDDEFINE» |