Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeEditPart.xpt')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeEditPart.xpt581
1 files changed, 581 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeEditPart.xpt
new file mode 100644
index 000000000..a204dfc6b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeEditPart.xpt
@@ -0,0 +1,581 @@
+/*
+ * Copyright (c) 2006, 2008 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::ViewmapAttributesUtils»
+«EXTENSION xpt::diagram::editparts::Utils»
+
+«DEFINE extendsListContents FOR gmfgen::GenNode-»
+«IF hasBorderItems(self)»org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE extendsListContents FOR gmfgen::GenChildSideAffixedNode-»
+«IF hasBorderItems(self)»org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
+ super(view);
+ }
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenNode-»
+ «EXPAND installCreationRolePolicy-»
+ super.createDefaultEditPolicies();
+ «EXPAND installPrimaryDragEditPolicy-»
+ «EXPAND xpt::diagram::editparts::Common::installSemanticEditPolicy-»
+ «IF needsGraphicalNodeEditPolicy(self)-»
+ installEditPolicy(org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE, new «getGraphicalNodeEditPolicyQualifiedClassName()»());
+ «ENDIF-»
+ «IF not childNodes->isEmpty()-»
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy());
+ «ENDIF-»
+ «EXPAND xpt::diagram::editparts::Common::installCanonicalEditPolicy-»
+ installEditPolicy(org.eclipse.gef.EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ «EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
+ // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
+«ENDDEFINE»
+
+«DEFINE installCreationRolePolicy FOR gmfgen::GenNode-»
+«IF hasChildren(self) or hasChildrenInListCompartments(self)-»
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE, «EXPAND _creationEditPolicyNewInstance»);
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE _creationEditPolicyNewInstance FOR gmfgen::GenNode»new org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy()«ENDDEFINE»
+
+«DEFINE installPrimaryDragEditPolicy FOR gmfgen::GenNode»«ENDDEFINE»
+
+«DEFINE installPrimaryDragEditPolicy FOR gmfgen::GenChildSideAffixedNode-»
+ installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE, getPrimaryDragEditPolicy());
+«ENDDEFINE»
+
+«DEFINE createLayoutEditPolicy FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gef.editpolicies.LayoutEditPolicy createLayoutEditPolicy() {
+ «EXPAND createLayoutEditPolicyBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE createLayoutEditPolicyBody FOR gmfgen::GenNode-»
+ «IF gmfgen::ViewmapLayoutType::XY_LAYOUT = getLayoutType()-»
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy() {
+
+ protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
+ «EXPAND borderItemSelectionEditPolicy-»
+ org.eclipse.gef.EditPolicy result = super.createChildEditPolicy(child);
+ if (result == null) {
+ return new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy();
+ }
+ return result;
+ }
+ };
+ return lep;
+ «ELSEIF gmfgen::ViewmapLayoutType::TOOLBAR_LAYOUT = getLayoutType()»
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy() {
+
+ protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
+ «EXPAND borderItemSelectionEditPolicy-»
+ if (child.getEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE) == null) {
+ if (child instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart) {
+ return new «getDiagram().getTextSelectionEditPolicyQualifiedClassName()»();
+ }
+ }
+ return super.createChildEditPolicy(child);
+ }
+ };
+ return lep;
+ «ELSEIF gmfgen::ViewmapLayoutType::FLOW_LAYOUT = getLayoutType()»
+ org.eclipse.gef.editpolicies.FlowLayoutEditPolicy lep = new org.eclipse.gef.editpolicies.FlowLayoutEditPolicy() {
+
+ «IF hasBorderItems(self)-»
+ protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
+ «EXPAND borderItemSelectionEditPolicy-»
+ return super.createChildEditPolicy(child);
+ }
+ «ENDIF-»
+
+ protected org.eclipse.gef.commands.Command createAddCommand(org.eclipse.gef.EditPart child, org.eclipse.gef.EditPart after) {
+ return null;
+ }
+
+ protected org.eclipse.gef.commands.Command createMoveChildCommand(org.eclipse.gef.EditPart child, org.eclipse.gef.EditPart after) {
+ return null;
+ }
+
+ protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gef.requests.CreateRequest request) {
+ return null;
+ }
+ };
+ return lep;
+ «ELSE-»
+ org.eclipse.gef.editpolicies.LayoutEditPolicy lep = new org.eclipse.gef.editpolicies.LayoutEditPolicy() {
+
+ protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
+ «EXPAND borderItemSelectionEditPolicy-»
+ org.eclipse.gef.EditPolicy result = child.getEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE);
+ if (result == null) {
+ result = new org.eclipse.gef.editpolicies.NonResizableEditPolicy();
+ }
+ return result;
+ }
+
+ 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;
+ }
+ };
+ return lep;
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE borderItemSelectionEditPolicy FOR gmfgen::GenNode-»
+«IF hasBorderItems(self)-»
+org.eclipse.gmf.runtime.notation.View childView = (org.eclipse.gmf.runtime.notation.View) child.getModel();
+switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(childView)) {
+«IF getExternalLabels(self)->size() > 0-»
+«FOREACH getExternalLabels(self) AS nextLabel-»
+«EXPAND xpt::Common::caseVisualID FOR nextLabel-»
+«ENDFOREACH-»
+ return «EXPAND borderItemSelectionEP»;
+«ENDIF-»
+«IF getSideAffixedChildren(self)->size() > 0-»
+«FOREACH getSideAffixedChildren(self) AS nextBorderItem-»
+«EXPAND xpt::Common::caseVisualID FOR nextBorderItem-»
+«ENDFOREACH-»
+ return new org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy();
+«ENDIF-»
+}
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE borderItemSelectionEP FOR gmfgen::GenNode-»
+new org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy() {
+
+ protected java.util.List createSelectionHandles() {
+ org.eclipse.gef.handles.MoveHandle mh = new org.eclipse.gef.handles.MoveHandle((org.eclipse.gef.GraphicalEditPart) getHost());
+ mh.setBorder(null);
+ return java.util.Collections.singletonList(mh);
+ }
+}
+«ENDDEFINE»
+
+«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::Viewmap-»
+ «ERROR 'Unknown viewmap: ' + self.repr()-»
+«ENDDEFINE»
+
+«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::FigureViewmap-»
+ «LET (if figureQualifiedClassName = null then 'org.eclipse.draw2d.RectangleFigure' else figureQualifiedClassName endif) AS fqn-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createNodeShape() {
+ return primaryShape = new «fqn»()«IF node.getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT»{
+ protected boolean useLocalCoordinates() {
+ return true;
+ }
+ }«ENDIF»;
+ }
+
+ «EXPAND getPrimaryShapeMethod FOR fqn-»
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::SnippetViewmap-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createNodeShape() {
+ return «body»;
+ }
+«ENDDEFINE»
+
+«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::InnerClassViewmap-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createNodeShape() {
+ «className» figure = new «className»();
+ «IF node.childNodes->size() > 0 and node.getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT-»
+ figure.setUseLocalCoordinates(true);
+ «ENDIF-»
+ return primaryShape = figure;
+ }
+
+ «EXPAND getPrimaryShapeMethod FOR className-»
+«ENDDEFINE»
+
+«DEFINE getPrimaryShapeMethod FOR String-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «self» getPrimaryShape() {
+ return («self») primaryShape;
+ }
+«ENDDEFINE»
+
+«DEFINE addFixedChild FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean addFixedChild(org.eclipse.gef.EditPart childEditPart) {
+«FOREACH getInnerFixedLabels(self) AS label»«LET label.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
+ if (childEditPart instanceof «label.getEditPartQualifiedClassName()») {
+ ((«label.getEditPartQualifiedClassName()») childEditPart).«EXPAND impl::diagram::editparts::TextAware::labelSetterName FOR childViewmap»(getPrimaryShape().«childViewmap.getterName»());
+ return true;
+ }
+«ENDLET»«ENDFOREACH-»
+«FOREACH getPinnedCompartments(self) AS compartment»«LET compartment.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
+ if (childEditPart instanceof «compartment.getEditPartQualifiedClassName()») {
+ org.eclipse.draw2d.IFigure pane = getPrimaryShape().«childViewmap.getterName»();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((«compartment.getEditPartQualifiedClassName()») childEditPart).getFigure());
+ return true;
+ }
+«ENDLET»«ENDFOREACH-»
+«FOREACH getSideAffixedChildren(self) AS child-»
+ if (childEditPart instanceof «child.getEditPartQualifiedClassName()») {
+ org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator locator = new org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator(getMainFigure(), org.eclipse.draw2d.PositionConstants.«child.preferredSideName»);
+ getBorderedFigure().getBorderItemContainer().add(((«child.getEditPartQualifiedClassName()») childEditPart).getFigure(), locator);
+ return true;
+ }
+«ENDFOREACH-»
+ return false;
+ }
+«ENDDEFINE»
+
+«DEFINE removeFixedChild FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean removeFixedChild(org.eclipse.gef.EditPart childEditPart) {
+«FOREACH getInnerFixedLabels(self) AS label»«LET label.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
+ if (childEditPart instanceof «label.getEditPartQualifiedClassName()») {
+ return true;
+ }
+«ENDLET»«ENDFOREACH-»
+«FOREACH getPinnedCompartments(self) AS compartment»«LET compartment.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
+ if (childEditPart instanceof «compartment.getEditPartQualifiedClassName()») {
+ org.eclipse.draw2d.IFigure pane = getPrimaryShape().«childViewmap.getterName»();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.remove(((«compartment.getEditPartQualifiedClassName()») childEditPart).getFigure());
+ return true;
+ }
+«ENDLET»«ENDFOREACH-»
+«FOREACH getSideAffixedChildren(self) AS child-»
+ if (childEditPart instanceof «child.getEditPartQualifiedClassName()») {
+ getBorderedFigure().getBorderItemContainer().remove(((«child.getEditPartQualifiedClassName()») childEditPart).getFigure());
+ return true;
+ }
+«ENDFOREACH-»
+ return false;
+ }
+«ENDDEFINE»
+
+«DEFINE addChildVisual FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void addChildVisual(org.eclipse.gef.EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+«ENDDEFINE»
+
+«DEFINE removeChildVisual FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void removeChildVisual(org.eclipse.gef.EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)){
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+«ENDDEFINE»
+
+«DEFINE getContentPaneFor FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure getContentPaneFor(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart editPart) {
+ «REM»it is unclear what we should return for labels here«ENDREM-»
+«FOREACH getPinnedCompartments(self) AS compartment»«LET compartment.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
+ if (editPart instanceof «compartment.getEditPartQualifiedClassName()») {
+ return getPrimaryShape().«childViewmap.getterName»();
+ }
+«ENDLET»«ENDFOREACH-»
+«IF hasBorderItems(self)-»
+ if (editPart instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart) {
+ return getBorderedFigure().getBorderItemContainer();
+ }
+«ENDIF-»
+ return getContentPane();
+ }
+«ENDDEFINE»
+
+«DEFINE addBorderItem FOR gmfgen::GenNode-»
+ «IF getExternalLabels(self)->size() > 0-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void addBorderItem(org.eclipse.draw2d.IFigure borderItemContainer, org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart borderItemEditPart) {
+ if («FOREACH getExternalLabels(self) AS label SEPARATOR ' || '»borderItemEditPart instanceof «label.getEditPartQualifiedClassName()»«ENDFOREACH») {
+ org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator locator = new org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator(getMainFigure(), org.eclipse.draw2d.PositionConstants.SOUTH);
+ locator.setBorderItemOffset(new org.eclipse.draw2d.geometry.Dimension(-20, -20));
+ borderItemContainer.add(borderItemEditPart.getFigure(), locator);
+ } else {
+ super.addBorderItem(borderItemContainer, borderItemEditPart);
+ }
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE createNodePlate FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure createNodePlate() {
+ org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure result =
+ new org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure(getMapMode().DPtoLP(«defaultSizeWidth(viewmap, 40)»), getMapMode().DPtoLP(«defaultSizeHeight(viewmap, 40)»));
+ «EXPAND setupNodePlate-»
+ return result;
+ }
+«ENDDEFINE»
+
+«DEFINE setupNodePlate FOR gmfgen::GenNode»«ENDDEFINE»
+
+«DEFINE setupNodePlate FOR gmfgen::GenChildSideAffixedNode»
+ //FIXME: workaround for #154536
+ result.getBounds().setSize(result.getPreferredSize());
+«ENDDEFINE»
+
+«DEFINE getPrimaryDragEditPolicy FOR gmfgen::GenNode-»
+ «LET getResizeConstraints(viewmap) AS rc-»
+ «IF null <> primaryDragEditPolicyQualifiedClassName or null <> rc-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gef.EditPolicy getPrimaryDragEditPolicy() {
+ «IF null <> primaryDragEditPolicyQualifiedClassName-»
+ return new «primaryDragEditPolicyQualifiedClassName»();
+ «ELSE-»
+ org.eclipse.gef.EditPolicy result = super.getPrimaryDragEditPolicy();
+ if (result instanceof org.eclipse.gef.editpolicies.ResizableEditPolicy) {
+ org.eclipse.gef.editpolicies.ResizableEditPolicy ep = (org.eclipse.gef.editpolicies.ResizableEditPolicy) result;
+ ep.setResizeDirections(
+ «IF rc.resizeHandleNames->size() > 0-»
+ «FOREACH rc.resizeHandleNames->asSequence() AS name SEPARATOR ' | '»org.eclipse.draw2d.PositionConstants.«name»«ENDFOREACH-»
+ «ELSE»org.eclipse.draw2d.PositionConstants.NONE«ENDIF»);
+ }
+ return result;
+ «ENDIF-»
+ }
+ «ENDIF-»
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE createFigure FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'Creates figure for this edit part.
+
+Body of this method does not depend on settings in generation model
+so you may safely remove <i>generated</i> tag and modify it.
+'
+ )»
+ protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure create«IF hasBorderItems(self)»Main«ELSE»Node«ENDIF»Figure() {
+ org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure figure = createNodePlate();
+ figure.setLayoutManager(new org.eclipse.draw2d.StackLayout());
+ org.eclipse.draw2d.IFigure shape = createNodeShape();
+ figure.add(shape);
+ contentPane = setupContentPane(shape);
+ return figure;
+ }
+«ENDDEFINE»
+
+«DEFINE setupContentPane FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'Default implementation treats passed figure as content pane.
+Respects layout one may have set for generated figure.
+@param nodeShape instance of generated figure class'
+ )»
+ protected org.eclipse.draw2d.IFigure setupContentPane(org.eclipse.draw2d.IFigure nodeShape) {
+ «IF not childNodes->isEmpty() or (not compartments->isEmpty() or not labels->-((labels)[gmfgen::GenExternalNodeLabel])->isEmpty())-»
+ if (nodeShape.getLayoutManager() == null) {
+ «IF getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT-»
+ nodeShape.setLayoutManager(new org.eclipse.draw2d.FreeformLayout() {
+
+ public Object getConstraint(org.eclipse.draw2d.IFigure figure) {
+ Object result = constraints.get(figure);
+ if (result == null) {
+ result = new org.eclipse.draw2d.geometry.Rectangle(0, 0, -1, -1);
+ }
+ return result;
+ }
+ });
+ «ELSE-»
+ org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout layout =new org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout();
+ layout.setSpacing(getMapMode().DPtoLP(5));
+ nodeShape.setLayoutManager(layout);
+ «ENDIF-»
+ }
+ «ENDIF-»
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+«ENDDEFINE»
+
+«DEFINE getContentPane FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.draw2d.IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+«ENDDEFINE»
+
+«DEFINE setForegroundColor FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setForegroundColor(org.eclipse.swt.graphics.Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE setBackgroundColor FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setBackgroundColor(org.eclipse.swt.graphics.Color color) {
+ if (primaryShape != null) {
+ primaryShape.setBackgroundColor(color);
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE setLineWidth FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setLineWidth(int width) {
+ if (primaryShape instanceof org.eclipse.draw2d.Shape) {
+ ((org.eclipse.draw2d.Shape) primaryShape).setLineWidth(getMapMode().DPtoLP(width));
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE setLineStyle FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setLineType(int style) {
+ if (primaryShape instanceof org.eclipse.draw2d.Shape) {
+ ((org.eclipse.draw2d.Shape) primaryShape).setLineStyle(style);
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE getPrimaryChildEditPart FOR gmfgen::GenNode-»
+ «IF not labels->isEmpty()-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gef.EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall FOR labels->first().oclAsType(gmfgen::GenLabel)»);
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+// pre: getAssistantOutgoingLinks(this).size() > 0
+«DEFINE getMARelTypesOnSource FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMARelTypesOnSource() {
+ java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
+ «FOREACH getAssistantOutgoingLinks(self) AS link-»
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantIncomingLinks(this).size() > 0
+«DEFINE getMARelTypesOnTarget FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMARelTypesOnTarget() {
+ java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
+ «FOREACH getAssistantIncomingLinks(self) AS link-»
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantOutgoingLinks(this).size() > 0
+«DEFINE getMARelTypesOnSourceAndTarget FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMARelTypesOnSourceAndTarget(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart) {
+ java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
+ «FOREACH getAssistantOutgoingLinks(self) AS link-»
+ «FOREACH selectGenNodes(link.targets->asSequence()) AS target-»
+ if (targetEditPart instanceof «target.getEditPartQualifiedClassName()») {
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
+ }
+ «ENDFOREACH-»
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantIncomingLinks(this).size() > 0
+«DEFINE getMATypesForSource FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMATypesForSource(org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
+ java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
+ «FOREACH getAssistantIncomingLinks(self) AS link-»
+ «FOREACH selectGenNodes(link.sources->asSequence()) AS source-»
+ if (relationshipType == «EXPAND xpt::providers::ElementTypes::accessElementType FOR link») {
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR source»);
+ }
+ «ENDFOREACH-»
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantOutgoingLinks(this).size() > 0
+«DEFINE getMATypesForTarget FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMATypesForTarget(org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
+ java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
+ «FOREACH getAssistantOutgoingLinks(self) AS link-»
+ «FOREACH (link.targets)[gmfgen::GenNode]->asSequence() AS target-»
+ if (relationshipType == «EXPAND xpt::providers::ElementTypes::accessElementType FOR link») {
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR target»);
+ }
+ «ENDFOREACH-»
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+«DEFINE handleNotificationEventBody FOR gmfgen::GenTopLevelNode-»
+ if (event.getNotifier() == getModel() && org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getEModelElement_EAnnotations().equals(event.getFeature())) {
+ handleMajorSemanticChange();
+ } else {
+ super.handleNotificationEvent(event);
+ }
+«ENDDEFINE»
+
+«DEFINE innerClassDeclaration FOR gmfgen::Viewmap»
+«ENDDEFINE»
+
+«DEFINE innerClassDeclaration FOR gmfgen::InnerClassViewmap»
+ «classBody»
+«ENDDEFINE»
+
+«DEFINE getTargetEditPartMethod FOR gmfgen::GenNode»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gef.EditPart getTargetEditPart(org.eclipse.gef.Request request) {
+ if (request instanceof org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest) {
+ org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter adapter = ((org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
+ org.eclipse.gmf.runtime.emf.type.core.IElementType type = (org.eclipse.gmf.runtime.emf.type.core.IElementType) adapter.getAdapter(org.eclipse.gmf.runtime.emf.type.core.IElementType.class);
+«FOREACH compartments->asSequence() AS compartment-»
+ «IF listCompartmentHasChildren(compartment)-»
+ «FOREACH compartment.childNodes->asSequence() AS childNode-»
+ if (type == «EXPAND xpt::providers::ElementTypes::accessElementType FOR childNode») {
+ return getChildBySemanticHint(«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall FOR compartment»);
+ }
+ «ENDFOREACH-»
+ «ENDIF-»
+«ENDFOREACH-»
+ }
+ return super.getTargetEditPart(request);
+ }
+«ENDDEFINE»

Back to the top