diff options
Diffstat (limited to 'plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkEditPart.xtend')
-rw-r--r-- | plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkEditPart.xtend | 175 |
1 files changed, 82 insertions, 93 deletions
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkEditPart.xtend index 3316d6a023b..c0ff0a9268f 100644 --- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkEditPart.xtend +++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkEditPart.xtend @@ -1,23 +1,25 @@ -/******************************************************************************* - * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others +/***************************************************************************** + * Copyright (c) 2006, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * + * https://www.eclipse.org/legal/epl-2.0/ + * * SPDX-License-Identifier: EPL-2.0 * - * Contributors: - * Dmitry Stadnik (Borland) - initial API and implementation - * Alexander Shatalin (Borland) - initial API and implementation - * Michael Golubev (Montages) - #386838 - migrate to Xtend2 - * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174 + * Contributors: + * Dmitry Stadnik (Borland) - initial API and implementation + * Alexander Shatalin (Borland) - initial API and implementation + * Michael Golubev (Montages) - #386838 - migrate to Xtend2 + * Remi Schnekenburger (CEA LIST) - modification for Papyrus MDT + * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend + * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : Remove reference to gmfgraph and ModelViewMap *****************************************************************************/ package impl.diagram.editparts import com.google.inject.Inject -import impl.diagram.editparts.viewmaps.modeledViewmapProducer +import com.google.inject.Singleton import org.eclipse.papyrus.gmf.codegen.gmfgen.FigureViewmap import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLink import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLinkLabel @@ -27,19 +29,19 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.ParentAssignedViewmap import org.eclipse.papyrus.gmf.codegen.gmfgen.SnippetViewmap import org.eclipse.papyrus.gmf.codegen.gmfgen.Viewmap import xpt.Common -import xpt.Common_qvto
import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel +import xpt.Common_qvto +import xpt.CodeStyle /** * Revisit: [MG]: @Inject extension same-named-api-class -> template extends api-class? */ -@com.google.inject.Singleton class LinkEditPart { +@Singleton class LinkEditPart { @Inject extension Common; @Inject extension Common_qvto; - + @Inject extension CodeStyle; + @Inject xpt.diagram.editparts.Common xptEditpartsCommon; @Inject TextAware xptTextAware; - @Inject modeledViewmapProducer xptModeledViewmapProducer; - @Inject diagram.editparts.LinkLabelEditPart linkLabelEditPart; def className(GenLink it) '''«editPartClassName»''' @@ -54,32 +56,25 @@ import xpt.Common_qvto
import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel def createDefaultEditPoliciesBody(GenLink it) ''' super.createDefaultEditPolicies(); - «IF null == modelFacet» + «IF null === modelFacet» installEditPolicy(org.eclipse.gef.EditPolicy.COMPONENT_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ViewComponentEditPolicy()); «ENDIF» «xptEditpartsCommon.installSemanticEditPolicy(it)» - «installGraphicalNodeEditPolicy(it)» «xptEditpartsCommon.behaviour(it)» - «additionalEditPolicies(it)» ''' - - def installGraphicalNodeEditPolicy(GenLink it) '''''' - - def additionalEditPolicies(GenLink it) '''''' /** - * FIXME: [MG] check counterpart for ModeledViewmap, - */ + * FIXME: [MG] check counterpart for ModeledViewmap, */ def addFixedChild(GenLink it) ''' - «IF it.hasFixedLabels» - «generatedMemberComment» - protected boolean addFixedChild(org.eclipse.gef.EditPart childEditPart) { - «FOR label : labels» - «addLabel(label.viewmap, label)» - «ENDFOR» - return false; - } - «ENDIF» + «IF labels.size > 0» + «generatedMemberComment» + protected boolean addFixedChild(org.eclipse.gef.EditPart childEditPart) { + «FOR label : labels» + «addLabel(label.viewmap,label)» + «ENDFOR» + return false; + } + «ENDIF» ''' // Note, condition in addFixedChild template above should be changed if addLabel support added for Viewmaps other than ParentAssignedViewmap @@ -89,31 +84,25 @@ import xpt.Common_qvto
import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel «it.commonAddLabel(getterName,label)» ''' - def dispatch addLabel(ModeledViewmap it, GenLinkLabel label) ''' - «var labelAccessor = (figureModel as DiagramLabel).accessor» - «IF labelAccessor != null && labelAccessor.accessor != null» - «it.commonAddLabel(labelAccessor.accessor,label)» - «ENDIF» - ''' - def commonAddLabel(Viewmap it, String getterName, GenLinkLabel label) ''' if (childEditPart instanceof «label.getEditPartQualifiedClassName()») { - ((«label.getEditPartQualifiedClassName()») childEditPart).«xptTextAware.labelSetterName(it)»( - getPrimaryShape().«getterName»()); + ((«label.getEditPartQualifiedClassName()») childEditPart).«xptTextAware.labelSetterName(it)»(getPrimaryShape().«getterName»()); } ''' - def removeFixedChild(GenLink it) ''' - «IF it.hasFixedLabels» - «generatedMemberComment» - protected boolean removeFixedChild(org.eclipse.gef.EditPart childEditPart) { - «FOR label : labels» - «removeLabel(label.viewmap, label)» - «ENDFOR» - return false; + def CharSequence /*Bug 569174 : L1.2 - remove extra blank lines*/removeFixedChild(GenLink it) { + if(!labels.empty) { + ''' + «generatedMemberComment» + protected boolean removeFixedChild(org.eclipse.gef.EditPart childEditPart) { + «FOR label : labels» + «removeLabel(label.viewmap, label)» + «ENDFOR» + return false; + } + ''' } - «ENDIF» - ''' + } // Note, condition in removeFixedChild template above should be changed if removeLabel support added for Viewmaps other than ParentAssignedViewmap def dispatch removeLabel(Viewmap it, GenLinkLabel label) '''''' @@ -133,63 +122,50 @@ import xpt.Common_qvto
import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel ''' def addChildVisual(GenLink it) ''' - «IF it.hasFixedLabels» - «generatedMemberComment» - protected void addChildVisual(org.eclipse.gef.EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { - return; + «IF ! labels.empty» + «generatedMemberComment» + «overrideC» + protected void addChildVisual(org.eclipse.gef.EditPart childEditPart, int index) { + if (addFixedChild(childEditPart)) { + return; + } + super.addChildVisual(childEditPart, -1); } - super.addChildVisual(childEditPart, index); - } - «ENDIF» + «ENDIF» ''' def removeChildVisual(GenLink it) ''' - «IF it.hasFixedLabels» - «generatedMemberComment» - protected void removeChildVisual(org.eclipse.gef.EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { - return; + «IF ! labels.empty» + «generatedMemberComment» + «overrideC» + protected void removeChildVisual(org.eclipse.gef.EditPart childEditPart) { + if (removeFixedChild(childEditPart)) { + return; + } + super.removeChildVisual(childEditPart); } - super.removeChildVisual(childEditPart); - } - «ENDIF» + «ENDIF» ''' def createLinkFigure(GenLink it) ''' - «generatedMemberComment( - 'Creates figure for this edit part.\n' + '\n' + + «generatedMemberComment('Creates figure for this edit part.\n' + '\n' + 'Body of this method does not depend on settings in generation model\n' + - 'so you may safely remove <i>generated</i> tag and modify it.\n' - )» + 'so you may safely remove <i>generated</i> tag and modify it.')» «createLinkFigure(it.viewmap, it)» ''' def dispatch createLinkFigure(Viewmap it, GenLink link) '''«ERROR('Unknown viewmap: ' + it + ", for link: " + link)»''' - def dispatch createLinkFigure(ModeledViewmap it, GenLink link) ''' - protected org.eclipse.draw2d.Connection createConnectionFigure() { - return new «modeledViewmapFigureFQN(it)»(); - } - - «generatedMemberComment» - public «modeledViewmapFigureFQN(it)» getPrimaryShape() { - return («modeledViewmapFigureFQN(it)») getFigure(); - } - - «xptModeledViewmapProducer.viewmapClassBody(it)» - ''' - - def modeledViewmapFigureFQN(ModeledViewmap it) '''«xptModeledViewmapProducer.viewmapFigureFQN(it)»''' - def dispatch createLinkFigure(FigureViewmap it, GenLink link) { - var fqn = if(figureQualifiedClassName == null) 'org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx' else figureQualifiedClassName + var fqn = if(figureQualifiedClassName === null) 'org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx' else figureQualifiedClassName ''' + «link.overrideC» protected org.eclipse.draw2d.Connection createConnectionFigure() { return new «fqn»(); } - + «generatedMemberComment» + «link.overrideI» public «fqn» getPrimaryShape() { return («fqn») getFigure(); } @@ -197,29 +173,42 @@ import xpt.Common_qvto
import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel } def dispatch createLinkFigure(SnippetViewmap it, GenLink link) ''' + «link.overrideC» protected org.eclipse.draw2d.Connection createConnectionFigure() { return «body»; } ''' def dispatch createLinkFigure(InnerClassViewmap it, GenLink link) ''' + «link.overrideC» protected org.eclipse.draw2d.Connection createConnectionFigure() { return new «className»(); } - + «generatedMemberComment» + «link.overrideI» public «className» getPrimaryShape() { return («className») getFigure(); } - + «classBody» ''' - + /** * FIXME: [MG] it looks like the ModeledViewmap is fixed, check that * FIXME: [MG] and add the dispatch for modeled viewmaps then */ - def boolean hasFixedLabels(GenLink it){ + def boolean hasFixedLabels(GenLink it) { labels.notEmpty && (labels.filter(l | l.viewmap.oclIsKindOf(typeof(ParentAssignedViewmap))).notEmpty || labels.filter(l | l.viewmap.oclIsKindOf(typeof(ModeledViewmap))).notEmpty) } + + /** + * computes super type of the link edit part in case the edit part manages a representation of a UML element + */ + def extendsListContents(GenLink it) { + if(superEditPart !== null) + return '''«superEditPart»''' + else + return '''org.eclipse.papyrus.infra.gmfdiag.common.editpart.ConnectionEditPart''' + } } |