Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-12-02 14:45:38 +0000
committerGerrit Code Review @ Eclipse.org2015-12-04 12:59:05 +0000
commitf8dedc59a0e9bc39beaa61b7a8c2cad1252c9438 (patch)
tree0e03fa04aaa10fd1c0c48028dec5a61b64bd06c9 /plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/VisualTypeProvider.xtend
parent1f171bd0213d10d1d791f622e7ebf0b6484c40c5 (diff)
downloadorg.eclipse.papyrus-f8dedc59a0e9bc39beaa61b7a8c2cad1252c9438.tar.gz
org.eclipse.papyrus-f8dedc59a0e9bc39beaa61b7a8c2cad1252c9438.tar.xz
org.eclipse.papyrus-f8dedc59a0e9bc39beaa61b7a8c2cad1252c9438.zip
Bug 477384: [Canonical] Should not use drop requests to create views
https://bugs.eclipse.org/bugs/show_bug.cgi?id=477384 Changes to core APIs to remove PapyrusCanonicalEditPolicy's dependence on the generated diagram drag-and-drop behavior: * extract the CommonDiagramDragDropEditPolicy's abstract API for information about diagram-specific view types into a new service * update the canonical edit-policy and diagram-to-diagram synchronization infrastructure to use the new VisualTypeService to obtain information about the diagram's specific view types to then let the view service create views without resorting to drop commands * update extensions of various canonical strategies in the UML diagrams to adapt to the new drop-free synchronization mechanism Update the Papyrus Diagram GMFGen extensions and code generation templates to add generation of the IVisualTypeProvider that plugs into the new VisualTypeService to support canonical synchronization and drag-and-drop. Includes regeneration of the GMFGen extension model using EMF's most recent templates, which result in minor changes to most model source files. Regenerate all UML diagrams to create and register the visual type provider extensions. Also update the BREE for diagrams to 1.8 because at least one of them requires Java 8 to compile properly. * Note that the interaction overview diagram uses a code generator that is not published on Eclipse.org, so I had to emulate the code generation step for this one * Note also that the SysML 1.1 diagrams likewise cannot be re-generated but, moreover, they do not implement the common pattern for Visual ID Registry, so they are also updated "by hand" for parity with the Mars implementation of drag-and-drop (which had gaps) Deprecate the ICreationTargetStrategy extension API which was only needed to redirect drag-and-drop requests, but these are no longer employed in the canonical synchronization. Also some fixes for region layout problems in the State Machine Diagram: * update custom creation edit policies to re-use the commands used by drag-and-drop and untargeted creation that perform initial placement of new regions * fix the GMFGen to register the custom creation edit policy for the state machine compartment Change-Id: I3afc68d6f0f1bfe05e336c9138a7f1acbc8f643b
Diffstat (limited to 'plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/VisualTypeProvider.xtend')
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/VisualTypeProvider.xtend100
1 files changed, 100 insertions, 0 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/VisualTypeProvider.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/VisualTypeProvider.xtend
new file mode 100644
index 00000000000..a8597c8c102
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/VisualTypeProvider.xtend
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * Copyright (c) 2015 Christian W. Damus 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:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package aspects.xpt.providers
+
+import javax.inject.Inject
+import javax.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram
+import org.eclipse.papyrus.papyrusgmfgenextension.GenVisualTypeProvider
+import xpt.CodeStyle
+import xpt.Common
+import xpt.editor.VisualIDRegistry
+import xpt.providers.ElementTypes
+
+/**
+ * Template for the class that plugs in knowledge of the Visual IDs of this diagram
+ * into the {@code VisualTypeService}.
+ */
+@Singleton class VisualTypeProvider {
+
+ @Inject extension Common
+ @Inject extension CodeStyle
+ @Inject VisualIDRegistry visualIDs
+ @Inject ElementTypes elementTypes
+
+ def getPackageName(GenDiagram it) '''«it.providersPackageName»'''
+
+ def getClassName(GenDiagram it) '''«GenVisualTypeProvider.getClassName(it)»'''
+
+ def getQualifiedClassName(GenDiagram it) '''«packageName».«className»'''
+
+ protected def constructor(GenDiagram it) '''
+ «generatedMemberComment»
+ public «it.className»() {
+ super();
+ }
+ '''
+
+ protected def getElementType_(GenDiagram it) '''
+ «generatedMemberComment»
+ «overrideI»
+ public org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(org.eclipse.gmf.runtime.notation.Diagram diagram, String viewType) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType result = null;
+
+ try {
+ result = «elementTypes.qualifiedClassName(it)».getElementType(Integer.parseInt(viewType));
+ } catch (NumberFormatException e) {
+ // Not supported by this diagram
+ }
+
+ return result;
+ }
+ '''
+
+ protected def getNodeType(GenDiagram it) '''
+ «generatedMemberComment»
+ «overrideI»
+ public String getNodeType(View parentView, EObject element) {
+ int result = «visualIDs.getNodeVisualIDMethodCall(it)»(parentView, element);
+ return (result < 0) ? null : Integer.toString(result);
+ }
+ '''
+
+ protected def getLinkType(GenDiagram it) '''
+ «generatedMemberComment»
+ «overrideI»
+ public String getLinkType(Diagram diagram, EObject element) {
+ int result = «visualIDs.getLinkWithClassVisualIDMethodCall(it)»(element);
+ return (result < 0) ? null : Integer.toString(result);
+ }
+ '''
+
+ public def VisualTypeProvider(GenDiagram it) '''
+ «editorGen.copyright»
+ package «packageName»;
+
+ «generatedClassComment»
+ public class «className» extends org.eclipse.papyrus.infra.gmfdiag.common.service.visualtype.AbstractVisualTypeProvider {
+
+ «constructor»
+
+ «getElementType_»
+
+ «getNodeType»
+
+ «getLinkType»
+
+ }
+ '''
+} \ No newline at end of file

Back to the top