Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/DiagramEditPart.xpt')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/DiagramEditPart.xpt96
1 files changed, 96 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/DiagramEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/DiagramEditPart.xpt
new file mode 100644
index 000000000..f3db47549
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/DiagramEditPart.xpt
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2006, 2007 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::diagram::editparts::Utils»
+
+«DEFINE _constructor FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
+ super(view);
+ }
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenDiagram-»
+ super.createDefaultEditPolicies();
+ «EXPAND xpt::diagram::editparts::Common::installSemanticEditPolicy-»
+ «EXPAND xpt::diagram::editparts::Common::installCanonicalEditPolicy-»
+ «IF generateCreateShortcutAction() and null = editorGen.application-»
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramDragDropEditPolicy() {
+ public org.eclipse.gef.commands.Command getDropObjectsCommand(org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest dropRequest) {
+ java.util.List viewDescriptors = new java.util.ArrayList();
+ for (java.util.Iterator it = dropRequest.getObjects().iterator(); it.hasNext();) {
+ Object nextObject = it.next();
+ if (false == nextObject instanceof org.eclipse.emf.ecore.EObject) {
+ continue;
+ }
+ viewDescriptors.add(new org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor(new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter((org.eclipse.emf.ecore.EObject) nextObject), org.eclipse.gmf.runtime.notation.Node.class, null, getDiagramPreferencesHint()));
+ }
+ return createShortcutsCommand(dropRequest, viewDescriptors);
+ }
+
+ private org.eclipse.gef.commands.Command createShortcutsCommand(org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest dropRequest, java.util.List viewDescriptors) {
+ org.eclipse.gef.commands.Command command = createViewsAndArrangeCommand(dropRequest, viewDescriptors);
+ if (command != null) {
+ return command.chain(new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(new «getCreateShortcutDecorationsCommandQualifiedClassName()»(getEditingDomain(), (org.eclipse.gmf.runtime.notation.View) getModel(), viewDescriptors)));
+ }
+ return null;
+ }
+ });
+ «ENDIF-»
+ «IF shouldGenerateDiagramViewmap(self)-»
+ // diagram figure does layout; need to install child editpolicy to show selection feedback
+ installEditPolicy(org.eclipse.gef.EditPolicy.LAYOUT_ROLE, new org.eclipse.gef.editpolicies.LayoutEditPolicy() {
+ protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
+ final org.eclipse.gef.editpolicies.NonResizableEditPolicy p = new org.eclipse.gef.editpolicies.NonResizableEditPolicy();
+ p.setDragAllowed(false);
+ return p;
+ }
+ protected org.eclipse.gef.commands.Command getMoveChildrenCommand(org.eclipse.gef.Request request) {
+ return null;
+ }
+ protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gef.requests.CreateRequest request) {
+ return null;
+ }
+ });
+ «ENDIF-»
+ «EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE);
+«ENDDEFINE»
+
+«DEFINE createFigure FOR gmfgen::GenDiagram-»
+ «IF shouldGenerateDiagramViewmap(self)-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createFigure() {
+ org.eclipse.draw2d.FreeformLayer l = new org.eclipse.draw2d.FreeformLayer();
+ l.setBorder(new org.eclipse.draw2d.MarginBorder(50));
+ «EXPAND initLayout('lm') FOR viewmap.layoutType-»
+ l.setLayoutManager(lm);
+ return l;
+ }
+ «ENDIF»
+«ENDDEFINE»
+
+«DEFINE initLayout(varName : String) FOR gmfgen::ViewmapLayoutType-»
+ «IF self = gmfgen::ViewmapLayoutType::TOOLBAR_LAYOUT-»
+ org.eclipse.draw2d.ToolbarLayout «varName» = new org.eclipse.draw2d.ToolbarLayout();
+ «varName».setSpacing(10);
+ «ELSEIF self = gmfgen::ViewmapLayoutType::FLOW_LAYOUT-»
+ org.eclipse.draw2d.FlowLayout «varName» = new org.eclipse.draw2d.FlowLayout();
+ «varName».setMajorSpacing(10);
+ «varName».setMinorSpacing(10);
+ «ELSE-»
+ org.eclipse.draw2d.LayoutManager «varName» = null; /*FIXME - unknown layout type*/
+ «ENDIF-»
+«ENDDEFINE» \ No newline at end of file

Back to the top