Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2014-03-03 18:35:01 +0000
committerFlorian Noyrit2014-03-03 18:35:01 +0000
commit3724d11f5e8c95b39c35a1895ca977515d2fe392 (patch)
tree6df809ceee75ad07c1ff5e87fea7c2f0a6ebe3aa /plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram
parente6640915c57d431d04bd85d42bf6da5fa4434dda (diff)
downloadorg.eclipse.papyrus-3724d11f5e8c95b39c35a1895ca977515d2fe392.tar.gz
org.eclipse.papyrus-3724d11f5e8c95b39c35a1895ca977515d2fe392.tar.xz
org.eclipse.papyrus-3724d11f5e8c95b39c35a1895ca977515d2fe392.zip
Updated generation templates
Regenerated class diagram with many refactorings
Diffstat (limited to 'plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram')
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend16
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend4
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend28
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/Utils_qvto.xtend42
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend39
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/UpdateCommand.xtend47
6 files changed, 162 insertions, 14 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend
index c8a44b5048c..e907969828a 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend
@@ -88,7 +88,21 @@ public class «className(it)» extends org.eclipse.gmf.runtime.diagram.ui.editpoli
«additions(it)»
}
-'''
+'''
+
+override def addDestroyShortcutsCommand(GenDiagram it) '''
+ «generatedMemberComment('Clean all shortcuts to the host element from the same diagram')»
+ protected void addDestroyShortcutsCommand(org.eclipse.gmf.runtime.common.core.command.ICompositeCommand cmd, org.eclipse.gmf.runtime.notation.View view) {
+ «_assert('view.getEAnnotation(\"Shortcut\") == null')»
+ for (java.util.Iterator<?> it = view.getDiagram().getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next();
+ if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { «nonNLS()»
+ continue;
+ }
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), nextView));
+ }
+ }
+'''
override attributes(GenDiagram it) '''
«generatedMemberComment('Extended request data key to hold editpart visual id.')»
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend
index 4c1534540a5..7a85059b1ad 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend
@@ -58,8 +58,8 @@ import xpt.editor.VisualIDRegistry
««« Papyrus REM :
««« Test to know how the delete of this EditPart is done : we used the DeleteService or the "Traditional method"
-
- «IF it.eResource.allContents.filter(typeof (EditPartUsingDeleteService)).filter[v | v.genView.contains(this)].size != 0»
+
+ «IF it.eResource.allContents.filter(typeof (EditPartUsingDeleteService)).filter[v | v.genView.contains(it)].size != 0»
«generatedMemberComment»
«getDestroyElementCommandByService(it)»
«ELSE»
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend
new file mode 100644
index 00000000000..3ba5cf8e709
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend
@@ -0,0 +1,28 @@
+package aspects.xpt.diagram.editpolicies
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram
+import xpt.Common
+
+/**
+ * FIXME: [MG] - reverse the calls? call common code from here and TextelectionEP and not vice versa
+*/
+@Singleton class TextNonResizableEditPolicy extends xpt.diagram.editpolicies.TextNonResizableEditPolicy {
+
+ @Inject extension Common;
+
+
+
+ override def TextNonResizableEditPolicy_createSelectionHandles(GenDiagram it) '''
+ «generatedMemberComment»
+ protected java.util.List<?> createSelectionHandles() {
+ org.eclipse.gef.handles.MoveHandle moveHandle =
+ new org.eclipse.gef.handles.MoveHandle((org.eclipse.gef.GraphicalEditPart) getHost());
+ moveHandle.setBorder(null);
+ moveHandle.setDragTracker(new org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx(getHost()));
+ return java.util.Collections.singletonList(moveHandle);
+ }
+ '''
+
+} \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/Utils_qvto.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/Utils_qvto.xtend
new file mode 100644
index 00000000000..50246d06683
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/Utils_qvto.xtend
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2007-2013 Borland Software Corporation && others
+ *
+ * All rights reserved. This program && the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, && is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API && implementation
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ * - #386838 - migrate to Xtend2
+ */
+package aspects.xpt.diagram.editpolicies
+
+import com.google.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenLinkEnd
+
+@Singleton class Utils_qvto extends xpt.diagram.editpolicies.Utils_qvto {
+
+def Boolean containsCreateStartLinkCommand(GenLinkEnd it){
+ for (l : getAllPotentialLinks(it)){
+ if(createStartLinkCommand(l, it)){
+ return true;
+ }
+ }
+
+ return false;
+}
+
+def Boolean containsCreateCompleteLinkCommand(GenLinkEnd it){
+ for (l : getAllPotentialLinks(it)){
+ if(createCompleteLinkCommand(l, it)){
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend
index 1b16e699e54..a17cac0b44a 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend
@@ -51,7 +51,8 @@ import xpt.providers.ElementTypes
@Singleton class linkCommands extends xpt.diagram.editpolicies.linkCommands {
@Inject extension Utils_qvto;
@Inject extension Common;
-
+
+ @Inject aspects.xpt.diagram.editpolicies.Utils_qvto aspectsUtils_qvto
@Inject VisualIDRegistry xptVisualIDRegistry;
@Inject ElementTypes xptElementTypes;
@Inject CreateLinkCommand xptCreateLinkCommand;
@@ -77,15 +78,21 @@ import xpt.providers.ElementTypes
return null;
}
org.eclipse.gmf.runtime.emf.type.core.IElementType baseElementType = requestElementType;
+ «IF aspectsUtils_qvto.containsCreateStartLinkCommand(it)»
boolean isExtendedType = false;
+ «ENDIF»
if(requestElementType instanceof org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType) {
baseElementType = org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils.getClosestDiagramType(requestElementType);
if(baseElementType != null) {
+ «IF aspectsUtils_qvto.containsCreateStartLinkCommand(it)»
isExtendedType = true;
+ «ENDIF»
} else {
// no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
baseElementType = org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils.findClosestNonExtendedElementType((org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType)requestElementType);
+ «IF aspectsUtils_qvto.containsCreateStartLinkCommand(it)»
isExtendedType = true;
+ «ENDIF»
}
}
«FOR l : getAllPotentialLinks(it)»
@@ -102,15 +109,21 @@ import xpt.providers.ElementTypes
return null;
}
org.eclipse.gmf.runtime.emf.type.core.IElementType baseElementType = requestElementType;
+ «IF aspectsUtils_qvto.containsCreateCompleteLinkCommand(it)»
boolean isExtendedType = false;
+ «ENDIF»
if(requestElementType instanceof org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType) {
baseElementType = org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils.getClosestDiagramType(requestElementType);
if(baseElementType != null) {
+ «IF aspectsUtils_qvto.containsCreateCompleteLinkCommand(it)»
isExtendedType = true;
+ «ENDIF»
} else {
// no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
baseElementType = org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils.findClosestNonExtendedElementType((org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType)requestElementType);
+ «IF aspectsUtils_qvto.containsCreateCompleteLinkCommand(it)»
isExtendedType = true;
+ «ENDIF»
}
}
«FOR l : getAllPotentialLinks(it)»
@@ -164,15 +177,19 @@ import xpt.providers.ElementTypes
«generatedMemberComment(
'Returns command to reorient EClass based link. New link target or source\n' + 'should be the domain model element associated with this node.\n'
- protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(
- org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- «FOR rLink : getReroutableTypeLinks(it)»
- «reorientLinkCommandWithService(rLink)»
- «ENDFOR»
- }
- return super.getReorientRelationshipCommand(req);
- }
+ protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ «FOR link : getReroutableTypeLinks(it)»
+ «reorientLinkCommandWithService(link) »
+ «ENDFOR»
+ «callReorientCommand(it)»
+ «FOR link : getReroutableTypeLinks(it)»
+ «reorientLinkCommandWithoutService(link) »
+ «ENDFOR»
+ }
+ return super.getReorientRelationshipCommand(req);
+ }
'''
//This function writes only : "case myLinkEditPart.VISUAL_ID:"
@@ -204,7 +221,7 @@ import xpt.providers.ElementTypes
// This function writes the code for the Links which uses their own ReorientCommand (the initial code)
def reorientLinkCommandWithoutService(GenLink it) '''
- «IF it.eResource.allContents.filter(EditPartUsingReorientService).filter[v|v.genView.contains(it)].size != 0»
+ «IF it.eResource.allContents.filter(EditPartUsingReorientService).filter[v|v.genView.contains(it)].size == 0»
«reorientLinkCommand(it)»
«ENDIF»
'''
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/UpdateCommand.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/UpdateCommand.xtend
new file mode 100644
index 00000000000..e8238331560
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/UpdateCommand.xtend
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2007, 2009, 2013 Borland Software Corporation and others
+ *
+ * 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ */
+package aspects.xpt.diagram.updater
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenDiagramUpdater
+import xpt.Common
+
+@Singleton class UpdateCommand extends xpt.diagram.updater.UpdateCommand {
+ @Inject extension Common;
+
+
+
+ override def execute(GenDiagramUpdater it) '''
+ «generatedMemberComment»
+ public Object execute(org.eclipse.core.commands.ExecutionEvent event) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.jface.viewers.ISelection selection = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+ if (selection instanceof org.eclipse.jface.viewers.IStructuredSelection) {
+ org.eclipse.jface.viewers.IStructuredSelection structuredSelection = (org.eclipse.jface.viewers.IStructuredSelection) selection;
+ if (structuredSelection.size() != 1) {
+ return null;
+ }
+ if (structuredSelection.getFirstElement() instanceof org.eclipse.gef.EditPart && ((org.eclipse.gef.EditPart) structuredSelection.getFirstElement()).getModel() instanceof org.eclipse.gmf.runtime.notation.View) {
+ org.eclipse.emf.ecore.EObject modelElement = ((org.eclipse.gmf.runtime.notation.View) ((org.eclipse.gef.EditPart) structuredSelection.getFirstElement()).getModel()).getElement();
+ java.util.List<?> editPolicies = org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy.getRegisteredEditPolicies(modelElement);
+ for (java.util.Iterator<?> it = editPolicies.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy nextEditPolicy = (org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy) it.next();
+ nextEditPolicy.refresh();
+ }
+
+ }
+ }
+ return null;
+ }
+ '''
+}

Back to the top