Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcdumoulin2011-04-07 10:37:27 -0400
committercdumoulin2011-04-07 10:37:27 -0400
commit9735018e5e75f9356f83e35ac9f64fb011f8d682 (patch)
treef022829a0d89fdb7998f608b3f9c916ad601b735 /examples
parent09b1452e2b6dab5594784434eb68e649b691b5ab (diff)
downloadorg.eclipse.papyrus-9735018e5e75f9356f83e35ac9f64fb011f8d682.tar.gz
org.eclipse.papyrus-9735018e5e75f9356f83e35ac9f64fb011f8d682.tar.xz
org.eclipse.papyrus-9735018e5e75f9356f83e35ac9f64fb011f8d682.zip
NEW - bug 336732: [General] Provide a "create a new diagram project" tutorial
https://bugs.eclipse.org/bugs/show_bug.cgi?id=336732 Provide a simple diagram example. This example can be copied to create your own diagram.
Diffstat (limited to 'examples')
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.classpath8
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.options7
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.project28
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/META-INF/MANIFEST.MF52
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/build.properties5
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/CreateDiagramCommand.java34
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/DiagramEditorFactory.java18
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/UmlDiagramForMultiEditor.java92
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/docs/PapyrusDevelopperTutorial_OnDiagramCreating.odtbin0 -> 4789028 bytes
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/incomingLinksNavigatorGroup.gifbin0 -> 709 bytes
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linkSourceNavigatorGroup.gifbin0 -> 709 bytes
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linkTargetNavigatorGroup.gifbin0 -> 709 bytes
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linksNavigatorGroup.gifbin0 -> 709 bytes
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/Component.gifbin0 -> 123 bytes
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/Diagram_UML.gifbin0 -> 113 bytes
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/UMLDiagramFile.gifbin0 -> 339 bytes
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/newDiagramFile.gifbin0 -> 339 bytes
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/outgoingLinksNavigatorGroup.gifbin0 -> 709 bytes
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/wizban/NewUMLWizard.gifbin0 -> 2466 bytes
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/messages.properties99
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfgen158
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfgraph31
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfmap37
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmftool30
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.trace12
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/plugin.properties34
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/plugin.xml605
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/commands/ComponentCreateCommand.java119
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/ComponentEditHelper.java7
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/ModelEditHelper.java7
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/UMLBaseEditHelper.java88
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ComponentEditPart.java361
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ComponentNameEditPart.java868
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ModelEditPart.java171
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/UMLEditPartFactory.java203
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ComponentItemSemanticEditPolicy.java55
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelCanonicalEditPolicy.java158
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelItemSemanticEditPolicy.java73
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLBaseItemSemanticEditPolicy.java306
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLTextNonResizableEditPolicy.java225
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLTextSelectionEditPolicy.java209
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLAbstractNavigatorItem.java61
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorContentProvider.java230
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorItem.java117
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorLabelProvider.java98
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorActionProvider.java176
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorContentProvider.java368
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorGroup.java97
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorItem.java93
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorLabelProvider.java232
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorLinkHelper.java123
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorSorter.java27
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/parsers/AbstractParser.java464
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/parsers/MessageFormatParser.java204
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/DeleteElementAction.java3
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/DiagramEditorContextMenuProvider.java58
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/LoadResourceAction.java31
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/Messages.java299
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/ModelElementSelectionPage.java150
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLCreationWizard.java173
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLCreationWizardPage.java87
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramActionBarContributor.java39
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditor.java540
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditorPlugin.java284
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditorUtil.java415
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramUpdateCommand.java85
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramUpdater.java119
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDocumentProvider.java1124
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLInitDiagramFileAction.java95
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLLinkDescriptor.java93
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLMatchingStrategy.java36
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLNewDiagramFileWizard.java196
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLNodeDescriptor.java42
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLPaletteFactory.java61
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLUriEditorInputTester.java23
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLVisualIDRegistry.java217
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/ComponentPreferencePage.java53
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramAppearancePreferencePage.java19
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramConnectionsPreferencePage.java19
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramGeneralPreferencePage.java21
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramPreferenceInitializer.java28
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramPrintingPreferencePage.java19
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramRulersAndGridPreferencePage.java19
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/ElementInitializers.java26
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLEditPartProvider.java142
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLElementTypes.java208
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLIconProvider.java31
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLModelingAssistantProvider.java171
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLParserProvider.java124
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLViewProvider.java381
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/sheet/UMLPropertySection.java117
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/sheet/UMLSheetLabelProvider.java80
92 files changed, 12018 insertions, 0 deletions
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.classpath b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.classpath
new file mode 100644
index 00000000000..f6326c88c74
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="custom-src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.options b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.options
new file mode 100644
index 00000000000..48cca8261df
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.options
@@ -0,0 +1,7 @@
+# Tracing options for the org.eclipse.uml2.uml.diagram plug-in
+
+# Common issues
+org.eclipse.uml2.uml.diagram/debug=false
+
+# Visual IDs
+org.eclipse.uml2.uml.diagram/debug/visualID=false
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.project b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.project
new file mode 100644
index 00000000000..3c9db2aad7c
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.example.diagram.simplediagram</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/META-INF/MANIFEST.MF b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..b4a6d6c7e5f
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/META-INF/MANIFEST.MF
@@ -0,0 +1,52 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.uml2.uml.diagram; singleton:=true
+Bundle-Version: 0.8.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.core.expressions,
+ org.eclipse.jface,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.views,
+ org.eclipse.ui.navigator,
+ org.eclipse.ui.navigator.resources,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.emf.edit.ui,
+ org.eclipse.gmf.runtime.emf.core,
+ org.eclipse.gmf.runtime.emf.commands.core,
+ org.eclipse.gmf.runtime.emf.ui.properties,
+ org.eclipse.gmf.runtime.diagram.ui,
+ org.eclipse.gmf.runtime.diagram.ui.properties,
+ org.eclipse.gmf.runtime.diagram.ui.providers,
+ org.eclipse.gmf.runtime.diagram.ui.providers.ide,
+ org.eclipse.gmf.runtime.diagram.ui.render,
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor,
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide,
+ org.eclipse.draw2d;visibility:=reexport,
+ org.eclipse.uml2.uml;visibility:=reexport,
+ org.eclipse.uml2.uml.edit;visibility:=reexport,
+ org.eclipse.emf.ecore;visibility:=reexport,
+ org.eclipse.emf.ecore.edit;visibility:=reexport,
+ org.eclipse.gef,
+ org.eclipse.papyrus.preferences,
+ org.eclipse.papyrus.extensionpoints.editors,
+ org.eclipse.papyrus.core,
+ org.eclipse.papyrus.diagram.common,
+ org.eclipse.gmf.runtime.draw2d.ui;visibility:=reexport
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .
+Bundle-Localization: plugin
+Export-Package: org.eclipse.papyrus.example.diagram.simplediagram.edit.parts,
+ org.eclipse.papyrus.example.diagram.simplediagram.part,
+ org.eclipse.papyrus.example.diagram.simplediagram.providers
+Eclipse-LazyStart: true
+Import-Package: org.eclipse.papyrus.core.adaptor.gmf,
+ org.eclipse.papyrus.core.editor,
+ org.eclipse.papyrus.diagram.common.listeners,
+ org.eclipse.papyrus.example.diagram.simplediagram.edit.parts
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/build.properties b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/build.properties
new file mode 100644
index 00000000000..94408cbfe89
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
+jars.compile.order = .
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/CreateDiagramCommand.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/CreateDiagramCommand.java
new file mode 100644
index 00000000000..a418539ddd9
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/CreateDiagramCommand.java
@@ -0,0 +1,34 @@
+package org.eclipse.papyrus.example.diagram.simplediagram;
+
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.papyrus.core.adaptor.gmf.AbstractPapyrusGmfCreateDiagramCommandHandler;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+
+
+public class CreateDiagramCommand extends AbstractPapyrusGmfCreateDiagramCommandHandler {
+
+ @Override
+ protected String getDefaultDiagramName() {
+ return openDiagramNameDialog("NewDiagram");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getDiagramNotationID() {
+ return ModelEditPart.MODEL_ID;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected PreferencesHint getPreferenceHint() {
+ return org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT;
+ }
+
+}
+
+
+
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/DiagramEditorFactory.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/DiagramEditorFactory.java
new file mode 100644
index 00000000000..2c00fbb6965
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/DiagramEditorFactory.java
@@ -0,0 +1,18 @@
+package org.eclipse.papyrus.example.diagram.simplediagram;
+
+import org.eclipse.papyrus.core.adaptor.gmf.GmfEditorFactory;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+
+public class DiagramEditorFactory extends GmfEditorFactory {
+
+ /**
+ * @param diagramClass
+ * @param expectedType
+ */
+ public DiagramEditorFactory() {
+ super(UmlDiagramForMultiEditor.class, ModelEditPart.MODEL_ID);
+
+ }
+
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/UmlDiagramForMultiEditor.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/UmlDiagramForMultiEditor.java
new file mode 100644
index 00000000000..bb412fdc5a1
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/custom-src/org/eclipse/papyrus/example/diagram/simplediagram/UmlDiagramForMultiEditor.java
@@ -0,0 +1,92 @@
+package org.eclipse.papyrus.example.diagram.simplediagram;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.core.editor.BackboneException;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.core.services.ServicesRegistry;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditor;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+
+
+
+public class UmlDiagramForMultiEditor extends UMLDiagramEditor {
+ /**
+ * The location of diagram icon in the plug-in
+ */
+ private static final String DIAG_IMG_PATH = "icons/obj16/newDiagramFile.gif";
+
+ /**
+ * The image descriptor of the diagram icon
+ */
+ private static final ImageDescriptor DIAG_IMG_DESC = UMLDiagramEditorPlugin.getBundledImageDescriptor(UmlDiagramForMultiEditor.DIAG_IMG_PATH);
+
+ /** The editor splitter. */
+ private Composite splitter;
+
+ /**
+ * Constructor for SashSystem v2. Context and required objects are retrieved from the
+ * ServiceRegistry.
+ *
+ * @throws BackboneException
+ * @throws ServiceException
+ *
+ */
+ public UmlDiagramForMultiEditor(ServicesRegistry servicesRegistry, Diagram diagram) throws BackboneException, ServiceException {
+ super(servicesRegistry, diagram);
+ }
+
+ @Override
+ public void setInput(IEditorInput input) {
+ try {
+ // Provide an URI with fragment in order to reuse the same Resource
+ // and set the diagram to the fragment.
+ URIEditorInput uriInput = new URIEditorInput(EcoreUtil.getURI(getDiagram()));
+ doSetInput(uriInput, true);
+ } catch (CoreException x) {
+ String title = "Problem opening";
+ String msg = "Cannot open input element:";
+ Shell shell = getSite().getShell();
+ ErrorDialog.openError(shell, title, msg, x.getStatus());
+ }
+ }
+
+ @Override
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ // TODO Auto-generated method stub
+ super.init(site, input);
+ setPartName(getDiagram().getName());
+ setTitleImage(DIAG_IMG_DESC.createImage());
+ }
+
+ @Override
+ protected String getEditingDomainID() {
+ // TODO Auto-generated method stub
+ return "org.eclipse.papyrus.diagram.newdiagram.EditingDomain";
+ }
+
+ @Override
+ public void setFocus() {
+ splitter.setFocus();
+ super.setFocus();
+ }
+
+ @Override
+ protected void createGraphicalViewer(Composite parent) {
+ splitter = parent;
+ super.createGraphicalViewer(parent);
+ }
+
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/docs/PapyrusDevelopperTutorial_OnDiagramCreating.odt b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/docs/PapyrusDevelopperTutorial_OnDiagramCreating.odt
new file mode 100644
index 00000000000..2a6c089a8e1
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/docs/PapyrusDevelopperTutorial_OnDiagramCreating.odt
Binary files differ
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/incomingLinksNavigatorGroup.gif b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/incomingLinksNavigatorGroup.gif
new file mode 100644
index 00000000000..fca9c53e629
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/incomingLinksNavigatorGroup.gif
Binary files differ
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linkSourceNavigatorGroup.gif b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linkSourceNavigatorGroup.gif
new file mode 100644
index 00000000000..fca9c53e629
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linkSourceNavigatorGroup.gif
Binary files differ
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linkTargetNavigatorGroup.gif b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linkTargetNavigatorGroup.gif
new file mode 100644
index 00000000000..fca9c53e629
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linkTargetNavigatorGroup.gif
Binary files differ
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linksNavigatorGroup.gif b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linksNavigatorGroup.gif
new file mode 100644
index 00000000000..fca9c53e629
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/linksNavigatorGroup.gif
Binary files differ
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/Component.gif b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/Component.gif
new file mode 100644
index 00000000000..56b94fc30b6
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/Component.gif
Binary files differ
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/Diagram_UML.gif b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/Diagram_UML.gif
new file mode 100644
index 00000000000..6d18ce49bd3
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/Diagram_UML.gif
Binary files differ
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/UMLDiagramFile.gif b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/UMLDiagramFile.gif
new file mode 100644
index 00000000000..de938070dea
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/UMLDiagramFile.gif
Binary files differ
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/newDiagramFile.gif b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/newDiagramFile.gif
new file mode 100644
index 00000000000..de938070dea
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/obj16/newDiagramFile.gif
Binary files differ
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/outgoingLinksNavigatorGroup.gif b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/outgoingLinksNavigatorGroup.gif
new file mode 100644
index 00000000000..fca9c53e629
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/outgoingLinksNavigatorGroup.gif
Binary files differ
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/wizban/NewUMLWizard.gif b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/wizban/NewUMLWizard.gif
new file mode 100644
index 00000000000..83e03bf39bf
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/icons/wizban/NewUMLWizard.gif
Binary files differ
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/messages.properties b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/messages.properties
new file mode 100644
index 00000000000..1239c08a5b0
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/messages.properties
@@ -0,0 +1,99 @@
+
+# TODO: manually put keys and values
+UMLCreationWizardTitle=New PapyrusNewDiagram Diagram
+UMLCreationWizard_DiagramModelFilePageTitle=Create PapyrusNewDiagram Diagram
+UMLCreationWizard_DiagramModelFilePageDescription=Select file that will contain diagram model.
+UMLCreationWizard_DomainModelFilePageTitle=Create PapyrusNewDiagram Domain Model
+UMLCreationWizard_DomainModelFilePageDescription=Select file that will contain domain model.
+UMLCreationWizardOpenEditorError=Error opening diagram editor
+UMLCreationWizardCreationError=Creation Problems
+UMLCreationWizardPageExtensionError=File name should have {0} extension.
+UMLDiagramEditorUtil_OpenModelResourceErrorDialogTitle=Error
+UMLDiagramEditorUtil_OpenModelResourceErrorDialogMessage=Failed to load model file {0}
+UMLDiagramEditorUtil_CreateDiagramProgressTask=Creating diagram and model files
+UMLDiagramEditorUtil_CreateDiagramCommandLabel=Creating diagram and model
+UMLDocumentProvider_isModifiable=Updating cache failed
+UMLDocumentProvider_handleElementContentChanged=Failed to refresh hierarchy for changed resource
+UMLDocumentProvider_IncorrectInputError={1}
+UMLDocumentProvider_NoDiagramInResourceError=Diagram is not present in resource
+UMLDocumentProvider_DiagramLoadingError=Error loading diagram
+UMLDocumentProvider_UnsynchronizedFileSaveError=The file has been changed on the file system
+UMLDocumentProvider_SaveDiagramTask=Saving diagram
+UMLDocumentProvider_SaveNextResourceTask=Saving {0}
+UMLDocumentProvider_SaveAsOperation=Saving {0} diagram as
+InitDiagramFile_ResourceErrorDialogTitle=Error
+InitDiagramFile_ResourceErrorDialogMessage=Model file loading failed
+InitDiagramFile_WizardTitle=Initialize new {0} diagram file
+InitDiagramFile_OpenModelFileDialogTitle=Select domain model
+UMLNewDiagramFileWizard_CreationPageName=Initialize new diagram file
+UMLNewDiagramFileWizard_CreationPageTitle=Diagram file
+UMLNewDiagramFileWizard_CreationPageDescription=Create new diagram based on {0} model content
+UMLNewDiagramFileWizard_RootSelectionPageName=Select diagram root element
+UMLNewDiagramFileWizard_RootSelectionPageTitle=Diagram root element
+UMLNewDiagramFileWizard_RootSelectionPageDescription=Select semantic model element to be depicted on diagram
+UMLNewDiagramFileWizard_RootSelectionPageSelectionTitle=Select diagram root element:
+UMLNewDiagramFileWizard_RootSelectionPageNoSelectionMessage=Diagram root element is not selected
+UMLNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage=Invalid diagram root element is selected
+UMLNewDiagramFileWizard_InitDiagramCommand=Initializing diagram contents
+UMLNewDiagramFileWizard_IncorrectRootError=Incorrect model object stored as a root resource object
+UMLDiagramEditor_SavingDeletedFile=The original file "{0}" has been deleted.
+UMLDiagramEditor_SaveAsErrorTitle=Problem During Save As...
+UMLDiagramEditor_SaveAsErrorMessage=Save could not be completed. Target file is already open in another editor.
+UMLDiagramEditor_SaveErrorTitle=Save Problems
+UMLDiagramEditor_SaveErrorMessage=Could not save file.
+UMLElementChooserDialog_SelectModelElementTitle=Select model element
+ModelElementSelectionPageMessage=Select model element:
+ValidateActionMessage=Validate
+createUml1Group_title=uml
+createComponent1CreationTool_title=Component
+createComponent1CreationTool_desc=Create new Component
+
+CommandName_OpenDiagram=Open Diagram
+NavigatorActionProvider_OpenDiagramActionName=Open Diagram
+AbstractParser_UnexpectedValueType=Value of type {0} is expected
+AbstractParser_WrongStringConversion=String value does not convert to {0} value
+AbstractParser_UnknownLiteral=Unknown literal: {0}
+
+MessageFormatParser_InvalidInputError=Invalid input at {0}
+UMLModelingAssistantProviderTitle=Select domain model element
+UMLModelingAssistantProviderMessage=Available domain model elements:
+Nodes1Group_title=Nodes
+Links2Group_title=Links
+Features3Group_title=Features
+Interface1CreationTool_title=Interface
+Interface1CreationTool_desc=Create new Interface
+Component2CreationTool_title=Component
+Component2CreationTool_desc=Create new Component
+Generalization1CreationTool_title=Generalization
+Generalization1CreationTool_desc=Create new Generalization
+Realization2CreationTool_title=Realization
+Realization2CreationTool_desc=Create new Realization
+Usage3CreationTool_title=Usage
+Usage3CreationTool_desc=Create new Usage
+Comment1CreationTool_title=Comment
+Comment1CreationTool_desc=Create new Comment
+Property2CreationTool_title=Property
+Property2CreationTool_desc=Create new Property
+Operation3CreationTool_title=Operation
+Operation3CreationTool_desc=Create new Operation
+Port4CreationTool_title=Port
+Port4CreationTool_desc=Create new Port
+NavigatorGroupName_Model_1000_links=links
+NavigatorGroupName_Comment_2002_incominglinks=incoming links
+NavigatorGroupName_Comment_2002_outgoinglinks=outgoing links
+NavigatorGroupName_Realization_4003_target=target
+NavigatorGroupName_Realization_4003_incominglinks=incoming links
+NavigatorGroupName_Realization_4003_source=source
+NavigatorGroupName_Realization_4003_outgoinglinks=outgoing links
+NavigatorGroupName_Component_2001_incominglinks=incoming links
+NavigatorGroupName_Component_2001_outgoinglinks=outgoing links
+NavigatorGroupName_Generalization_4002_target=target
+NavigatorGroupName_Generalization_4002_incominglinks=incoming links
+NavigatorGroupName_Generalization_4002_source=source
+NavigatorGroupName_Generalization_4002_outgoinglinks=outgoing links
+NavigatorGroupName_Usage_4001_target=target
+NavigatorGroupName_Usage_4001_incominglinks=incoming links
+NavigatorGroupName_Usage_4001_source=source
+NavigatorGroupName_Usage_4001_outgoinglinks=outgoing links
+NavigatorGroupName_Interface_2003_incominglinks=incoming links
+NavigatorGroupName_Interface_2003_outgoinglinks=outgoing links
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfgen b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfgen
new file mode 100644
index 00000000000..3949d5941ed
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfgen
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gmfgen:GenEditorGenerator xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:gmfgen="http://www.eclipse.org/gmf/2009/GenModel" packageNamePrefix="org.eclipse.papyrus.diagram.newdiagram"
+ modelID="PapyrusNewDiagram"
+ domainFileExtension="PapyrusNewDiagram"
+ dynamicTemplates="true"
+ templateDirectory="/org.eclipse.papyrus.def/dynamic-templates3.5/codegen"
+ pluginDirectory="/org.eclipse.papyrus.diagram.newdiagram/src">
+ <diagram
+ visualID="1000"
+ editPartClassName="ModelEditPart"
+ itemSemanticEditPolicyClassName="ModelItemSemanticEditPolicy"
+ canonicalEditPolicyClassName="ModelCanonicalEditPolicy"
+ iconProviderPriority="Low"
+ validationProviderPriority="Low">
+ <diagramRunTimeClass
+ href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Diagram"/>
+ <elementType
+ xsi:type="gmfgen:MetamodelType"
+ editHelperClassName="ModelEditHelper"/>
+ <viewmap
+ xsi:type="gmfgen:FigureViewmap"
+ figureQualifiedClassName="org.eclipse.draw2d.FreeformLayer"/>
+ <domainDiagramElement
+ href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Model"/>
+ <topLevelNodes
+ visualID="2001"
+ editPartClassName="ComponentEditPart"
+ itemSemanticEditPolicyClassName="ComponentItemSemanticEditPolicy"
+ notationViewFactoryClassName="ComponentViewFactory"
+ canonicalEditPolicyClassName="ComponentCanonicalEditPolicy"
+ graphicalNodeEditPolicyClassName="ComponentGraphicalNodeEditPolicy"
+ createCommandClassName="ComponentCreateCommand">
+ <diagramRunTimeClass
+ href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
+ <elementType
+ xsi:type="gmfgen:MetamodelType"
+ editHelperClassName="ComponentEditHelper"/>
+ <viewmap
+ xsi:type="gmfgen:InnerClassViewmap"
+ layoutType="FLOW_LAYOUT"
+ className="ComponentFigure"
+ classBody="&#xA;/**&#xA; * @generated&#xA; */&#xA;public class ComponentFigure extends org.eclipse.draw2d.RectangleFigure {&#xA;&#xA;&#xA;&#x9;/**&#xA;&#x9; * @generated&#xA;&#x9; */&#xA;&#x9;private org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel fFigureComponentNameFigure; &#xA;&#xA;&#xA;&#x9;/**&#xA;&#x9; * @generated&#xA;&#x9; */&#xA;&#x9;public ComponentFigure() {&#xA;&#x9;&#x9;&#xA;&#x9;org.eclipse.draw2d.FlowLayout layoutThis = new org.eclipse.draw2d.FlowLayout();&#xA;&#x9;layoutThis.setStretchMinorAxis(false);&#xA;&#x9;layoutThis.setMinorAlignment(org.eclipse.draw2d.FlowLayout.ALIGN_LEFTTOP&#xA;);&#xA;&#xA;&#x9;layoutThis.setMajorAlignment(org.eclipse.draw2d.FlowLayout.ALIGN_LEFTTOP&#xA;);&#xA;&#x9;layoutThis.setMajorSpacing(5);&#xA;&#x9;layoutThis.setMinorSpacing(5);&#xA;&#x9;layoutThis.setHorizontal(true);&#xA;&#xA;&#x9;this.setLayoutManager(layoutThis);&#xA;&#xA;&#x9;&#x9;&#x9;&#x9;createContents();&#xA;&#x9;}&#xA;&#x9;/**&#xA;&#x9; * @generated&#xA;&#x9; */&#xA;&#x9;private void createContents(){&#xA;&#xA;&#xA;fFigureComponentNameFigure = new org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel();&#xA;fFigureComponentNameFigure.setText(&quot;&lt;...>&quot;);&#xA;&#xA;this.add(fFigureComponentNameFigure);&#xA;&#xA;&#xA;&#x9;}&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#x9;/**&#xA;&#x9; * @generated&#xA;&#x9; */&#xA;&#x9;public org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel getFigureComponentNameFigure() {&#xA;&#x9;&#x9;return fFigureComponentNameFigure;&#xA;&#x9;}&#xA;&#xA;&#xA;}&#xA;&#xA;"/>
+ <modelFacet>
+ <metaClass
+ href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Component"/>
+ <containmentMetaFeature
+ href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Package/packagedElement"/>
+ <childMetaFeature
+ href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Package/packagedElement"/>
+ </modelFacet>
+ <labels
+ visualID="5001"
+ editPartClassName="ComponentNameEditPart"
+ itemSemanticEditPolicyClassName="ComponentNameItemSemanticEditPolicy"
+ notationViewFactoryClassName="ComponentNameViewFactory"
+ elementIcon="true">
+ <diagramRunTimeClass
+ href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
+ <viewmap
+ xsi:type="gmfgen:ParentAssignedViewmap"
+ getterName="getFigureComponentNameFigure"
+ figureQualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"/>
+ <modelFacet
+ xsi:type="gmfgen:FeatureLabelModelFacet"
+ parser="//@labelParsers/@implementations.0">
+ <metaFeatures
+ href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/>
+ </modelFacet>
+ </labels>
+ </topLevelNodes>
+ <palette>
+ <groups
+ title="uml"
+ largeIconPath="icons/obj16/Diagram_UML.gif"
+ smallIconPath="icons/obj16/Diagram_UML.gif">
+ <entries
+ xsi:type="gmfgen:ToolEntry"
+ title="Component"
+ description="Create new Component"
+ largeIconPath="icons/obj16/Component.gif"
+ smallIconPath="icons/obj16/Component.gif"
+ genNodes="//@diagram/@topLevelNodes.0"/>
+ </groups>
+ </palette>
+ <preferencePages
+ xsi:type="gmfgen:GenStandardPreferencePage"
+ iD="org.eclipse.uml2.uml.diagram.general"
+ name="UML Diagram">
+ <children
+ xsi:type="gmfgen:GenStandardPreferencePage"
+ iD="org.eclipse.uml2.uml.diagram.appearance"
+ name="Appearance"
+ kind="Appearance"/>
+ <children
+ xsi:type="gmfgen:GenStandardPreferencePage"
+ iD="org.eclipse.uml2.uml.diagram.connections"
+ name="Connections"
+ kind="Connections"/>
+ <children
+ xsi:type="gmfgen:GenStandardPreferencePage"
+ iD="org.eclipse.uml2.uml.diagram.printing"
+ name="Printing"
+ kind="Printing"/>
+ <children
+ xsi:type="gmfgen:GenStandardPreferencePage"
+ iD="org.eclipse.uml2.uml.diagram.rulersAndGrid"
+ name="Rulers And Grid"
+ kind="RulersAndGrid"/>
+ </preferencePages>
+ </diagram>
+ <plugin>
+ <requiredPlugins>org.eclipse.draw2d</requiredPlugins>
+ </plugin>
+ <editor/>
+ <navigator>
+ <childReferences
+ child="//@diagram"/>
+ <childReferences
+ parent="//@diagram"
+ child="//@diagram/@topLevelNodes.0"/>
+ </navigator>
+ <diagramUpdater/>
+ <propertySheet>
+ <tabs
+ xsi:type="gmfgen:GenStandardPropertyTab"
+ iD="appearance"/>
+ <tabs
+ xsi:type="gmfgen:GenStandardPropertyTab"
+ iD="diagram"/>
+ <tabs
+ xsi:type="gmfgen:GenCustomPropertyTab"
+ iD="domain"
+ label="Core">
+ <filter
+ xsi:type="gmfgen:TypeTabFilter">
+ <types>org.eclipse.gmf.runtime.notation.View</types>
+ <types>org.eclipse.gef.EditPart</types>
+ <generatedTypes>abstractNavigatorItem</generatedTypes>
+ </filter>
+ </tabs>
+ </propertySheet>
+ <domainGenModel
+ href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#/"/>
+ <labelParsers
+ extensibleViaService="true">
+ <implementations
+ xsi:type="gmfgen:PredefinedParser"
+ uses="//@diagram/@topLevelNodes.0/@labels.0/@modelFacet"/>
+ </labelParsers>
+ <contextMenus
+ context="//@diagram">
+ <items
+ xsi:type="gmfgen:LoadResourceAction"/>
+ </contextMenus>
+</gmfgen:GenEditorGenerator>
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfgraph b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfgraph
new file mode 100644
index 00000000000..557af9b570b
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfgraph
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gmfgraph:Canvas xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:gmfgraph="http://www.eclipse.org/gmf/2006/GraphicalDefinition" name="uml">
+ <figures
+ name="Default">
+ <descriptors
+ name="ComponentFigure">
+ <actualFigure
+ xsi:type="gmfgraph:Rectangle"
+ name="ComponentFigure">
+ <layout
+ xsi:type="gmfgraph:FlowLayout"/>
+ <children
+ xsi:type="gmfgraph:Label"
+ name="ComponentNameFigure"
+ text="&lt;...>"/>
+ </actualFigure>
+ <accessors
+ figure="//@figures.0/@descriptors.0/@actualFigure/@children.0"/>
+ </descriptors>
+ </figures>
+ <nodes
+ name="Component"
+ figure="ComponentFigure"/>
+ <labels
+ name="ComponentName"
+ figure="ComponentFigure"
+ accessor="//@figures.0/@descriptors.0/@accessors.0"/>
+</gmfgraph:Canvas>
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfmap b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfmap
new file mode 100644
index 00000000000..83d8442d6ea
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmfmap
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gmfmap:Mapping xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings"
+ xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
+ <nodes>
+ <containmentFeature
+ href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//Package/packagedElement"/>
+ <ownedChild>
+ <domainMetaElement
+ href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//Component"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="newdiagram.gmfgraph#ComponentName"/>
+ <features
+ href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//NamedElement/name"/>
+ </labelMappings>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="newdiagram.gmftool#//@palette/@tools.0/@tools.0"/>
+ <diagramNode
+ href="newdiagram.gmfgraph#Component"/>
+ </ownedChild>
+ </nodes>
+ <diagram>
+ <diagramCanvas
+ href="newdiagram.gmfgraph#uml"/>
+ <domainModel
+ href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#/"/>
+ <domainMetaElement
+ href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//Model"/>
+ <palette
+ href="newdiagram.gmftool#//@palette"/>
+ </diagram>
+</gmfmap:Mapping>
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmftool b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmftool
new file mode 100644
index 00000000000..af9d32d62d9
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.gmftool
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gmftool:ToolRegistry xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
+ <palette
+ title="umlPalette">
+ <tools
+ xsi:type="gmftool:ToolGroup"
+ title="uml">
+ <smallIcon
+ xsi:type="gmftool:BundleImage"
+ path="icons/obj16/Diagram_UML.gif"/>
+ <largeIcon
+ xsi:type="gmftool:BundleImage"
+ path="icons/obj16/Diagram_UML.gif"/>
+ <tools
+ xsi:type="gmftool:CreationTool"
+ title="Component"
+ description="Create new Component">
+ <smallIcon
+ xsi:type="gmftool:BundleImage"
+ path="icons/obj16/Component.gif"/>
+ <largeIcon
+ xsi:type="gmftool:BundleImage"
+ path="icons/obj16/Component.gif"/>
+ </tools>
+ </tools>
+ </palette>
+</gmftool:ToolRegistry>
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.trace b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.trace
new file mode 100644
index 00000000000..48670f3a490
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/model/newdiagram.trace
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<trace:TraceModel xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:trace="http://www.eclipse.org/gmf/2006/Trace">
+ <nodeTraces
+ visualID="2001"
+ queryText="(let _eClass_:ecore::EClass = modelFacet.metaClass.ecoreClass in _eClass_.ePackage.nsURI = 'http://www.eclipse.org/uml2/3.0.0/UML' and _eClass_.name = 'Component') and (let _containmentMF_:ecore::EStructuralFeature = modelFacet.containmentMetaFeature.ecoreFeature in (let _eClass_:ecore::EClass = _containmentMF_.eContainingClass in _eClass_.ePackage.nsURI = 'http://www.eclipse.org/uml2/3.0.0/UML' and _eClass_.name = 'Package') and _containmentMF_.name = 'packagedElement')">
+ <nodeLabelTraces
+ visualID="5001"
+ queryText="true"/>
+ </nodeTraces>
+</trace:TraceModel>
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/plugin.properties b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/plugin.properties
new file mode 100644
index 00000000000..7017c272c72
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/plugin.properties
@@ -0,0 +1,34 @@
+pluginName=Papyrus New Diagram (Incubation)
+providerName=Eclipse Modeling Project
+editorName=PapyrusNewDiagram Diagram Editing
+context.description=PapyrusNewDiagram Diagram Editing
+context.name=In PapyrusNewDiagram Diagram Editor
+newWizardName=PapyrusNewDiagram Diagram
+newWizardDesc=Creates PapyrusNewDiagram diagram.
+ initDiagramActionLabel=Initialize PapyrusNewDiagram_diagram diagram file
+ navigatorContentName=*.PapyrusNewDiagram_diagram diagram contents
+domainNavigatorContentName=*.PapyrusNewDiagram model contents
+update.diagram.name=Update PapyrusNewDiagram diagram
+update.diagram.description=Perform PapyrusNewDiagram diagram update
+ tab.appearance=Appearance
+tab.diagram=Rulers & Grid
+tab.domain=Core
+ prefpage.org.eclipse.uml2.uml.diagram.general=UML Diagram
+prefpage.org.eclipse.uml2.uml.diagram.appearance=Appearance
+prefpage.org.eclipse.uml2.uml.diagram.connections=Connections
+prefpage.org.eclipse.uml2.uml.diagram.printing=Printing
+prefpage.org.eclipse.uml2.uml.diagram.rulersAndGrid=Rulers And Grid
+ metatype.name.Package_1000=Undefined
+metatype.name.Component_2001=Component
+ cmdcategory.name=PapyrusNewDiagram Editor Commands
+cmdcategory.desc=PapyrusNewDiagram Editor Commands
+
+metatype.name.Model_1000=Undefined
+metatype.name.Interface_2003=Interface
+metatype.name.Comment_2002=Comment
+metatype.name.Property_3001=Property
+metatype.name.Operation_3002=Operation
+metatype.name.Usage_4001=Usage
+metatype.name.Generalization_4002=Generalization
+metatype.name.Realization_4003=Realization
+
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/plugin.xml b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/plugin.xml
new file mode 100644
index 00000000000..3670be5797c
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/plugin.xml
@@ -0,0 +1,605 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.example.diagram.simplediagram.CreateDiagramCommand"
+ description="Create a Tutorial Diagram"
+ id="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand"
+ name="Create a Tutorial Diagram">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.example.diagram.simplediagram.CreateDiagramCommand"
+ commandId="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand">
+ <activeWhen>
+ <with
+ variable="activeEditorId">
+ <equals
+ value="org.eclipse.papyrus.core.papyrusEditor">
+ </equals>
+ </with>
+ </activeWhen>
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="menu:org.eclipse.papyrus.ui.menu">
+ <menu
+ id="org.eclipse.papyrus.diagram.ui.menu.diagrams"
+ label="Diagrams">
+ <command
+ commandId="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand"
+ icon="icons/obj16/newDiagramFile.gif"
+ label="Create a new Simple Diagram"
+ style="push"
+ tooltip="Create a new Simple Diagram">
+ <visibleWhen>
+ <reference
+ definitionId="org.eclipse.papyrus.diagram.common.IsPapyrusActiveWithUMLModel">
+ </reference>
+ </visibleWhen>
+ </command>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ locationURI="toolbar:org.eclipse.ui.main.toolbar">
+ <toolbar
+ id="org.eclipse.papyrus.diagram.ui.toolbar">
+ <command
+ commandId="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand"
+ icon="icons/obj16/newDiagramFile.gif"
+ label="Create a new Simple Diagram"
+ style="push"
+ tooltip="Create a new Simple Diagram">
+ <visibleWhen>
+ <reference
+ definitionId="org.eclipse.papyrus.diagram.common.IsPapyrusActiveWithUMLModel">
+ </reference>
+ </visibleWhen>
+ </command>
+ </toolbar>
+ </menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.papyrus.modelexplorer.popupmenu.creatediagram">
+ <command
+ commandId="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand"
+ icon="icons/obj16/newDiagramFile.gif"
+ label="Create a new Simple Diagram"
+ style="push"
+ tooltip="Create a new Component Diagram">
+ <visibleWhen>
+ <reference
+ definitionId="org.eclipse.papyrus.diagram.common.IsPapyrusActiveWithUMLModel">
+ </reference>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.core.papyrusDiagram">
+ <editorDiagram
+ actionBarContributorId="org.eclipse.papyrus.diagram.common.part.UMLDiagramActionBarContributor"
+ contextId="com.cea.papyrus.gmf.editor.context"
+ factoryClass="org.eclipse.papyrus.example.diagram.simplediagram.DiagramEditorFactory"
+ icon="icons/obj16/newDiagramFile.gif">
+ </editorDiagram>
+ <creationCommand
+ creationCommandClass="org.eclipse.papyrus.example.diagram.simplediagram.CreateDiagramCommand"
+ icon="icons/obj16/newDiagramFile.gif"
+ id="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand"
+ label="UML Tutorial Diagram"
+ language="uml">
+ </creationCommand>
+ </extension>
+
+
+
+ <extension point="org.eclipse.ui.contexts" id="ui-context">
+ <?gmfgen generated="true"?>
+ <context
+ description="%context.description"
+ id="org.eclipse.papyrus.diagram.newdiagram.ui.diagramContext"
+ name="%context.name"
+ parentId="org.eclipse.gmf.runtime.diagram.ui.diagramContext">
+ </context>
+ </extension>
+
+
+ <extension point="org.eclipse.gmf.runtime.common.ui.services.action.globalActionHandlerProviders" id="global-actions">
+ <?gmfgen generated="true"?>
+ <GlobalActionHandlerProvider
+ class="org.eclipse.papyrus.diagram.common.providers.PapyrusGlobalActionHandlerProvider"
+ id="PapyrusNewDiagramPresentation">
+ <Priority name="Highest"/>
+ <ViewId id="org.eclipse.papyrus.core.papyrusEditor">
+ <ElementType class="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart">
+ <GlobalActionId actionId="delete"/>
+ </ElementType>
+ <ElementType class="org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart">
+ <GlobalActionId actionId="save"/>
+ </ElementType>
+ </ViewId>
+ </GlobalActionHandlerProvider>
+ <GlobalActionHandlerProvider
+ class="org.eclipse.gmf.runtime.diagram.ui.providers.ide.providers.DiagramIDEGlobalActionHandlerProvider"
+ id="PapyrusNewDiagramPresentationIDE">
+ <Priority name="Low"/>
+ <ViewId id="org.eclipse.papyrus.core.papyrusEditor">
+ <ElementType class="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart">
+ <GlobalActionId actionId="bookmark"/>
+ </ElementType>
+ </ViewId>
+ </GlobalActionHandlerProvider>
+ <GlobalActionHandlerProvider
+ class="org.eclipse.papyrus.diagram.common.providers.PapyrusGlobalActionHandlerProvider"
+ id="PapyrusNewDiagramRender">
+ <Priority name="Highest"/>
+ <ViewId id="org.eclipse.papyrus.core.papyrusEditor">
+ <ElementType class="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart">
+ <GlobalActionId actionId="cut"/>
+ <GlobalActionId actionId="copy"/>
+ <GlobalActionId actionId="paste"/>
+ </ElementType>
+ </ViewId>
+ </GlobalActionHandlerProvider>
+ </extension>
+
+
+
+ <?gmfgen generated="true"?>
+
+ <?gmfgen generated="true"?>
+
+ <extension point="org.eclipse.ui.preferencePages" id="prefpages">
+ <?gmfgen generated="true"?>
+ <page
+ id="org.eclipse.papyrus.preferences.diagrams.PapyrusNewDiagram"
+ name="PapyrusNewDiagram Diagram"
+ category="org.eclipse.papyrus.preferences.diagrams"
+ class="org.eclipse.papyrus.example.diagram.simplediagram.preferences.DiagramGeneralPreferencePage">
+ </page>
+
+
+
+ <page
+ id="org.eclipse.papyrus.diagram.newdiagram.preferences.DiagramPrintingPreferencePage"
+ name="%prefpage.org.eclipse.uml2.uml.diagram.printing"
+ category="org.eclipse.papyrus.preferences.diagrams.PapyrusNewDiagram"
+ class="org.eclipse.papyrus.example.diagram.simplediagram.preferences.DiagramPrintingPreferencePage">
+ </page>
+
+ <page
+ id="org.eclipse.papyrus.diagram.newdiagram.preferences.DiagramRulersAndGridPreferencePage"
+ name="%prefpage.org.eclipse.uml2.uml.diagram.rulersAndGrid"
+ category="org.eclipse.papyrus.preferences.diagrams.PapyrusNewDiagram"
+ class="org.eclipse.papyrus.example.diagram.simplediagram.preferences.DiagramRulersAndGridPreferencePage">
+ </page>
+
+ </extension>
+
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyContributor" id="prop-contrib">
+ <?gmfgen generated="true"?>
+ <propertyContributor
+ contributorId="org.eclipse.uml2.uml.diagram"
+ labelProvider="org.eclipse.papyrus.example.diagram.simplediagram.sheet.UMLSheetLabelProvider">
+ <propertyCategory category="domain"/>
+ <propertyCategory category="visual"/>
+ <propertyCategory category="extra"/>
+ </propertyContributor>
+ </extension>
+
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs" id="proptabs">
+ <?gmfgen generated="true"?>
+ <propertyTabs contributorId="org.eclipse.uml2.uml.diagram">
+ <propertyTab
+ category="visual"
+ id="property.tab.AppearancePropertySection"
+ label="%tab.appearance"/>
+ <propertyTab
+ category="visual"
+ id="property.tab.DiagramPropertySection"
+ label="%tab.diagram"/>
+ <propertyTab
+ category="domain"
+ id="property.tab.domain"
+ label="%tab.domain"/>
+ </propertyTabs>
+ </extension>
+
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertySections" id="propsections">
+ <?gmfgen generated="true"?>
+ <propertySections contributorId="org.eclipse.uml2.uml.diagram">
+ <propertySection id="property.section.ConnectorAppearancePropertySection"
+ filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.ConnectionEditPartPropertySectionFilter"
+ class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ConnectionAppearancePropertySection"
+ tab="property.tab.AppearancePropertySection">
+ </propertySection>
+ <propertySection id="property.section.ShapeColorAndFontPropertySection"
+ filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.ShapeEditPartPropertySectionFilter"
+ class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ShapeColorsAndFontsPropertySection"
+ tab="property.tab.AppearancePropertySection">
+ </propertySection>
+ <propertySection id="property.section.DiagramColorsAndFontsPropertySection"
+ filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.DiagramEditPartPropertySectionFilter"
+ class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.DiagramColorsAndFontsPropertySection"
+ tab="property.tab.AppearancePropertySection">
+ </propertySection>
+ <propertySection id="property.section.RulerGridPropertySection"
+ filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.DiagramEditPartPropertySectionFilter"
+ class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.grid.RulerGridPropertySection"
+ tab="property.tab.DiagramPropertySection">
+ </propertySection>
+ <propertySection
+ id="property.section.domain"
+ tab="property.tab.domain"
+ class="org.eclipse.papyrus.example.diagram.simplediagram.sheet.UMLPropertySection">
+ <input type="org.eclipse.gmf.runtime.notation.View"/>
+ <input type="org.eclipse.gef.EditPart"/>
+ <input type="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLAbstractNavigatorItem"/>
+ </propertySection>
+ </propertySections>
+ </extension>
+
+
+<?gmfgen generated="true"?>
+
+ <extension point="org.eclipse.core.runtime.preferences">
+ <?gmfgen generated="true"?>
+ <initializer class="org.eclipse.papyrus.example.diagram.simplediagram.preferences.DiagramPreferenceInitializer"/>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.diagram.core.viewProviders" id="view-provider">
+ <?gmfgen generated="true"?>
+ <viewProvider class="org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLViewProvider">
+ <Priority name="Lowest"/>
+ <context viewClass="org.eclipse.gmf.runtime.notation.Diagram" semanticHints="PapyrusNewDiagram"/>
+ <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="2001"/>
+ </viewProvider>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders" id="ep-provider">
+ <?gmfgen generated="true"?>
+ <editpartProvider class="org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLEditPartProvider">
+ <Priority name="Lowest"/>
+ <object class="org.eclipse.gmf.runtime.notation.Diagram" id="generated-diagram">
+ <method name="getType()" value="PapyrusNewDiagram"/>
+ </object>
+ <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-nodes">
+ <method name="getType()" value="2001"/>
+ </object>
+ <object class="org.eclipse.gmf.runtime.notation.Edge" id="generated-links">
+ <method name="getType()" value=""/>
+ </object>
+ <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-labels">
+ <method name="getType()" value="5001"/>
+ </object>
+ <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-compartments">
+ <method name="getType()" value=""/>
+ </object>
+ <context views="generated-diagram,generated-nodes,generated-links,generated-labels,generated-compartments"/>
+ </editpartProvider>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.emf.ui.modelingAssistantProviders" id="modelassist-provider">
+ <?gmfgen generated="true"?>
+ <modelingAssistantProvider class="org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLModelingAssistantProvider">
+ <Priority name="Lowest"/>
+ <object class="org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart" id="Model_1000"/>
+ <object class="org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentEditPart" id="Component_2001"/>
+ <context elements="Model_1000,Component_2001"/>
+ </modelingAssistantProvider>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.common.ui.services.iconProviders" id="icon-provider">
+ <?gmfgen generated="true"?>
+ <IconProvider class="org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLIconProvider">
+ <Priority name="Low"/>
+ </IconProvider>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.common.ui.services.parserProviders" id="parser-provider">
+ <?gmfgen generated="true"?>
+ <ParserProvider class="org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLParserProvider">
+ <Priority name="Lowest"/>
+ </ParserProvider>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes" id="element-types">
+ <?gmfgen generated="true"?>
+ <metamodel nsURI="http://www.eclipse.org/uml2/3.0.0/UML">
+ <metamodelType
+ id="org.eclipse.uml2.uml.diagram.Model_1000"
+ name="%metatype.name.Model_1000"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"
+ eclass="Model"
+ edithelper="org.eclipse.papyrus.example.diagram.simplediagram.edit.helpers.ModelEditHelper">
+ <param name="semanticHint" value="1000"/>
+ </metamodelType>
+ </metamodel>
+ <metamodel nsURI="http://www.eclipse.org/uml2/3.0.0/UML">
+ <metamodelType
+ id="org.eclipse.uml2.uml.diagram.Component_2001"
+ name="%metatype.name.Component_2001"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"
+ eclass="Component"
+ edithelper="org.eclipse.papyrus.example.diagram.simplediagram.edit.helpers.ComponentEditHelper">
+ <param name="semanticHint" value="2001"/>
+ </metamodelType>
+ </metamodel>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings" id="element-types-bindings">
+ <?gmfgen generated="true"?>
+ <clientContext id="org.eclipse.uml2.uml.diagram.TypeContext">
+ <enablement>
+ <test
+ property="org.eclipse.gmf.runtime.emf.core.editingDomain"
+ value="org.eclipse.uml2.uml.diagram.EditingDomain"/>
+ </enablement>
+ </clientContext>
+ <binding context="org.eclipse.uml2.uml.diagram.TypeContext">
+ <elementType ref="org.eclipse.uml2.uml.diagram.Model_1000"/>
+ <elementType ref="org.eclipse.uml2.uml.diagram.Component_2001"/>
+ <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ </binding>
+ </extension>
+ <extension point="org.eclipse.core.expressions.propertyTesters" id="navigator-proptest.isURIEditorInput">
+ <?gmfgen generated="true"?>
+ <propertyTester
+ id="org.eclipse.uml2.uml.diagram.URIEditorInputPropertyTester"
+ type="org.eclipse.emf.common.ui.URIEditorInput"
+ namespace="org.eclipse.uml2.uml.diagram"
+ properties="isURIEditorInput"
+ class="org.eclipse.papyrus.example.diagram.simplediagram.part.UMLUriEditorInputTester">
+ </propertyTester>
+ </extension>
+
+ <extension point="org.eclipse.ui.navigator.viewer" id="navigator-viewbinding">
+ <?gmfgen generated="true"?>
+ <viewerContentBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+ <includes>
+ <contentExtension pattern="org.eclipse.uml2.uml.diagram.resourceContent"/>
+ <contentExtension pattern="org.eclipse.uml2.uml.diagram.domainResourceContent"/>
+ <contentExtension pattern="org.eclipse.uml2.uml.diagram.navigatorLinkHelper"/>
+ </includes>
+ </viewerContentBinding>
+ <viewerActionBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+ <includes>
+ <actionExtension pattern="org.eclipse.uml2.uml.diagram.navigatorActionProvider"/>
+ </includes>
+ </viewerActionBinding>
+ </extension>
+
+ <extension point="org.eclipse.ui.navigator.navigatorContent" id="navigator-content">
+ <?gmfgen generated="true"?>
+ <navigatorContent
+ id="org.eclipse.uml2.uml.diagram.resourceContent"
+ name="%navigatorContentName"
+ priority="normal"
+ contentProvider="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorContentProvider"
+ labelProvider="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorLabelProvider"
+ icon="icons/obj16/UMLDiagramFile.gif"
+ activeByDefault="true">
+ <triggerPoints>
+ <or>
+ <and>
+ <instanceof value="org.eclipse.core.resources.IFile"/>
+ <test property="org.eclipse.core.resources.extension" value="PapyrusNewDiagram_diagram"/>
+ </and>
+ <instanceof value="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLAbstractNavigatorItem"/>
+ </or>
+ </triggerPoints>
+ <possibleChildren>
+ <or>
+ <instanceof value="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLAbstractNavigatorItem"/>
+ </or>
+ </possibleChildren>
+ <commonSorter
+ id="org.eclipse.uml2.uml.diagram.navigatorSorter"
+ class="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorSorter">
+ <parentExpression>
+ <or>
+ <and>
+ <instanceof value="org.eclipse.core.resources.IFile"/>
+ <test property="org.eclipse.core.resources.extension" value="PapyrusNewDiagram_diagram"/>
+ </and>
+ <instanceof value="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLAbstractNavigatorItem"/>
+ </or>
+ </parentExpression>
+ </commonSorter>
+ </navigatorContent>
+ <navigatorContent
+ id="org.eclipse.uml2.uml.diagram.domainResourceContent"
+ name="%domainNavigatorContentName"
+ priority="normal"
+ contentProvider="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLDomainNavigatorContentProvider"
+ labelProvider="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLDomainNavigatorLabelProvider"
+ icon="icons/obj16/UMLDiagramFile.gif"
+ activeByDefault="true">
+ <triggerPoints>
+ <or>
+ <and>
+ <instanceof value="org.eclipse.core.resources.IFile"/>
+ <test property="org.eclipse.core.resources.extension" value="PapyrusNewDiagram"/>
+ </and>
+ <instanceof value="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLDomainNavigatorItem"/>
+ </or>
+ </triggerPoints>
+ <possibleChildren>
+ <instanceof value="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLDomainNavigatorItem"/>
+ </possibleChildren>
+ </navigatorContent>
+ <actionProvider
+ id="org.eclipse.uml2.uml.diagram.navigatorActionProvider"
+ class="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorActionProvider">
+ <enablement>
+ <or>
+ <instanceof value="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLAbstractNavigatorItem"/>
+ </or>
+ </enablement>
+ </actionProvider>
+ </extension>
+
+ <extension point="org.eclipse.ui.navigator.linkHelper" id="navigator-linkhelper">
+ <?gmfgen generated="true"?>
+ <linkHelper
+ id="org.eclipse.uml2.uml.diagram.navigatorLinkHelper"
+ class="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorLinkHelper">
+ <editorInputEnablement>
+ <and>
+ <instanceof value="org.eclipse.emf.common.ui.URIEditorInput"/>
+ <test property="org.eclipse.uml2.uml.diagram.isURIEditorInput"/>
+ </and>
+ </editorInputEnablement>
+ <selectionEnablement>
+ <instanceof value="org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLAbstractNavigatorItem"/>
+ </selectionEnablement>
+ </linkHelper>
+ </extension>
+ <extension point="org.eclipse.ui.commands" id="update-cmd">
+ <?gmfgen generated="true"?>
+ <command
+ categoryId="org.eclipse.ui.category.edit"
+ defaultHandler="org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramUpdateCommand"
+ description="%update.diagram.description"
+ id="org.eclipse.papyrus.diagram.newdiagram.updateDiagram"
+ name="%update.diagram.name"/>
+ </extension>
+
+ <extension point="org.eclipse.ui.bindings" id="update-cmd-binding">
+ <?gmfgen generated="true"?>
+ <key
+ commandId="org.eclipse.papyrus.diagram.newdiagram.updateDiagram"
+ contextId="org.eclipse.papyrus.diagram.newdiagram.ui.diagramContext"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="F5"/>
+ </extension>
+
+ <extension point="org.eclipse.ui.menus" id="context-menus">
+ <?gmfgen generated="true"?>
+ <!-- menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=">
+ </menuContribution>
+ <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=">
+ </menuContribution -->
+ <menuContribution locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu">
+ <command commandId="org.eclipse.uml2.uml.diagram.LoadResourceAction">
+ <visibleWhen>
+ <and>
+ <with variable="activePartId"><equals value="org.eclipse.papyrus.diagram.newdiagram.part.UMLDiagramEditorID"/></with>
+ <with variable="selection"><iterate ifEmpty="false">
+ <instanceof value="org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart"/>
+ </iterate></with>
+ </and>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+
+ <extension point="org.eclipse.ui.commands" id="menu-commands">
+ <?gmfgen generated="true"?>
+ <category id="org.eclipse.papyrus.diagram.newdiagram.part.UMLDiagramEditorID" name="%cmdcategory.name" description="%cmdcategory.desc"/>
+ <command id="org.eclipse.uml2.uml.diagram.LoadResourceAction"
+ name="Load Resource"
+ categoryId="org.eclipse.papyrus.diagram.newdiagram.part.UMLDiagramEditorID"
+ defaultHandler="org.eclipse.papyrus.example.diagram.simplediagram.part.LoadResourceAction"/>
+ </extension>
+
+ <extension point="org.eclipse.ui.handlers" id="menu-handlers">
+ <?gmfgen generated="true"?>
+ </extension>
+
+
+
+
+<extension
+ id="UML Plugin.palettedefinition"
+ name="UML Plugin Predefined Entries"
+ point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders">
+
+ <?gmfgen generated="true"?>
+ <paletteProvider class="org.eclipse.gmf.runtime.diagram.ui.providers.DefaultPaletteProvider">
+ <Priority name="Lowest"/>
+ <contribution
+ factoryClass="org.eclipse.papyrus.example.diagram.simplediagram.part.UMLPaletteFactory">
+ <predefinedEntry id="standardGroup/noteStack/noteTool" remove="true"/>
+ <predefinedEntry id="standardGroup/noteStack/textTool" remove="true"/>
+ <predefinedEntry id="standardGroup/noteStack/noteattachmentTool" remove="true"/>
+ <entry
+ defineOnly="true"
+ description="Create new Component"
+ id="createComponent1CreationTool"
+ kind="tool"
+ label="Component"
+ large_icon="icons/obj16/Component.gif"
+ path=""
+ small_icon="icons/obj16/Component.gif">
+ </entry>
+
+ </contribution>
+ </paletteProvider>
+
+ </extension>
+
+<extension
+ id="UML Plugin.standard"
+ name="UML Plugin Standard Palette"
+ point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders">
+
+ <?gmfgen generated="true"?>
+ <paletteProvider class="org.eclipse.gmf.runtime.diagram.ui.providers.DefaultPaletteProvider">
+ <Priority name="Low"/>
+ <contribution
+ factoryClass="org.eclipse.papyrus.example.diagram.simplediagram.part.UMLPaletteFactory">
+ <predefinedEntry id="standardGroup/noteStack/noteTool" remove="true"/>
+ <predefinedEntry id="standardGroup/noteStack/textTool" remove="true"/>
+ <predefinedEntry id="standardGroup/noteStack/noteattachmentTool" remove="true"/>
+ <entry
+ description=""
+ id="createUml1Group"
+ kind="drawer"
+ label="uml"
+ large_icon="icons/obj16/Diagram_UML.gif"
+ path="/"
+ small_icon="icons/obj16/Diagram_UML.gif">
+ <expand
+ force="true">
+ </expand>
+ </entry>
+
+ <predefinedEntry
+ id="createComponent1CreationTool"
+ path="/createUml1Group">
+ </predefinedEntry>
+
+
+ </contribution>
+ <editor id="org.eclipse.uml2.uml.diagram"/>
+ </paletteProvider>
+
+ </extension>
+
+<extension point="org.eclipse.ui.preferencePages">
+
+
+
+ <?gmfgen generated="true"?>
+ <page category="org.eclipse.papyrus.preferences.diagrams.PapyrusNewDiagram"
+ class="org.eclipse.papyrus.example.diagram.simplediagram.preferences.ComponentPreferencePage"
+ id="org.eclipse.papyrus.diagram.newdiagram.preferences.ComponentPreferencePage"
+ name="Component Node" />
+
+
+
+
+</extension>
+
+
+
+ <!-- optionally, specify keybindings -->
+</plugin>
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/commands/ComponentCreateCommand.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/commands/ComponentCreateCommand.java
new file mode 100644
index 00000000000..83341f3826a
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/commands/ComponentCreateCommand.java
@@ -0,0 +1,119 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.uml2.uml.Component;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * @generated
+ */
+public class ComponentCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private EClass eClass = null;
+ /**
+ * @generated
+ */
+ private EObject eObject = null;
+
+ /**
+ * @generated
+ */
+ public ComponentCreateCommand(CreateElementRequest req, EObject eObject) {
+ super(req.getLabel(), null, req);
+ this.eObject = eObject;
+ this.eClass = eObject != null ? eObject.eClass() : null;
+ }
+
+ /**
+ * @generated
+ */
+ public static ComponentCreateCommand create(CreateElementRequest req,
+ EObject eObject) {
+ return new ComponentCreateCommand(req, eObject);
+ }
+
+ /**
+ * @generated
+ */
+ public ComponentCreateCommand(CreateElementRequest req) {
+ super(req.getLabel(), null, req);
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ * @generated
+ */
+ protected EObject getElementToEdit() {
+
+ EObject container = ((CreateElementRequest) getRequest())
+ .getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ if (container != null) {
+ return container;
+ }
+ return eObject;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+
+ return true;
+
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
+ IAdaptable info) throws ExecutionException {
+
+ Component newElement = UMLFactory.eINSTANCE.createComponent();
+
+ Package owner = (Package) getElementToEdit();
+ owner.getPackagedElements().add(newElement);
+
+ doConfigure(newElement, monitor, info);
+
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Component newElement, IProgressMonitor monitor,
+ IAdaptable info) throws ExecutionException {
+ IElementType elementType = ((CreateElementRequest) getRequest())
+ .getElementType();
+ ConfigureRequest configureRequest = new ConfigureRequest(
+ getEditingDomain(), newElement, elementType);
+ configureRequest.setClientContext(((CreateElementRequest) getRequest())
+ .getClientContext());
+ configureRequest.addParameters(getRequest().getParameters());
+ ICommand configureCommand = elementType
+ .getEditCommand(configureRequest);
+ if (configureCommand != null && configureCommand.canExecute()) {
+ configureCommand.execute(monitor, info);
+ }
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/ComponentEditHelper.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/ComponentEditHelper.java
new file mode 100644
index 00000000000..7207c3db8d5
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/ComponentEditHelper.java
@@ -0,0 +1,7 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.helpers;
+
+/**
+ * @generated
+ */
+public class ComponentEditHelper extends UMLBaseEditHelper {
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/ModelEditHelper.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/ModelEditHelper.java
new file mode 100644
index 00000000000..c12113eb6be
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/ModelEditHelper.java
@@ -0,0 +1,7 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.helpers;
+
+/**
+ * @generated
+ */
+public class ModelEditHelper extends UMLBaseEditHelper {
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/UMLBaseEditHelper.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/UMLBaseEditHelper.java
new file mode 100644
index 00000000000..f91a12227e5
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/helpers/UMLBaseEditHelper.java
@@ -0,0 +1,88 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.helpers;
+
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+
+/**
+ * @generated
+ */
+public class UMLBaseEditHelper extends AbstractEditHelper {
+
+ /**
+ * @generated
+ */
+ public static final String EDIT_POLICY_COMMAND = "edit policy command"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final String CONTEXT_ELEMENT_TYPE = "context element type"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ protected IEditHelperAdvice[] getEditHelperAdvice(IEditCommandRequest req) {
+ if (req.getParameter(CONTEXT_ELEMENT_TYPE) instanceof IElementType) {
+ return ElementTypeRegistry.getInstance().getEditHelperAdvice(
+ (IElementType) req.getParameter(CONTEXT_ELEMENT_TYPE));
+ }
+ return super.getEditHelperAdvice(req);
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getInsteadCommand(IEditCommandRequest req) {
+ ICommand epCommand = (ICommand) req.getParameter(EDIT_POLICY_COMMAND);
+ req.setParameter(EDIT_POLICY_COMMAND, null);
+ ICommand ehCommand = super.getInsteadCommand(req);
+ if (epCommand == null) {
+ return ehCommand;
+ }
+ if (ehCommand == null) {
+ return epCommand;
+ }
+ CompositeCommand command = new CompositeCommand(null);
+ command.add(epCommand);
+ command.add(ehCommand);
+ return command;
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getCreateCommand(CreateElementRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getCreateRelationshipCommand(
+ CreateRelationshipRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getDestroyElementCommand(DestroyElementRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getDestroyReferenceCommand(DestroyReferenceRequest req) {
+ return null;
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ComponentEditPart.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ComponentEditPart.java
new file mode 100644
index 00000000000..e224e1d8acb
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ComponentEditPart.java
@@ -0,0 +1,361 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.parts;
+
+import org.eclipse.draw2d.FlowLayout;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.Shape;
+import org.eclipse.draw2d.StackLayout;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.FlowLayoutEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.papyrus.diagram.common.helper.PreferenceInitializerForElementHelper;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.policies.ComponentItemSemanticEditPolicy;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.preferences.utils.GradientPreferenceConverter;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ComponentEditPart extends
+
+ShapeNodeEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2001;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ComponentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
+ new ComponentItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ // 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);
+ }
+
+ /**
+ * @generated
+ */
+ protected LayoutEditPolicy createLayoutEditPolicy() {
+
+ FlowLayoutEditPolicy lep = new FlowLayoutEditPolicy() {
+
+ protected Command createAddCommand(EditPart child, EditPart after) {
+ return null;
+ }
+
+ protected Command createMoveChildCommand(EditPart child,
+ EditPart after) {
+ return null;
+ }
+
+ protected Command getCreateCommand(CreateRequest request) {
+ return null;
+ }
+ };
+ return lep;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createNodeShape() {
+ return primaryShape = new ComponentFigure();
+ }
+
+ /**
+ * @generated
+ */
+ public ComponentFigure getPrimaryShape() {
+ return (ComponentFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ComponentNameEditPart) {
+ ((ComponentNameEditPart) childEditPart).setLabel(getPrimaryShape()
+ .getFigureComponentNameFigure());
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ComponentNameEditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ protected NodeFigure createNodePlate() {
+ String prefElementId = "Component";
+ IPreferenceStore store = UMLDiagramEditorPlugin.getInstance()
+ .getPreferenceStore();
+ String preferenceConstantWitdh = PreferenceInitializerForElementHelper
+ .getpreferenceKey(getNotationView(), prefElementId,
+ PreferenceConstantHelper.WIDTH);
+ String preferenceConstantHeight = PreferenceInitializerForElementHelper
+ .getpreferenceKey(getNotationView(), prefElementId,
+ PreferenceConstantHelper.HEIGHT);
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(
+ store.getInt(preferenceConstantWitdh),
+ store.getInt(preferenceConstantHeight));
+
+ return result;
+ }
+
+ /**
+ * 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.
+ *
+ * @generated
+ */
+ protected NodeFigure createNodeFigure() {
+ NodeFigure figure = createNodePlate();
+ figure.setLayoutManager(new StackLayout());
+ IFigure shape = createNodeShape();
+ figure.add(shape);
+ contentPane = setupContentPane(shape);
+ return figure;
+ }
+
+ /**
+ * Default implementation treats passed figure as content pane.
+ * Respects layout one may have set for generated figure.
+ * @param nodeShape instance of generated figure class
+ * @generated
+ */
+ protected IFigure setupContentPane(IFigure nodeShape) {
+ if (nodeShape.getLayoutManager() == null) {
+ ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
+ layout.setSpacing(5);
+ nodeShape.setLayoutManager(layout);
+ }
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+
+ /**
+ * @generated
+ */
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineWidth(int width) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineWidth(width);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineType(int style) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry
+ .getType(ComponentNameEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ public class ComponentFigure extends RectangleFigure {
+
+ /**
+ * @generated
+ */
+ private WrappingLabel fFigureComponentNameFigure;
+
+ /**
+ * @generated
+ */
+ public ComponentFigure() {
+
+ FlowLayout layoutThis = new FlowLayout();
+ layoutThis.setStretchMinorAxis(false);
+ layoutThis.setMinorAlignment(FlowLayout.ALIGN_LEFTTOP);
+
+ layoutThis.setMajorAlignment(FlowLayout.ALIGN_LEFTTOP);
+ layoutThis.setMajorSpacing(5);
+ layoutThis.setMinorSpacing(5);
+ layoutThis.setHorizontal(true);
+
+ this.setLayoutManager(layoutThis);
+
+ createContents();
+ }
+
+ /**
+ * @generated
+ */
+ private void createContents() {
+
+ fFigureComponentNameFigure = new WrappingLabel();
+ fFigureComponentNameFigure.setText("<...>");
+
+ this.add(fFigureComponentNameFigure);
+
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getFigureComponentNameFigure() {
+ return fFigureComponentNameFigure;
+ }
+
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public Object getPreferredValue(EStructuralFeature feature) {
+ IPreferenceStore preferenceStore = (IPreferenceStore) getDiagramPreferencesHint()
+ .getPreferenceStore();
+ Object result = null;
+
+ if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()
+ || feature == NotationPackage.eINSTANCE
+ .getFontStyle_FontColor()
+ || feature == NotationPackage.eINSTANCE
+ .getFillStyle_FillColor()) {
+ String prefColor = null;
+ if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) {
+ prefColor = PreferenceConstantHelper.getElementConstant(
+ "Component", PreferenceConstantHelper.COLOR_LINE);
+ } else if (feature == NotationPackage.eINSTANCE
+ .getFontStyle_FontColor()) {
+ prefColor = PreferenceConstantHelper.getElementConstant(
+ "Component", PreferenceConstantHelper.COLOR_FONT);
+ } else if (feature == NotationPackage.eINSTANCE
+ .getFillStyle_FillColor()) {
+ prefColor = PreferenceConstantHelper.getElementConstant(
+ "Component", PreferenceConstantHelper.COLOR_FILL);
+ }
+ result = FigureUtilities.RGBToInteger(PreferenceConverter.getColor(
+ (IPreferenceStore) preferenceStore, prefColor));
+ } else if (feature == NotationPackage.eINSTANCE
+ .getFillStyle_Transparency()
+ || feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) {
+ String prefGradient = PreferenceConstantHelper.getElementConstant(
+ "Component", PreferenceConstantHelper.COLOR_GRADIENT);
+ GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(
+ preferenceStore.getString(prefGradient));
+ if (feature == NotationPackage.eINSTANCE
+ .getFillStyle_Transparency()) {
+ result = new Integer(
+ gradientPreferenceConverter.getTransparency());
+ } else if (feature == NotationPackage.eINSTANCE
+ .getFillStyle_Gradient()) {
+ result = gradientPreferenceConverter.getGradientData();
+ }
+ }
+
+ if (result == null) {
+ result = getStructuralFeatureValue(feature);
+ }
+ return result;
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ComponentNameEditPart.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ComponentNameEditPart.java
new file mode 100644
index 00000000000..1a671f4c1d7
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ComponentNameEditPart.java
@@ -0,0 +1,868 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.diagram.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.diagram.common.util.DiagramEditPartsUtil;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLElementTypes;
+import org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLParserProvider;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.umlutils.ui.VisualInformationPapyrusConstant;
+import org.eclipse.papyrus.umlutils.ui.helper.NameLabelIconHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @generated
+ */
+public class ComponentNameEditPart extends CompartmentEditPart implements
+ ITextAwareEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5001;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ComponentNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
+ new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE,
+ new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE,
+ new ModelEditPart.NodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(WrappingLabel figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+
+ List<View> views = DiagramEditPartsUtil.findViews(parserElement,
+ getViewer());
+ for (View view : views) {
+ if (NameLabelIconHelper.showLabelIcon(view)) {
+ return UMLElementTypes.getImage(parserElement.eClass());
+ }
+ }
+ return null;
+
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(
+ new EObjectAdapter(parserElement),
+ getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(
+ new EObjectAdapter(getParserElement()),
+ getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return getParser() != null;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain()
+ .runExclusive(new RunnableWithResult.Impl() {
+
+ public void run() {
+ setResult(parser.isValidEditString(
+ new EObjectAdapter(element),
+ (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null
+ : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(
+ new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = UMLParserProvider
+ .getParser(
+ UMLElementTypes.Component_2001,
+ getParserElement(),
+ UMLVisualIDRegistry
+ .getType(org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager
+ .getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation
+ .getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+
+ final Request theRequest = request;
+
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration)
+ .createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ } else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration)
+ .createDialog(
+ PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getShell(),
+ resolveSemanticElement(),
+ configuration
+ .getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow()
+ .getShell(), resolveSemanticElement(),
+ ((IDirectEditorConfiguration) configuration)
+ .getTextToEdit(resolveSemanticElement()),
+ (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain,
+ "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(
+ resolveSemanticElement(),
+ ((ILabelEditorDialog) finalDialog)
+ .getValue());
+
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest
+ .getExtendedData()
+ .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest
+ .getExtendedData()
+ .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest)
+ && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style
+ .isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(),
+ style.getFontHeight(), (style.isBold() ? SWT.BOLD
+ : SWT.NORMAL)
+ | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ if (getParser() instanceof ISemanticParser) {
+ EObject element = resolveSemanticElement();
+ parserElements = ((ISemanticParser) getParser())
+ .getSemanticElementsBeingParsed(element);
+ for (int i = 0; i < parserElements.size(); i++) {
+ addListenerFilter(
+ "SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$
+ }
+ } else {
+ super.addSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil
+ .hasSpecificEditorConfiguration(resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator
+ .getDefault()
+ .getPreferenceStore()
+ .getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT
+ + resolveSemanticElement().eClass()
+ .getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(
+ languagePreferred, resolveSemanticElement().eClass()
+ .getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(
+ IDirectEditorsIds.UML_LANGUAGE,
+ resolveSemanticElement().eClass()
+ .getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator
+ .getDefault()
+ .getPreferenceStore()
+ .getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT
+ + resolveSemanticElement().eClass()
+ .getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")
+ && languagePreferred != configuration.getLanguage()) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(
+ languagePreferred, resolveSemanticElement().eClass()
+ .getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR
+ .equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ * @param theRequest the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest
+ .getExtendedData()
+ .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest
+ .getExtendedData()
+ .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest)
+ && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(
+ feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough()
+ .equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(
+ feature)
+ || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(
+ feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold()
+ .equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(
+ feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null
+ && getParser().isAffectingEvent(event,
+ getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+
+ if (event.getNewValue() instanceof EAnnotation
+ && VisualInformationPapyrusConstant.DISPLAY_NAMELABELICON
+ .equals(((EAnnotation) event.getNewValue()).getSource())) {
+ refreshLabel();
+ }
+
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent()
+ .getModel())); //$NON-NLS-1$
+
+ }
+
+ /**
+ * @generated
+ */
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ModelEditPart.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ModelEditPart.java
new file mode 100644
index 00000000000..0b3c169dc6e
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/ModelEditPart.java
@@ -0,0 +1,171 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IClippingStrategy;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.diagram.common.providers.ViewInfo;
+import org.eclipse.papyrus.diagram.common.util.MDTUtil;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.policies.ModelItemSemanticEditPolicy;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+
+/**
+ * @generated
+ */
+public class ModelEditPart extends DiagramEditPart {
+
+ /**
+ * @generated
+ */
+ public final static String MODEL_ID = "PapyrusNewDiagram"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1000;
+
+ /**
+ * @generated
+ */
+ public ModelEditPart(View view) {
+ super(view);
+
+ getFigure().setClippingStrategy(new IClippingStrategy() {
+
+ public Rectangle[] getClip(IFigure childFigure) {
+ // very inefficient, since it implies several tree traversals. Bit handles modifications of the tree structure
+ // It's a workaround instead of the better solution to fix BorderedNodeFigure (overload and let it return
+ // getExtendedBounds)
+ // See bug 313985 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=313985) for more details
+ applyClippingStrategy(childFigure);
+ if (childFigure instanceof BorderedNodeFigure) {
+ return new Rectangle[] { ((BorderedNodeFigure) childFigure)
+ .getExtendedBounds() };
+
+ } else {
+ return new Rectangle[] { childFigure.getBounds() };
+ }
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ public void applyClippingStrategy(IFigure fig) {
+ boolean hasBorderedNodeChild = false;
+ for (Object child : fig.getChildren()) {
+ if (child instanceof IFigure) {
+ applyClippingStrategy((IFigure) child);
+ if (child instanceof BorderedNodeFigure) {
+ hasBorderedNodeChild = true;
+ }
+ }
+ }
+ if (hasBorderedNodeChild && (fig.getClippingStrategy() == null)) {
+ fig.setClippingStrategy(new IClippingStrategy() {
+
+ public Rectangle[] getClip(IFigure childFigure) {
+ if (childFigure instanceof BorderedNodeFigure) {
+ return new Rectangle[] { ((BorderedNodeFigure) childFigure)
+ .getExtendedBounds() };
+ } else {
+ return new Rectangle[] { childFigure.getBounds() };
+ }
+ }
+ });
+ }
+
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE,
+ new DuplicatePasteEditPolicy());
+
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
+ new ModelItemSemanticEditPolicy());
+
+ //in Papyrus diagrams are not strongly synchronised
+ //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.diagram.newdiagram.edit.policies.ModelCanonicalEditPolicy());
+
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE);
+ }
+
+ /**
+ * @generated
+ */
+ /*package-local*/static class NodeLabelDragPolicy extends
+ NonResizableEditPolicy {
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List createSelectionHandles() {
+ MoveHandle h = new MoveHandle((GraphicalEditPart) getHost());
+ h.setBorder(null);
+ return Collections.singletonList(h);
+ }
+
+ /**
+ * @generated
+ */
+ public Command getCommand(Request request) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean understandsRequest(Request request) {
+ return false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+
+ super.handleNotificationEvent(event);
+ if (event.getNotifier() instanceof EAnnotation) {
+ EAnnotation eAnnotation = (EAnnotation) event.getNotifier();
+ if (eAnnotation.getSource() != null
+ && eAnnotation.getSource().equals(
+ MDTUtil.FilterViewAndLabelsSource)) {
+ //modification form MOSKitt approach, canonical policies are not called
+ MDTUtil.filterDiagramViews(this.getDiagramView());
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public Object getAdapter(Class adapter) {
+
+ if (adapter != null && adapter.equals(ViewInfo.class)) {
+ return UMLVisualIDRegistry.getDiagramViewInfo();
+ }
+ return super.getAdapter(adapter);
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/UMLEditPartFactory.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/UMLEditPartFactory.java
new file mode 100644
index 00000000000..9c544e6a6b4
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/parts/UMLEditPartFactory.java
@@ -0,0 +1,203 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.parts;
+
+import org.eclipse.draw2d.FigureUtilities;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+import org.eclipse.gef.tools.CellEditorLocator;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.papyrus.diagram.common.figure.node.IMultilineEditableFigure;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @generated
+ */
+public class UMLEditPartFactory implements EditPartFactory {
+
+ /**
+ * @generated
+ */
+ public EditPart createEditPart(EditPart context, Object model) {
+ if (model instanceof View) {
+ View view = (View) model;
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+
+ case ModelEditPart.VISUAL_ID:
+ return new ModelEditPart(view);
+
+ case ComponentEditPart.VISUAL_ID:
+ return new ComponentEditPart(view);
+
+ case ComponentNameEditPart.VISUAL_ID:
+ return new ComponentNameEditPart(view);
+ }
+ }
+ return createUnrecognizedEditPart(context, model);
+ }
+
+ /**
+ * @generated
+ */
+ private EditPart createUnrecognizedEditPart(EditPart context, Object model) {
+ // Handle creation of unrecognized child node EditParts here
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public static CellEditorLocator getTextCellEditorLocator(
+ ITextAwareEditPart source) {
+ if (source.getFigure() instanceof IMultilineEditableFigure)
+ return new MultilineCellEditorLocator(
+ (IMultilineEditableFigure) source.getFigure());
+ else if (source.getFigure() instanceof WrappingLabel)
+ return new TextCellEditorLocator((WrappingLabel) source.getFigure());
+ else {
+ return new LabelCellEditorLocator((Label) source.getFigure());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ static private class MultilineCellEditorLocator implements
+ CellEditorLocator {
+
+ /**
+ * @generated
+ */
+ private IMultilineEditableFigure multilineEditableFigure;
+
+ /**
+ * @generated
+ */
+ public MultilineCellEditorLocator(IMultilineEditableFigure figure) {
+ this.multilineEditableFigure = figure;
+ }
+
+ /**
+ * @generated
+ */
+ public IMultilineEditableFigure getMultilineEditableFigure() {
+ return multilineEditableFigure;
+ }
+
+ /**
+ * @generated
+ */
+ public void relocate(CellEditor celleditor) {
+ Text text = (Text) celleditor.getControl();
+ Rectangle rect = getMultilineEditableFigure().getBounds().getCopy();
+ rect.x = getMultilineEditableFigure().getEditionLocation().x;
+ rect.y = getMultilineEditableFigure().getEditionLocation().y;
+ getMultilineEditableFigure().translateToAbsolute(rect);
+ if (getMultilineEditableFigure().getText().length() > 0) {
+ rect.setSize(new Dimension(text.computeSize(rect.width,
+ SWT.DEFAULT)));
+ }
+ if (!rect.equals(new Rectangle(text.getBounds()))) {
+ text.setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ static private class TextCellEditorLocator implements CellEditorLocator {
+
+ /**
+ * @generated
+ */
+ private WrappingLabel wrapLabel;
+
+ /**
+ * @generated
+ */
+ public TextCellEditorLocator(WrappingLabel wrapLabel) {
+ this.wrapLabel = wrapLabel;
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getWrapLabel() {
+ return wrapLabel;
+ }
+
+ /**
+ * @generated
+ */
+ public void relocate(CellEditor celleditor) {
+ Text text = (Text) celleditor.getControl();
+ Rectangle rect = getWrapLabel().getTextBounds().getCopy();
+ getWrapLabel().translateToAbsolute(rect);
+ if (!text.getFont().isDisposed()) {
+ if (getWrapLabel().isTextWrapOn()
+ && getWrapLabel().getText().length() > 0) {
+ rect.setSize(new Dimension(text.computeSize(rect.width,
+ SWT.DEFAULT)));
+ } else {
+ int avr = FigureUtilities.getFontMetrics(text.getFont())
+ .getAverageCharWidth();
+ rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT,
+ SWT.DEFAULT)).expand(avr * 2, 0));
+ }
+ }
+ if (!rect.equals(new Rectangle(text.getBounds()))) {
+ text.setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private static class LabelCellEditorLocator implements CellEditorLocator {
+
+ /**
+ * @generated
+ */
+ private Label label;
+
+ /**
+ * @generated
+ */
+ public LabelCellEditorLocator(Label label) {
+ this.label = label;
+ }
+
+ /**
+ * @generated
+ */
+ public Label getLabel() {
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ public void relocate(CellEditor celleditor) {
+ Text text = (Text) celleditor.getControl();
+ Rectangle rect = getLabel().getTextBounds().getCopy();
+ getLabel().translateToAbsolute(rect);
+ if (!text.getFont().isDisposed()) {
+ int avr = FigureUtilities.getFontMetrics(text.getFont())
+ .getAverageCharWidth();
+ rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT,
+ SWT.DEFAULT)).expand(avr * 2, 0));
+ }
+ if (!rect.equals(new Rectangle(text.getBounds()))) {
+ text.setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+ }
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ComponentItemSemanticEditPolicy.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ComponentItemSemanticEditPolicy.java
new file mode 100644
index 00000000000..a3d307e0131
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ComponentItemSemanticEditPolicy.java
@@ -0,0 +1,55 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.diagram.common.command.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ComponentItemSemanticEditPolicy extends
+ UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ComponentItemSemanticEditPolicy() {
+ super(UMLElementTypes.Component_2001);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
+ getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+
+ EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
+ if (annotation == null) {
+ // there are indirectly referenced children, need extra commands: false
+ addDestroyShortcutsCommand(cmd, view);
+ // delete host element
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(
+ getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(
+ getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelCanonicalEditPolicy.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelCanonicalEditPolicy.java
new file mode 100644
index 00000000000..b0d85c84f3e
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelCanonicalEditPolicy.java
@@ -0,0 +1,158 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilityCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramUpdater;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLNodeDescriptor;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ModelCanonicalEditPolicy extends CanonicalEditPolicy {
+
+ /**
+ * @generated
+ */
+ protected EStructuralFeature getFeatureToSynchronize() {
+ return UMLPackage.eINSTANCE.getPackage_PackagedElement();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getSemanticChildrenList() {
+ View viewObject = (View) getHost().getModel();
+ LinkedList<EObject> result = new LinkedList<EObject>();
+ List<UMLNodeDescriptor> childDescriptors = UMLDiagramUpdater
+ .getModel_1000SemanticChildren(viewObject);
+ for (UMLNodeDescriptor d : childDescriptors) {
+ result.add(d.getModelElement());
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isOrphaned(Collection<EObject> semanticChildren,
+ final View view) {
+ return isMyDiagramElement(view)
+ && !semanticChildren.contains(view.getElement());
+ }
+
+ /**
+ * @generated
+ */
+ private boolean isMyDiagramElement(View view) {
+ return ComponentEditPart.VISUAL_ID == UMLVisualIDRegistry
+ .getVisualID(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshSemantic() {
+ if (resolveSemanticElement() == null) {
+ return;
+ }
+ LinkedList<IAdaptable> createdViews = new LinkedList<IAdaptable>();
+ List<UMLNodeDescriptor> childDescriptors = UMLDiagramUpdater
+ .getModel_1000SemanticChildren((View) getHost().getModel());
+ LinkedList<View> orphaned = new LinkedList<View>();
+ // we care to check only views we recognize as ours
+ LinkedList<View> knownViewChildren = new LinkedList<View>();
+ for (View v : getViewChildren()) {
+ if (isMyDiagramElement(v)) {
+ knownViewChildren.add(v);
+ }
+ }
+ // alternative to #cleanCanonicalSemanticChildren(getViewChildren(), semanticChildren)
+ //
+ // iteration happens over list of desired semantic elements, trying to find best matching View, while original CEP
+ // iterates views, potentially losing view (size/bounds) information - i.e. if there are few views to reference same EObject, only last one
+ // to answer isOrphaned == true will be used for the domain element representation, see #cleanCanonicalSemanticChildren()
+ for (Iterator<UMLNodeDescriptor> descriptorsIterator = childDescriptors
+ .iterator(); descriptorsIterator.hasNext();) {
+ UMLNodeDescriptor next = descriptorsIterator.next();
+ String hint = UMLVisualIDRegistry.getType(next.getVisualID());
+ LinkedList<View> perfectMatch = new LinkedList<View>(); // both semanticElement and hint match that of NodeDescriptor
+ for (View childView : getViewChildren()) {
+ EObject semanticElement = childView.getElement();
+ if (next.getModelElement().equals(semanticElement)) {
+ if (hint.equals(childView.getType())) {
+ perfectMatch.add(childView);
+ // actually, can stop iteration over view children here, but
+ // may want to use not the first view but last one as a 'real' match (the way original CEP does
+ // with its trick with viewToSemanticMap inside #cleanCanonicalSemanticChildren
+ }
+ }
+ }
+ if (perfectMatch.size() > 0) {
+ descriptorsIterator.remove(); // precise match found no need to create anything for the NodeDescriptor
+ // use only one view (first or last?), keep rest as orphaned for further consideration
+ knownViewChildren.remove(perfectMatch.getFirst());
+ }
+ }
+ // those left in knownViewChildren are subject to removal - they are our diagram elements we didn't find match to,
+ // or those we have potential matches to, and thus need to be recreated, preserving size/location information.
+ orphaned.addAll(knownViewChildren);
+ //
+ ArrayList<CreateViewRequest.ViewDescriptor> viewDescriptors = new ArrayList<CreateViewRequest.ViewDescriptor>(
+ childDescriptors.size());
+ for (UMLNodeDescriptor next : childDescriptors) {
+ String hint = UMLVisualIDRegistry.getType(next.getVisualID());
+ IAdaptable elementAdapter = new CanonicalElementAdapter(
+ next.getModelElement(), hint);
+ CreateViewRequest.ViewDescriptor descriptor = new CreateViewRequest.ViewDescriptor(
+ elementAdapter, Node.class, hint, ViewUtil.APPEND, false,
+ host().getDiagramPreferencesHint());
+ viewDescriptors.add(descriptor);
+ }
+
+ boolean changed = deleteViews(orphaned.iterator());
+ //
+ CreateViewRequest request = getCreateViewRequest(viewDescriptors);
+ Command cmd = getCreateViewCommand(request);
+ if (cmd != null && cmd.canExecute()) {
+ SetViewMutabilityCommand.makeMutable(
+ new EObjectAdapter(host().getNotationView())).execute();
+ executeCommand(cmd);
+ @SuppressWarnings("unchecked")
+ List<IAdaptable> nl = (List<IAdaptable>) request.getNewObject();
+ createdViews.addAll(nl);
+ }
+ if (changed || createdViews.size() > 0) {
+ postProcessRefreshSemantic(createdViews);
+ }
+
+ if (createdViews.size() > 1) {
+ // perform a layout of the container
+ DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host()
+ .getEditingDomain(), createdViews, host());
+ executeCommand(new ICommandProxy(layoutCmd));
+ }
+
+ makeViewsImmutable(createdViews);
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelItemSemanticEditPolicy.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelItemSemanticEditPolicy.java
new file mode 100644
index 00000000000..7f7d75f0020
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelItemSemanticEditPolicy.java
@@ -0,0 +1,73 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.policies;
+
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.papyrus.diagram.common.commands.DuplicateNamedElementCommand;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.commands.ComponentCreateCommand;
+import org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ModelItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ModelItemSemanticEditPolicy() {
+ super(UMLElementTypes.Model_1000);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateCommand(CreateElementRequest req) {
+ if (UMLElementTypes.Component_2001 == req.getElementType()) {
+ return getGEFWrapper(new ComponentCreateCommand(req));
+ }
+ return super.getCreateCommand(req);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDuplicateCommand(DuplicateElementsRequest req) {
+ TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
+ .getEditingDomain();
+ Diagram currentDiagram = null;
+ if (getHost() instanceof IGraphicalEditPart) {
+ currentDiagram = ((IGraphicalEditPart) getHost()).getNotationView()
+ .getDiagram();
+ }
+ return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req,
+ currentDiagram));
+ }
+
+ /**
+ * @generated
+ */
+ private static class DuplicateAnythingCommand extends
+ DuplicateNamedElementCommand {
+ /**
+ * @generated
+ */
+ private Diagram diagram;
+
+ /**
+ * @generated
+ */
+ public DuplicateAnythingCommand(
+ TransactionalEditingDomain editingDomain,
+ DuplicateElementsRequest req, Diagram currentDiagram) {
+ super(editingDomain, req.getLabel(), req
+ .getElementsToBeDuplicated(), req
+ .getAllDuplicatedElementsMap(), currentDiagram);
+ this.diagram = currentDiagram;
+ }
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLBaseItemSemanticEditPolicy.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLBaseItemSemanticEditPolicy.java
new file mode 100644
index 00000000000..82e5a0c17ea
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLBaseItemSemanticEditPolicy.java
@@ -0,0 +1,306 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.policies;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ReconnectRequest;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.helpers.UMLBaseEditHelper;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy {
+ /**
+ * Extended request data key to hold editpart visual id.
+ * @generated
+ */
+ public static final String VISUAL_ID_KEY = "visual_id"; //$NON-NLS-1$
+ /**
+ * Extended request data key to hold the edge view during a reconnect request.
+ * @generated
+ */
+ public static final String GRAPHICAL_RECONNECTED_EDGE = "graphical_edge"; //$NON-NLS-1$
+ /**
+ * @generated
+ */
+ private final IElementType myElementType;
+
+ /**
+ * @generated
+ */
+ protected UMLBaseItemSemanticEditPolicy(IElementType elementType) {
+ myElementType = elementType;
+ }
+
+ /**
+ * Extended request data key to hold editpart visual id.
+ * Add visual id of edited editpart to extended data of the request
+ * so command switch can decide what kind of diagram element is being edited.
+ * It is done in those cases when it's not possible to deduce diagram
+ * element kind from domain element.
+ * Add the reoriented view to the request extended data so that the view
+ * currently edited can be distinguished from other views of the same element
+ * and these latter possibly removed if they become inconsistent after reconnect
+ *
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ public Command getCommand(Request request) {
+ if (request instanceof ReconnectRequest) {
+ Object view = ((ReconnectRequest) request).getConnectionEditPart()
+ .getModel();
+ if (view instanceof View) {
+ Integer id = new Integer(
+ UMLVisualIDRegistry.getVisualID((View) view));
+ request.getExtendedData().put(VISUAL_ID_KEY, id);
+ request.getExtendedData().put(GRAPHICAL_RECONNECTED_EDGE,
+ (View) view);
+ }
+ }
+ return super.getCommand(request);
+ }
+
+ /**
+ * Returns visual id from request parameters.
+ * @generated
+ */
+ protected int getVisualID(IEditCommandRequest request) {
+ Object id = request.getParameter(VISUAL_ID_KEY);
+ return id instanceof Integer ? ((Integer) id).intValue() : -1;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getSemanticCommand(IEditCommandRequest request) {
+ IEditCommandRequest completedRequest = completeRequest(request);
+ Command semanticCommand = getSemanticCommandSwitch(completedRequest);
+ semanticCommand = getEditHelperCommand(completedRequest,
+ semanticCommand);
+ if (completedRequest instanceof DestroyRequest) {
+ DestroyRequest destroyRequest = (DestroyRequest) completedRequest;
+ return shouldProceed(destroyRequest) ? addDeleteViewCommand(
+ semanticCommand, destroyRequest) : null;
+ }
+ return semanticCommand;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command addDeleteViewCommand(Command mainCommand,
+ DestroyRequest completedRequest) {
+ Command deleteViewCommand = getGEFWrapper(new DeleteCommand(
+ getEditingDomain(), (View) getHost().getModel()));
+ return mainCommand == null ? deleteViewCommand : mainCommand
+ .chain(deleteViewCommand);
+ }
+
+ /**
+ * @generated
+ */
+ private Command getEditHelperCommand(IEditCommandRequest request,
+ Command editPolicyCommand) {
+ if (editPolicyCommand != null) {
+ ICommand command = editPolicyCommand instanceof ICommandProxy ? ((ICommandProxy) editPolicyCommand)
+ .getICommand() : new CommandProxy(editPolicyCommand);
+ request.setParameter(UMLBaseEditHelper.EDIT_POLICY_COMMAND, command);
+ }
+ IElementType requestContextElementType = getContextElementType(request);
+ request.setParameter(UMLBaseEditHelper.CONTEXT_ELEMENT_TYPE,
+ requestContextElementType);
+ ICommand command = requestContextElementType.getEditCommand(request);
+ request.setParameter(UMLBaseEditHelper.EDIT_POLICY_COMMAND, null);
+ request.setParameter(UMLBaseEditHelper.CONTEXT_ELEMENT_TYPE, null);
+ if (command != null) {
+ if (!(command instanceof CompositeTransactionalCommand)) {
+ command = new CompositeTransactionalCommand(getEditingDomain(),
+ command.getLabel()).compose(command);
+ }
+ return new ICommandProxy(command);
+ }
+ return editPolicyCommand;
+ }
+
+ /**
+ * @generated
+ */
+ protected IElementType getContextElementType(IEditCommandRequest request) {
+ IElementType requestContextElementType = UMLElementTypes
+ .getElementType(getVisualID(request));
+ return requestContextElementType != null ? requestContextElementType
+ : myElementType;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getSemanticCommandSwitch(IEditCommandRequest req) {
+ if (req instanceof CreateRelationshipRequest) {
+ return getCreateRelationshipCommand((CreateRelationshipRequest) req);
+ } else if (req instanceof CreateElementRequest) {
+ return getCreateCommand((CreateElementRequest) req);
+ } else if (req instanceof ConfigureRequest) {
+ return getConfigureCommand((ConfigureRequest) req);
+ } else if (req instanceof DestroyElementRequest) {
+ return getDestroyElementCommand((DestroyElementRequest) req);
+ } else if (req instanceof DestroyReferenceRequest) {
+ return getDestroyReferenceCommand((DestroyReferenceRequest) req);
+ } else if (req instanceof DuplicateElementsRequest) {
+ return getDuplicateCommand((DuplicateElementsRequest) req);
+ } else if (req instanceof GetEditContextRequest) {
+ return getEditContextCommand((GetEditContextRequest) req);
+ } else if (req instanceof MoveRequest) {
+ return getMoveCommand((MoveRequest) req);
+ } else if (req instanceof ReorientReferenceRelationshipRequest) {
+ return getReorientReferenceRelationshipCommand((ReorientReferenceRelationshipRequest) req);
+ } else if (req instanceof ReorientRelationshipRequest) {
+ return getReorientRelationshipCommand((ReorientRelationshipRequest) req);
+ } else if (req instanceof SetRequest) {
+ return getSetCommand((SetRequest) req);
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getConfigureCommand(ConfigureRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateCommand(CreateElementRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getSetCommand(SetRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getEditContextCommand(GetEditContextRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDuplicateCommand(DuplicateElementsRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getMoveCommand(MoveRequest req) {
+
+ return getGEFWrapper(new MoveElementsCommand(req));
+
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getReorientReferenceRelationshipCommand(
+ ReorientReferenceRelationshipRequest req) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getReorientRelationshipCommand(
+ ReorientRelationshipRequest req) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ * @generated
+ */
+ protected final Command getGEFWrapper(ICommand cmd) {
+ return new ICommandProxy(cmd);
+ }
+
+ /**
+ * Returns editing domain from the host edit part.
+ * @generated
+ */
+ protected TransactionalEditingDomain getEditingDomain() {
+ return ((IGraphicalEditPart) getHost()).getEditingDomain();
+ }
+
+ /**
+ * Clean all shortcuts to the host element from the same diagram
+ * @generated
+ */
+ protected void addDestroyShortcutsCommand(ICompositeCommand cmd, View view) {
+ assert view.getEAnnotation("Shortcut") == null; //$NON-NLS-1$
+ for (Iterator it = view.getDiagram().getChildren().iterator(); it
+ .hasNext();) {
+ View nextView = (View) it.next();
+ if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { //$NON-NLS-1$
+ continue;
+ }
+ cmd.add(new DeleteCommand(getEditingDomain(), nextView));
+ }
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLTextNonResizableEditPolicy.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLTextNonResizableEditPolicy.java
new file mode 100644
index 00000000000..8257f356428
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLTextNonResizableEditPolicy.java
@@ -0,0 +1,225 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.policies;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.FigureListener;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableEditPolicyEx;
+import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+
+/**
+ * @generated
+ */
+public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx {
+
+ /**
+ * @generated
+ */
+ private IFigure selectionFeedbackFigure;
+
+ /**
+ * @generated
+ */
+ private IFigure focusFeedbackFigure;
+
+ /**
+ * @generated
+ */
+ private FigureListener hostPositionListener;
+
+ /**
+ * @generated
+ */
+ protected void showPrimarySelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(true);
+ ((WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ showSelection();
+ showFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void showSelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(true);
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ hideSelection();
+ addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure());
+ getHostFigure().addFigureListener(getHostPositionListener());
+ refreshSelectionFeedback();
+ hideFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void hideSelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(false);
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (selectionFeedbackFigure != null) {
+ removeFeedback(selectionFeedbackFigure);
+ getHostFigure().removeFigureListener(getHostPositionListener());
+ selectionFeedbackFigure = null;
+ }
+ hideFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void showFocus() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ hideFocus();
+ addFeedback(focusFeedbackFigure = createFocusFeedbackFigure());
+ refreshFocusFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void hideFocus() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (focusFeedbackFigure != null) {
+ removeFeedback(focusFeedbackFigure);
+ focusFeedbackFigure = null;
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Rectangle getFeedbackBounds() {
+ Rectangle bounds;
+ if (getHostFigure() instanceof Label) {
+ bounds = ((Label) getHostFigure()).getTextBounds();
+ bounds.intersect(getHostFigure().getBounds());
+ } else {
+ bounds = getHostFigure().getBounds().getCopy();
+ }
+ getHostFigure().getParent().translateToAbsolute(bounds);
+ getFeedbackLayer().translateToRelative(bounds);
+ return bounds;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createSelectionFeedbackFigure() {
+ if (getHostFigure() instanceof Label) {
+ Label feedbackFigure = new Label();
+ feedbackFigure.setOpaque(true);
+ feedbackFigure
+ .setBackgroundColor(ColorConstants.menuBackgroundSelected);
+ feedbackFigure
+ .setForegroundColor(ColorConstants.menuForegroundSelected);
+ return feedbackFigure;
+ } else {
+ RectangleFigure feedbackFigure = new RectangleFigure();
+ feedbackFigure.setFill(false);
+ return feedbackFigure;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFocusFeedbackFigure() {
+ return new Figure() {
+
+ protected void paintFigure(Graphics graphics) {
+ graphics.drawFocus(getBounds().getResized(-1, -1));
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ protected void updateLabel(Label target) {
+ Label source = (Label) getHostFigure();
+ target.setText(source.getText());
+ target.setTextAlignment(source.getTextAlignment());
+ target.setFont(source.getFont());
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshSelectionFeedback() {
+ if (selectionFeedbackFigure != null) {
+ if (selectionFeedbackFigure instanceof Label) {
+ updateLabel((Label) selectionFeedbackFigure);
+ selectionFeedbackFigure.setBounds(getFeedbackBounds());
+ } else {
+ selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5,
+ 5));
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFocusFeedback() {
+ if (focusFeedbackFigure != null) {
+ focusFeedbackFigure.setBounds(getFeedbackBounds());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void refreshFeedback() {
+ refreshSelectionFeedback();
+ refreshFocusFeedback();
+ }
+
+ /**
+ * @generated
+ */
+ private FigureListener getHostPositionListener() {
+ if (hostPositionListener == null) {
+ hostPositionListener = new FigureListener() {
+ public void figureMoved(IFigure source) {
+ refreshFeedback();
+ }
+ };
+ }
+ return hostPositionListener;
+ }
+
+ /**
+ * @generated
+ */
+ protected List createSelectionHandles() {
+ MoveHandle moveHandle = new MoveHandle((GraphicalEditPart) getHost());
+ moveHandle.setBorder(null);
+ moveHandle.setDragTracker(new DragEditPartsTrackerEx(getHost()));
+ return Collections.singletonList(moveHandle);
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLTextSelectionEditPolicy.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLTextSelectionEditPolicy.java
new file mode 100644
index 00000000000..4072e532af9
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/UMLTextSelectionEditPolicy.java
@@ -0,0 +1,209 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.policies;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.FigureListener;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.editpolicies.SelectionEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+
+/**
+ * @generated
+ */
+public class UMLTextSelectionEditPolicy extends SelectionEditPolicy {
+
+ /**
+ * @generated
+ */
+ private IFigure selectionFeedbackFigure;
+
+ /**
+ * @generated
+ */
+ private IFigure focusFeedbackFigure;
+
+ /**
+ * @generated
+ */
+ private FigureListener hostPositionListener;
+
+ /**
+ * @generated
+ */
+ protected void showPrimarySelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(true);
+ ((WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ showSelection();
+ showFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void showSelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(true);
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ hideSelection();
+ addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure());
+ getHostFigure().addFigureListener(getHostPositionListener());
+ refreshSelectionFeedback();
+ hideFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void hideSelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(false);
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (selectionFeedbackFigure != null) {
+ removeFeedback(selectionFeedbackFigure);
+ getHostFigure().removeFigureListener(getHostPositionListener());
+ selectionFeedbackFigure = null;
+ }
+ hideFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void showFocus() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ hideFocus();
+ addFeedback(focusFeedbackFigure = createFocusFeedbackFigure());
+ refreshFocusFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void hideFocus() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (focusFeedbackFigure != null) {
+ removeFeedback(focusFeedbackFigure);
+ focusFeedbackFigure = null;
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Rectangle getFeedbackBounds() {
+ Rectangle bounds;
+ if (getHostFigure() instanceof Label) {
+ bounds = ((Label) getHostFigure()).getTextBounds();
+ bounds.intersect(getHostFigure().getBounds());
+ } else {
+ bounds = getHostFigure().getBounds().getCopy();
+ }
+ getHostFigure().getParent().translateToAbsolute(bounds);
+ getFeedbackLayer().translateToRelative(bounds);
+ return bounds;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createSelectionFeedbackFigure() {
+ if (getHostFigure() instanceof Label) {
+ Label feedbackFigure = new Label();
+ feedbackFigure.setOpaque(true);
+ feedbackFigure
+ .setBackgroundColor(ColorConstants.menuBackgroundSelected);
+ feedbackFigure
+ .setForegroundColor(ColorConstants.menuForegroundSelected);
+ return feedbackFigure;
+ } else {
+ RectangleFigure feedbackFigure = new RectangleFigure();
+ feedbackFigure.setFill(false);
+ return feedbackFigure;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFocusFeedbackFigure() {
+ return new Figure() {
+
+ protected void paintFigure(Graphics graphics) {
+ graphics.drawFocus(getBounds().getResized(-1, -1));
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ protected void updateLabel(Label target) {
+ Label source = (Label) getHostFigure();
+ target.setText(source.getText());
+ target.setTextAlignment(source.getTextAlignment());
+ target.setFont(source.getFont());
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshSelectionFeedback() {
+ if (selectionFeedbackFigure != null) {
+ if (selectionFeedbackFigure instanceof Label) {
+ updateLabel((Label) selectionFeedbackFigure);
+ selectionFeedbackFigure.setBounds(getFeedbackBounds());
+ } else {
+ selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5,
+ 5));
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFocusFeedback() {
+ if (focusFeedbackFigure != null) {
+ focusFeedbackFigure.setBounds(getFeedbackBounds());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void refreshFeedback() {
+ refreshSelectionFeedback();
+ refreshFocusFeedback();
+ }
+
+ /**
+ * @generated
+ */
+ private FigureListener getHostPositionListener() {
+ if (hostPositionListener == null) {
+ hostPositionListener = new FigureListener() {
+ public void figureMoved(IFigure source) {
+ refreshFeedback();
+ }
+ };
+ }
+ return hostPositionListener;
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLAbstractNavigatorItem.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLAbstractNavigatorItem.java
new file mode 100644
index 00000000000..89fb8953e66
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLAbstractNavigatorItem.java
@@ -0,0 +1,61 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.navigator;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+
+/**
+ * @generated
+ */
+public abstract class UMLAbstractNavigatorItem extends PlatformObject {
+
+ /**
+ * @generated
+ */
+ static {
+ final Class[] supportedTypes = new Class[] { ITabbedPropertySheetPageContributor.class };
+ final ITabbedPropertySheetPageContributor propertySheetPageContributor = new ITabbedPropertySheetPageContributor() {
+ public String getContributorId() {
+ return "org.eclipse.uml2.uml.diagram"; //$NON-NLS-1$
+ }
+ };
+ Platform.getAdapterManager().registerAdapters(
+ new IAdapterFactory() {
+
+ public Object getAdapter(Object adaptableObject,
+ Class adapterType) {
+ if (adaptableObject instanceof org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLAbstractNavigatorItem
+ && adapterType == ITabbedPropertySheetPageContributor.class) {
+ return propertySheetPageContributor;
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return supportedTypes;
+ }
+ },
+ org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLAbstractNavigatorItem.class);
+ }
+
+ /**
+ * @generated
+ */
+ private Object myParent;
+
+ /**
+ * @generated
+ */
+ protected UMLAbstractNavigatorItem(Object parent) {
+ myParent = parent;
+ }
+
+ /**
+ * @generated
+ */
+ public Object getParent() {
+ return myParent;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorContentProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorContentProvider.java
new file mode 100644
index 00000000000..c00743a5713
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorContentProvider.java
@@ -0,0 +1,230 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.navigator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonContentProvider;
+
+/**
+ * @generated
+ */
+public class UMLDomainNavigatorContentProvider implements
+ ICommonContentProvider {
+
+ /**
+ * @generated
+ */
+ private AdapterFactoryContentProvider myAdapterFctoryContentProvier;
+
+ /**
+ * @generated
+ */
+ private static final Object[] EMPTY_ARRAY = new Object[0];
+ /**
+ * @generated
+ */
+ private Viewer myViewer;
+ /**
+ * @generated
+ */
+ private AdapterFactoryEditingDomain myEditingDomain;
+ /**
+ * @generated
+ */
+ private WorkspaceSynchronizer myWorkspaceSynchronizer;
+ /**
+ * @generated
+ */
+ private Runnable myViewerRefreshRunnable;
+
+ /**
+ * @generated
+ */
+ public UMLDomainNavigatorContentProvider() {
+ myAdapterFctoryContentProvier = new AdapterFactoryContentProvider(
+ UMLDiagramEditorPlugin.getInstance()
+ .getItemProvidersAdapterFactory());
+ TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE
+ .createEditingDomain();
+ myEditingDomain = (AdapterFactoryEditingDomain) editingDomain;
+ myEditingDomain.setResourceToReadOnlyMap(new HashMap() {
+ public Object get(Object key) {
+ if (!containsKey(key)) {
+ put(key, Boolean.TRUE);
+ }
+ return super.get(key);
+ }
+ });
+ myViewerRefreshRunnable = new Runnable() {
+ public void run() {
+ if (myViewer != null) {
+ myViewer.refresh();
+ }
+ }
+ };
+ myWorkspaceSynchronizer = new WorkspaceSynchronizer(editingDomain,
+ new WorkspaceSynchronizer.Delegate() {
+ public void dispose() {
+ }
+
+ public boolean handleResourceChanged(final Resource resource) {
+ for (Iterator it = myEditingDomain.getResourceSet()
+ .getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay()
+ .asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+
+ public boolean handleResourceDeleted(Resource resource) {
+ for (Iterator it = myEditingDomain.getResourceSet()
+ .getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay()
+ .asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+
+ public boolean handleResourceMoved(Resource resource,
+ final URI newURI) {
+ for (Iterator it = myEditingDomain.getResourceSet()
+ .getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay()
+ .asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ myWorkspaceSynchronizer.dispose();
+ myWorkspaceSynchronizer = null;
+ myViewerRefreshRunnable = null;
+ for (Iterator it = myEditingDomain.getResourceSet().getResources()
+ .iterator(); it.hasNext();) {
+ Resource resource = (Resource) it.next();
+ resource.unload();
+ }
+ ((TransactionalEditingDomain) myEditingDomain).dispose();
+ myEditingDomain = null;
+ }
+
+ /**
+ * @generated
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ myViewer = viewer;
+ }
+
+ /**
+ * @generated
+ */
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ /**
+ * @generated
+ */
+ public void restoreState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public void saveState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public void init(ICommonContentExtensionSite aConfig) {
+ }
+
+ /**
+ * @generated
+ */
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof IFile) {
+ IFile file = (IFile) parentElement;
+ URI fileURI = URI.createPlatformResourceURI(file.getFullPath()
+ .toString(), true);
+ Resource resource = myEditingDomain.getResourceSet().getResource(
+ fileURI, true);
+ return wrapEObjects(
+ myAdapterFctoryContentProvier.getChildren(resource),
+ parentElement);
+ }
+
+ if (parentElement instanceof UMLDomainNavigatorItem) {
+ return wrapEObjects(
+ myAdapterFctoryContentProvier.getChildren(((UMLDomainNavigatorItem) parentElement)
+ .getEObject()), parentElement);
+ }
+ return EMPTY_ARRAY;
+ }
+
+ /**
+ * @generated
+ */
+ public Object[] wrapEObjects(Object[] objects, Object parentElement) {
+ Collection result = new ArrayList();
+ for (int i = 0; i < objects.length; i++) {
+ if (objects[i] instanceof EObject) {
+ result.add(new UMLDomainNavigatorItem((EObject) objects[i],
+ parentElement, myAdapterFctoryContentProvier));
+ }
+ }
+ return result.toArray();
+ }
+
+ /**
+ * @generated
+ */
+ public Object getParent(Object element) {
+ if (element instanceof UMLAbstractNavigatorItem) {
+ UMLAbstractNavigatorItem abstractNavigatorItem = (UMLAbstractNavigatorItem) element;
+ return abstractNavigatorItem.getParent();
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean hasChildren(Object element) {
+ return element instanceof IFile || getChildren(element).length > 0;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorItem.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorItem.java
new file mode 100644
index 00000000000..4fc3fba6bac
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorItem.java
@@ -0,0 +1,117 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.navigator;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.IPropertySourceProvider;
+
+/**
+ * @generated
+ */
+public class UMLDomainNavigatorItem extends PlatformObject {
+
+ /**
+ * @generated
+ */
+ static {
+ final Class[] supportedTypes = new Class[] { EObject.class,
+ IPropertySource.class };
+ Platform.getAdapterManager().registerAdapters(
+ new IAdapterFactory() {
+
+ public Object getAdapter(Object adaptableObject,
+ Class adapterType) {
+ if (adaptableObject instanceof org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLDomainNavigatorItem) {
+ org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLDomainNavigatorItem domainNavigatorItem = (org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLDomainNavigatorItem) adaptableObject;
+ EObject eObject = domainNavigatorItem.getEObject();
+ if (adapterType == EObject.class) {
+ return eObject;
+ }
+ if (adapterType == IPropertySource.class) {
+ return domainNavigatorItem
+ .getPropertySourceProvider()
+ .getPropertySource(eObject);
+ }
+ }
+
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return supportedTypes;
+ }
+ },
+ org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLDomainNavigatorItem.class);
+ }
+
+ /**
+ * @generated
+ */
+ private Object myParent;
+
+ /**
+ * @generated
+ */
+ private EObject myEObject;
+
+ /**
+ * @generated
+ */
+ private IPropertySourceProvider myPropertySourceProvider;
+
+ /**
+ * @generated
+ */
+ public UMLDomainNavigatorItem(EObject eObject, Object parent,
+ IPropertySourceProvider propertySourceProvider) {
+ myParent = parent;
+ myEObject = eObject;
+ myPropertySourceProvider = propertySourceProvider;
+ }
+
+ /**
+ * @generated
+ */
+ public Object getParent() {
+ return myParent;
+ }
+
+ /**
+ * @generated
+ */
+ public EObject getEObject() {
+ return myEObject;
+ }
+
+ /**
+ * @generated
+ */
+ public IPropertySourceProvider getPropertySourceProvider() {
+ return myPropertySourceProvider;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLDomainNavigatorItem) {
+ return EcoreUtil
+ .getURI(getEObject())
+ .equals(EcoreUtil
+ .getURI(((org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLDomainNavigatorItem) obj)
+ .getEObject()));
+ }
+ return super.equals(obj);
+ }
+
+ /**
+ * @generated
+ */
+ public int hashCode() {
+ return EcoreUtil.getURI(getEObject()).hashCode();
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorLabelProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorLabelProvider.java
new file mode 100644
index 00000000000..f85d66abf52
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLDomainNavigatorLabelProvider.java
@@ -0,0 +1,98 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.navigator;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonLabelProvider;
+
+/**
+ * @generated
+ */
+public class UMLDomainNavigatorLabelProvider implements ICommonLabelProvider {
+
+ /**
+ * @generated
+ */
+ private AdapterFactoryLabelProvider myAdapterFactoryLabelProvider = new AdapterFactoryLabelProvider(
+ UMLDiagramEditorPlugin.getInstance()
+ .getItemProvidersAdapterFactory());
+
+ /**
+ * @generated
+ */
+ public void init(ICommonContentExtensionSite aConfig) {
+ }
+
+ /**
+ * @generated
+ */
+ public Image getImage(Object element) {
+ if (element instanceof UMLDomainNavigatorItem) {
+ return myAdapterFactoryLabelProvider
+ .getImage(((UMLDomainNavigatorItem) element).getEObject());
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public String getText(Object element) {
+ if (element instanceof UMLDomainNavigatorItem) {
+ return myAdapterFactoryLabelProvider
+ .getText(((UMLDomainNavigatorItem) element).getEObject());
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void addListener(ILabelProviderListener listener) {
+ myAdapterFactoryLabelProvider.addListener(listener);
+ }
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ myAdapterFactoryLabelProvider.dispose();
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isLabelProperty(Object element, String property) {
+ return myAdapterFactoryLabelProvider.isLabelProperty(element, property);
+ }
+
+ /**
+ * @generated
+ */
+ public void removeListener(ILabelProviderListener listener) {
+ myAdapterFactoryLabelProvider.removeListener(listener);
+ }
+
+ /**
+ * @generated
+ */
+ public void restoreState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public void saveState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public String getDescription(Object anElement) {
+ return null;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorActionProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorActionProvider.java
new file mode 100644
index 00000000000..5cf944b823f
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorActionProvider.java
@@ -0,0 +1,176 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.navigator;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.Messages;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditor;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionConstants;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * @generated
+ */
+public class UMLNavigatorActionProvider extends CommonActionProvider {
+
+ /**
+ * @generated
+ */
+ private boolean myContribute;
+
+ /**
+ * @generated
+ */
+ private OpenDiagramAction myOpenDiagramAction;
+
+ /**
+ * @generated
+ */
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+ if (aSite.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+ myContribute = true;
+ makeActions((ICommonViewerWorkbenchSite) aSite.getViewSite());
+ } else {
+ myContribute = false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void makeActions(ICommonViewerWorkbenchSite viewerSite) {
+ myOpenDiagramAction = new OpenDiagramAction(viewerSite);
+ }
+
+ /**
+ * @generated
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ if (!myContribute) {
+ return;
+ }
+ IStructuredSelection selection = (IStructuredSelection) getContext()
+ .getSelection();
+ myOpenDiagramAction.selectionChanged(selection);
+ if (myOpenDiagramAction.isEnabled()) {
+ actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN,
+ myOpenDiagramAction);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void fillContextMenu(IMenuManager menu) {
+ }
+
+ /**
+ * @generated
+ */
+ private static class OpenDiagramAction extends Action {
+
+ /**
+ * @generated
+ */
+ private Diagram myDiagram;
+
+ /**
+ * @generated
+ */
+ private ICommonViewerWorkbenchSite myViewerSite;
+
+ /**
+ * @generated
+ */
+ public OpenDiagramAction(ICommonViewerWorkbenchSite viewerSite) {
+ super(Messages.NavigatorActionProvider_OpenDiagramActionName);
+ myViewerSite = viewerSite;
+ }
+
+ /**
+ * @generated
+ */
+ public final void selectionChanged(IStructuredSelection selection) {
+ myDiagram = null;
+ if (selection.size() == 1) {
+ Object selectedElement = selection.getFirstElement();
+ if (selectedElement instanceof UMLNavigatorItem) {
+ selectedElement = ((UMLNavigatorItem) selectedElement)
+ .getView();
+ } else if (selectedElement instanceof IAdaptable) {
+ selectedElement = ((IAdaptable) selectedElement)
+ .getAdapter(View.class);
+ }
+ if (selectedElement instanceof Diagram) {
+ Diagram diagram = (Diagram) selectedElement;
+ if (ModelEditPart.MODEL_ID.equals(UMLVisualIDRegistry
+ .getModelID(diagram))) {
+ myDiagram = diagram;
+ }
+ }
+ }
+ setEnabled(myDiagram != null);
+ }
+
+ /**
+ * @generated
+ */
+ public void run() {
+ if (myDiagram == null || myDiagram.eResource() == null) {
+ return;
+ }
+
+ IEditorInput editorInput = getEditorInput(myDiagram);
+ IWorkbenchPage page = myViewerSite.getPage();
+ try {
+ page.openEditor(editorInput, UMLDiagramEditor.ID);
+ } catch (PartInitException e) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Exception while openning diagram", e); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private static IEditorInput getEditorInput(Diagram diagram) {
+ Resource diagramResource = diagram.eResource();
+ for (EObject nextEObject : diagramResource.getContents()) {
+ if (nextEObject == diagram) {
+ return new FileEditorInput(
+ WorkspaceSynchronizer.getFile(diagramResource));
+ }
+ if (nextEObject instanceof Diagram) {
+ break;
+ }
+ }
+ URI uri = EcoreUtil.getURI(diagram);
+ String editorName = uri.lastSegment() + '#'
+ + diagram.eResource().getContents().indexOf(diagram);
+ IEditorInput editorInput = new URIEditorInput(uri, editorName);
+ return editorInput;
+ }
+
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorContentProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorContentProvider.java
new file mode 100644
index 00000000000..d952b9b8ea1
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorContentProvider.java
@@ -0,0 +1,368 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.navigator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonContentProvider;
+
+/**
+ * @generated
+ */
+public class UMLNavigatorContentProvider implements ICommonContentProvider {
+ /**
+ * @generated
+ */
+ private static final Object[] EMPTY_ARRAY = new Object[0];
+ /**
+ * @generated
+ */
+ private Viewer myViewer;
+ /**
+ * @generated
+ */
+ private AdapterFactoryEditingDomain myEditingDomain;
+ /**
+ * @generated
+ */
+ private WorkspaceSynchronizer myWorkspaceSynchronizer;
+ /**
+ * @generated
+ */
+ private Runnable myViewerRefreshRunnable;
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings({ "unchecked", "serial", "rawtypes" })
+ public UMLNavigatorContentProvider() {
+ TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE
+ .createEditingDomain();
+ myEditingDomain = (AdapterFactoryEditingDomain) editingDomain;
+ myEditingDomain.setResourceToReadOnlyMap(new HashMap() {
+ public Object get(Object key) {
+ if (!containsKey(key)) {
+ put(key, Boolean.TRUE);
+ }
+ return super.get(key);
+ }
+ });
+ myViewerRefreshRunnable = new Runnable() {
+ public void run() {
+ if (myViewer != null) {
+ myViewer.refresh();
+ }
+ }
+ };
+ myWorkspaceSynchronizer = new WorkspaceSynchronizer(editingDomain,
+ new WorkspaceSynchronizer.Delegate() {
+ public void dispose() {
+ }
+
+ public boolean handleResourceChanged(final Resource resource) {
+ for (Iterator it = myEditingDomain.getResourceSet()
+ .getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay()
+ .asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+
+ public boolean handleResourceDeleted(Resource resource) {
+ for (Iterator it = myEditingDomain.getResourceSet()
+ .getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay()
+ .asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+
+ public boolean handleResourceMoved(Resource resource,
+ final URI newURI) {
+ for (Iterator it = myEditingDomain.getResourceSet()
+ .getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay()
+ .asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+ });
+ }
+
+ /**
+ *
+ *Papyrus Template
+ *this method is a modification of gmf code in order to avoid getViewChidreen() method becoming greater than 64kb.
+ *@generated
+ **/
+ private Object[] getViewChildrenForModelEditPart(View view,
+ Object parentElement) {
+ Collection result = new ArrayList();
+ Collection connectedViews = getChildrenByType(
+ Collections.singleton(view),
+ UMLVisualIDRegistry.getType(ComponentEditPart.VISUAL_ID));
+ result.addAll(createNavigatorItems(connectedViews, parentElement, false));
+ return result.toArray();
+ }
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ myWorkspaceSynchronizer.dispose();
+ myWorkspaceSynchronizer = null;
+ myViewerRefreshRunnable = null;
+ for (Iterator it = myEditingDomain.getResourceSet().getResources()
+ .iterator(); it.hasNext();) {
+ Resource resource = (Resource) it.next();
+ resource.unload();
+ }
+ ((TransactionalEditingDomain) myEditingDomain).dispose();
+ myEditingDomain = null;
+ }
+
+ /**
+ * @generated
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ myViewer = viewer;
+ }
+
+ /**
+ * @generated
+ */
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ /**
+ * @generated
+ */
+ public void restoreState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public void saveState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public void init(ICommonContentExtensionSite aConfig) {
+ }
+
+ /**
+ * @generated
+ */
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof IFile) {
+ IFile file = (IFile) parentElement;
+ URI fileURI = URI.createPlatformResourceURI(file.getFullPath()
+ .toString(), true);
+ Resource resource = myEditingDomain.getResourceSet().getResource(
+ fileURI, true);
+ Collection result = new ArrayList();
+ result.addAll(createNavigatorItems(
+ selectViewsByType(resource.getContents(),
+ ModelEditPart.MODEL_ID), file, false));
+ return result.toArray();
+ }
+
+ if (parentElement instanceof UMLNavigatorGroup) {
+ UMLNavigatorGroup group = (UMLNavigatorGroup) parentElement;
+ return group.getChildren();
+ }
+
+ if (parentElement instanceof UMLNavigatorItem) {
+ UMLNavigatorItem navigatorItem = (UMLNavigatorItem) parentElement;
+ if (navigatorItem.isLeaf() || !isOwnView(navigatorItem.getView())) {
+ return EMPTY_ARRAY;
+ }
+ return getViewChildren(navigatorItem.getView(), parentElement);
+ }
+
+ return EMPTY_ARRAY;
+ }
+
+ /**
+ * @generated
+ */
+ private Object[] getViewChildren(View view, Object parentElement) {
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+
+ case ModelEditPart.VISUAL_ID: {
+
+ //modification of the template to avoid mistake of 65kb.
+ return getViewChildrenForModelEditPart(view, parentElement);
+
+ }
+
+ }
+ return EMPTY_ARRAY;
+ }
+
+ /**
+ * @generated
+ */
+ private Collection getLinksSourceByType(Collection edges, String type) {
+ Collection result = new ArrayList();
+ for (Iterator it = edges.iterator(); it.hasNext();) {
+ Edge nextEdge = (Edge) it.next();
+ View nextEdgeSource = nextEdge.getSource();
+ if (type.equals(nextEdgeSource.getType())
+ && isOwnView(nextEdgeSource)) {
+ result.add(nextEdgeSource);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ private Collection getLinksTargetByType(Collection edges, String type) {
+ Collection result = new ArrayList();
+ for (Iterator it = edges.iterator(); it.hasNext();) {
+ Edge nextEdge = (Edge) it.next();
+ View nextEdgeTarget = nextEdge.getTarget();
+ if (type.equals(nextEdgeTarget.getType())
+ && isOwnView(nextEdgeTarget)) {
+ result.add(nextEdgeTarget);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ private Collection getOutgoingLinksByType(Collection nodes, String type) {
+ Collection result = new ArrayList();
+ for (Iterator it = nodes.iterator(); it.hasNext();) {
+ View nextNode = (View) it.next();
+ result.addAll(selectViewsByType(nextNode.getSourceEdges(), type));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ private Collection getIncomingLinksByType(Collection nodes, String type) {
+ Collection result = new ArrayList();
+ for (Iterator it = nodes.iterator(); it.hasNext();) {
+ View nextNode = (View) it.next();
+ result.addAll(selectViewsByType(nextNode.getTargetEdges(), type));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ private Collection getChildrenByType(Collection nodes, String type) {
+ Collection result = new ArrayList();
+ for (Iterator it = nodes.iterator(); it.hasNext();) {
+ View nextNode = (View) it.next();
+ result.addAll(selectViewsByType(nextNode.getChildren(), type));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ private Collection getDiagramLinksByType(Collection diagrams, String type) {
+ Collection result = new ArrayList();
+ for (Iterator it = diagrams.iterator(); it.hasNext();) {
+ Diagram nextDiagram = (Diagram) it.next();
+ result.addAll(selectViewsByType(nextDiagram.getEdges(), type));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ private Collection selectViewsByType(Collection views, String type) {
+ Collection result = new ArrayList();
+ for (Iterator it = views.iterator(); it.hasNext();) {
+ View nextView = (View) it.next();
+ if (type.equals(nextView.getType()) && isOwnView(nextView)) {
+ result.add(nextView);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ private boolean isOwnView(View view) {
+ return ModelEditPart.MODEL_ID.equals(UMLVisualIDRegistry
+ .getModelID(view));
+ }
+
+ /**
+ * @generated
+ */
+ private Collection createNavigatorItems(Collection views, Object parent,
+ boolean isLeafs) {
+ Collection result = new ArrayList();
+ for (Iterator it = views.iterator(); it.hasNext();) {
+ result.add(new UMLNavigatorItem((View) it.next(), parent, isLeafs));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public Object getParent(Object element) {
+ if (element instanceof UMLAbstractNavigatorItem) {
+ UMLAbstractNavigatorItem abstractNavigatorItem = (UMLAbstractNavigatorItem) element;
+ return abstractNavigatorItem.getParent();
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean hasChildren(Object element) {
+ return element instanceof IFile || getChildren(element).length > 0;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorGroup.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorGroup.java
new file mode 100644
index 00000000000..e8264e8b8db
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorGroup.java
@@ -0,0 +1,97 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.navigator;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+/**
+ * @generated
+ */
+public class UMLNavigatorGroup extends UMLAbstractNavigatorItem {
+
+ /**
+ * @generated
+ */
+ private String myGroupName;
+
+ /**
+ * @generated
+ */
+ private String myIcon;
+
+ /**
+ * @generated
+ */
+ private Collection myChildren = new LinkedList();
+
+ /**
+ * @generated
+ */
+ UMLNavigatorGroup(String groupName, String icon, Object parent) {
+ super(parent);
+ myGroupName = groupName;
+ myIcon = icon;
+ }
+
+ /**
+ * @generated
+ */
+ public String getGroupName() {
+ return myGroupName;
+ }
+
+ /**
+ * @generated
+ */
+ public String getIcon() {
+ return myIcon;
+ }
+
+ /**
+ * @generated
+ */
+ public Object[] getChildren() {
+ return myChildren.toArray();
+ }
+
+ /**
+ * @generated
+ */
+ public void addChildren(Collection children) {
+ myChildren.addAll(children);
+ }
+
+ /**
+ * @generated
+ */
+ public void addChild(Object child) {
+ myChildren.add(child);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isEmpty() {
+ return myChildren.size() == 0;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorGroup) {
+ org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorGroup anotherGroup = (org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorGroup) obj;
+ if (getGroupName().equals(anotherGroup.getGroupName())) {
+ return getParent().equals(anotherGroup.getParent());
+ }
+ }
+ return super.equals(obj);
+ }
+
+ /**
+ * @generated
+ */
+ public int hashCode() {
+ return getGroupName().hashCode();
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorItem.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorItem.java
new file mode 100644
index 00000000000..5acc41ce96a
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorItem.java
@@ -0,0 +1,93 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.navigator;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class UMLNavigatorItem extends UMLAbstractNavigatorItem {
+
+ /**
+ * @generated
+ */
+ static {
+ final Class[] supportedTypes = new Class[] { View.class, EObject.class };
+ Platform.getAdapterManager().registerAdapters(
+ new IAdapterFactory() {
+
+ public Object getAdapter(Object adaptableObject,
+ Class adapterType) {
+ if (adaptableObject instanceof org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorItem
+ && (adapterType == View.class || adapterType == EObject.class)) {
+ return ((org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorItem) adaptableObject)
+ .getView();
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return supportedTypes;
+ }
+ },
+ org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorItem.class);
+ }
+
+ /**
+ * @generated
+ */
+ private View myView;
+
+ /**
+ * @generated
+ */
+ private boolean myLeaf = false;
+
+ /**
+ * @generated
+ */
+ public UMLNavigatorItem(View view, Object parent, boolean isLeaf) {
+ super(parent);
+ myView = view;
+ myLeaf = isLeaf;
+ }
+
+ /**
+ * @generated
+ */
+ public View getView() {
+ return myView;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isLeaf() {
+ return myLeaf;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorItem) {
+ return EcoreUtil
+ .getURI(getView())
+ .equals(EcoreUtil
+ .getURI(((org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorItem) obj)
+ .getView()));
+ }
+ return super.equals(obj);
+ }
+
+ /**
+ * @generated
+ */
+ public int hashCode() {
+ return EcoreUtil.getURI(getView()).hashCode();
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorLabelProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorLabelProvider.java
new file mode 100644
index 00000000000..fbf3b7944f2
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorLabelProvider.java
@@ -0,0 +1,232 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.navigator;
+
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.viewers.ITreePathLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.ViewerLabel;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentNameEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLElementTypes;
+import org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLParserProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonLabelProvider;
+import org.eclipse.uml2.uml.Model;
+
+/**
+ * @generated
+ */
+public class UMLNavigatorLabelProvider extends LabelProvider implements
+ ICommonLabelProvider, ITreePathLabelProvider {
+
+ /**
+ * @generated
+ */
+ static {
+ UMLDiagramEditorPlugin
+ .getInstance()
+ .getImageRegistry()
+ .put("Navigator?UnknownElement", ImageDescriptor.getMissingImageDescriptor()); //$NON-NLS-1$
+ UMLDiagramEditorPlugin
+ .getInstance()
+ .getImageRegistry()
+ .put("Navigator?ImageNotFound", ImageDescriptor.getMissingImageDescriptor()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ public void updateLabel(ViewerLabel label, TreePath elementPath) {
+ Object element = elementPath.getLastSegment();
+ if (element instanceof UMLNavigatorItem
+ && !isOwnView(((UMLNavigatorItem) element).getView())) {
+ return;
+ }
+ label.setText(getText(element));
+ label.setImage(getImage(element));
+ }
+
+ /**
+ * @generated
+ */
+ public Image getImage(Object element) {
+ if (element instanceof UMLNavigatorGroup) {
+ UMLNavigatorGroup group = (UMLNavigatorGroup) element;
+ return UMLDiagramEditorPlugin.getInstance().getBundledImage(
+ group.getIcon());
+ }
+
+ if (element instanceof UMLNavigatorItem) {
+ UMLNavigatorItem navigatorItem = (UMLNavigatorItem) element;
+ if (!isOwnView(navigatorItem.getView())) {
+ return super.getImage(element);
+ }
+ return getImage(navigatorItem.getView());
+ }
+
+ return super.getImage(element);
+ }
+
+ /**
+ * @generated
+ */
+ public Image getImage(View view) {
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ case ModelEditPart.VISUAL_ID:
+ return getImage(
+ "Navigator?Diagram?http://www.eclipse.org/uml2/3.0.0/UML?Model", UMLElementTypes.Model_1000); //$NON-NLS-1$
+ case ComponentEditPart.VISUAL_ID:
+ return getImage(
+ "Navigator?TopLevelNode?http://www.eclipse.org/uml2/3.0.0/UML?Component", UMLElementTypes.Component_2001); //$NON-NLS-1$
+ }
+ return getImage("Navigator?UnknownElement", null); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ private Image getImage(String key, IElementType elementType) {
+ ImageRegistry imageRegistry = UMLDiagramEditorPlugin.getInstance()
+ .getImageRegistry();
+ Image image = imageRegistry.get(key);
+ if (image == null && elementType != null
+ && UMLElementTypes.isKnownElementType(elementType)) {
+ image = UMLElementTypes.getImage(elementType);
+ imageRegistry.put(key, image);
+ }
+
+ if (image == null) {
+ image = imageRegistry.get("Navigator?ImageNotFound"); //$NON-NLS-1$
+ imageRegistry.put(key, image);
+ }
+ return image;
+ }
+
+ /**
+ * @generated
+ */
+ public String getText(Object element) {
+ if (element instanceof UMLNavigatorGroup) {
+ UMLNavigatorGroup group = (UMLNavigatorGroup) element;
+ return group.getGroupName();
+ }
+
+ if (element instanceof UMLNavigatorItem) {
+ UMLNavigatorItem navigatorItem = (UMLNavigatorItem) element;
+ if (!isOwnView(navigatorItem.getView())) {
+ return null;
+ }
+ return getText(navigatorItem.getView());
+ }
+
+ return super.getText(element);
+ }
+
+ /**
+ * @generated
+ */
+ public String getText(View view) {
+ if (view.getElement() != null && view.getElement().eIsProxy()) {
+ return getUnresolvedDomainElementProxyText(view);
+ }
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ case ModelEditPart.VISUAL_ID:
+ return getModel_1000Text(view);
+ case ComponentEditPart.VISUAL_ID:
+ return getComponent_2001Text(view);
+ }
+ return getUnknownElementText(view);
+ }
+
+ /**
+ * @generated
+ */
+ private String getModel_1000Text(View view) {
+ Model domainModelElement = (Model) view.getElement();
+ if (domainModelElement != null) {
+ return String.valueOf(domainModelElement.getName());
+ } else {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "No domain element for view with visualID = " + 1000); //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private String getComponent_2001Text(View view) {
+ IParser parser = UMLParserProvider.getParser(
+ UMLElementTypes.Component_2001,
+ view.getElement() != null ? view.getElement() : view,
+ UMLVisualIDRegistry.getType(ComponentNameEditPart.VISUAL_ID));
+ if (parser != null) {
+ return parser.getPrintString(new EObjectAdapter(
+ view.getElement() != null ? view.getElement() : view),
+ ParserOptions.NONE.intValue());
+ } else {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Parser was not found for label " + 5001); //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private String getUnknownElementText(View view) {
+ return "<UnknownElement Visual_ID = " + view.getType() + ">"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * @generated
+ */
+ private String getUnresolvedDomainElementProxyText(View view) {
+ return "<Unresolved domain element Visual_ID = " + view.getType() + ">"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * @generated
+ */
+ public void init(ICommonContentExtensionSite aConfig) {
+ }
+
+ /**
+ * @generated
+ */
+ public void restoreState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public void saveState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public String getDescription(Object anElement) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private boolean isOwnView(View view) {
+ return ModelEditPart.MODEL_ID.equals(UMLVisualIDRegistry
+ .getModelID(view));
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorLinkHelper.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorLinkHelper.java
new file mode 100644
index 00000000000..7b1e024674d
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorLinkHelper.java
@@ -0,0 +1,123 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.navigator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.navigator.ILinkHelper;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * @generated
+ */
+public class UMLNavigatorLinkHelper implements ILinkHelper {
+
+ /**
+ * @generated
+ */
+ private static IEditorInput getEditorInput(Diagram diagram) {
+ Resource diagramResource = diagram.eResource();
+ for (EObject nextEObject : diagramResource.getContents()) {
+ if (nextEObject == diagram) {
+ return new FileEditorInput(
+ WorkspaceSynchronizer.getFile(diagramResource));
+ }
+ if (nextEObject instanceof Diagram) {
+ break;
+ }
+ }
+ URI uri = EcoreUtil.getURI(diagram);
+ String editorName = uri.lastSegment() + '#'
+ + diagram.eResource().getContents().indexOf(diagram);
+ IEditorInput editorInput = new URIEditorInput(uri, editorName);
+ return editorInput;
+ }
+
+ /**
+ * @generated
+ */
+ public IStructuredSelection findSelection(IEditorInput anInput) {
+ IDiagramDocument document = UMLDiagramEditorPlugin.getInstance()
+ .getDocumentProvider().getDiagramDocument(anInput);
+ if (document == null) {
+ return StructuredSelection.EMPTY;
+ }
+ Diagram diagram = document.getDiagram();
+ IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
+ if (file != null) {
+ UMLNavigatorItem item = new UMLNavigatorItem(diagram, file, false);
+ return new StructuredSelection(item);
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ /**
+ * @generated
+ */
+ public void activateEditor(IWorkbenchPage aPage,
+ IStructuredSelection aSelection) {
+ if (aSelection == null || aSelection.isEmpty()) {
+ return;
+ }
+ if (false == aSelection.getFirstElement() instanceof UMLAbstractNavigatorItem) {
+ return;
+ }
+
+ UMLAbstractNavigatorItem abstractNavigatorItem = (UMLAbstractNavigatorItem) aSelection
+ .getFirstElement();
+ View navigatorView = null;
+ if (abstractNavigatorItem instanceof UMLNavigatorItem) {
+ navigatorView = ((UMLNavigatorItem) abstractNavigatorItem)
+ .getView();
+ } else if (abstractNavigatorItem instanceof UMLNavigatorGroup) {
+ UMLNavigatorGroup navigatorGroup = (UMLNavigatorGroup) abstractNavigatorItem;
+ if (navigatorGroup.getParent() instanceof UMLNavigatorItem) {
+ navigatorView = ((UMLNavigatorItem) navigatorGroup.getParent())
+ .getView();
+ }
+ }
+ if (navigatorView == null) {
+ return;
+ }
+ IEditorInput editorInput = getEditorInput(navigatorView.getDiagram());
+ IEditorPart editor = aPage.findEditor(editorInput);
+ if (editor == null) {
+ return;
+ }
+ aPage.bringToTop(editor);
+ if (editor instanceof DiagramEditor) {
+ DiagramEditor diagramEditor = (DiagramEditor) editor;
+ ResourceSet diagramEditorResourceSet = diagramEditor
+ .getEditingDomain().getResourceSet();
+ EObject selectedView = diagramEditorResourceSet.getEObject(
+ EcoreUtil.getURI(navigatorView), true);
+ if (selectedView == null) {
+ return;
+ }
+ GraphicalViewer graphicalViewer = (GraphicalViewer) diagramEditor
+ .getAdapter(GraphicalViewer.class);
+ EditPart selectedEditPart = (EditPart) graphicalViewer
+ .getEditPartRegistry().get(selectedView);
+ if (selectedEditPart != null) {
+ graphicalViewer.select(selectedEditPart);
+ }
+ }
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorSorter.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorSorter.java
new file mode 100644
index 00000000000..a713e6119cf
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/navigator/UMLNavigatorSorter.java
@@ -0,0 +1,27 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.navigator;
+
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+
+/**
+ * @generated
+ */
+public class UMLNavigatorSorter extends ViewerSorter {
+
+ /**
+ * @generated
+ */
+ private static final int GROUP_CATEGORY = 2003;
+
+ /**
+ * @generated
+ */
+ public int category(Object element) {
+ if (element instanceof UMLNavigatorItem) {
+ UMLNavigatorItem item = (UMLNavigatorItem) element;
+ return UMLVisualIDRegistry.getVisualID(item.getView());
+ }
+ return GROUP_CATEGORY;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/parsers/AbstractParser.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/parsers/AbstractParser.java
new file mode 100644
index 00000000000..dd5d75fa54d
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/parsers/AbstractParser.java
@@ -0,0 +1,464 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.parsers;
+
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.Messages;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+
+/**
+ * @generated
+ */
+public abstract class AbstractParser implements IParser {
+
+ /**
+ * @generated
+ */
+ protected final EAttribute[] features;
+
+ /**
+ * @generated
+ */
+ protected final EAttribute[] editableFeatures;
+
+ /**
+ * @generated
+ */
+ private String viewPattern;
+
+ /**
+ * @generated
+ */
+ private String editorPattern;
+
+ /**
+ * @generated
+ */
+ private String editPattern;
+
+ /**
+ * @generated
+ */
+ public AbstractParser(EAttribute[] features) {
+ if (features == null || Arrays.asList(features).contains(null)) {
+ throw new IllegalArgumentException();
+ }
+ this.editableFeatures = this.features = features;
+ }
+
+ /**
+ * @generated
+ */
+ public AbstractParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ if (features == null || Arrays.asList(features).contains(null)) {
+ throw new IllegalArgumentException();
+ }
+ this.features = features;
+ if (editableFeatures == null
+ || Arrays.asList(editableFeatures).contains(null)) {
+ throw new IllegalArgumentException();
+ }
+ this.editableFeatures = editableFeatures;
+ }
+
+ /**
+ * @generated
+ */
+ public String getViewPattern() {
+ return viewPattern;
+ }
+
+ /**
+ * @generated
+ */
+ public void setViewPattern(String viewPattern) {
+ this.viewPattern = viewPattern;
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditorPattern() {
+ return editorPattern;
+ }
+
+ /**
+ * @generated
+ */
+ public void setEditorPattern(String editorPattern) {
+ this.editorPattern = editorPattern;
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditPattern() {
+ return editPattern;
+ }
+
+ /**
+ * @generated
+ */
+ public void setEditPattern(String editPattern) {
+ this.editPattern = editPattern;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isAffectingEvent(Object event, int flags) {
+ if (event instanceof Notification) {
+ return isAffectingFeature(((Notification) event).getFeature());
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isAffectingFeature(Object feature) {
+ for (int i = 0; i < features.length; i++) {
+ if (features[i] == feature) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Object[] getValues(EObject element) {
+ Object[] values = new Object[features.length];
+ for (int i = 0; i < features.length; i++) {
+ values[i] = getValue(element, features[i]);
+ }
+ return values;
+ }
+
+ /**
+ * @generated
+ */
+ protected Object[] getEditableValues(EObject element) {
+ Object[] values = new Object[editableFeatures.length];
+ for (int i = 0; i < editableFeatures.length; i++) {
+ values[i] = getValue(element, editableFeatures[i]);
+ }
+ return values;
+ }
+
+ /**
+ * @generated
+ */
+ protected Object getValue(EObject element, EAttribute feature) {
+ Object value = element.eGet(feature);
+ Class iClass = feature.getEAttributeType().getInstanceClass();
+ if (String.class.equals(iClass)) {
+ if (value == null) {
+ value = ""; //$NON-NLS-1$
+ }
+ }
+ return value;
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getParseCommand(IAdaptable adapter, Object[] values,
+ int flags) {
+ if (values == null
+ || validateNewValues(values).getCode() != IParserEditStatus.EDITABLE) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ EObject element = (EObject) adapter.getAdapter(EObject.class);
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(element);
+ if (editingDomain == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ CompositeTransactionalCommand command = new CompositeTransactionalCommand(
+ editingDomain, "Set Values"); //$NON-NLS-1$
+ for (int i = 0; i < values.length; i++) {
+ command.compose(getModificationCommand(element,
+ editableFeatures[i], values[i]));
+ }
+ return command;
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getModificationCommand(EObject element,
+ EAttribute feature, Object value) {
+ value = getValidNewValue(feature, value);
+ if (value instanceof InvalidValue) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ SetRequest request = new SetRequest(element, feature, value);
+ return new SetValueCommand(request);
+ }
+
+ /**
+ * @generated
+ */
+ protected IParserEditStatus validateNewValues(Object[] values) {
+ if (values.length != editableFeatures.length) {
+ return ParserEditStatus.UNEDITABLE_STATUS;
+ }
+ for (int i = 0; i < values.length; i++) {
+ Object value = getValidNewValue(editableFeatures[i], values[i]);
+ if (value instanceof InvalidValue) {
+ return new ParserEditStatus(UMLDiagramEditorPlugin.ID,
+ IParserEditStatus.UNEDITABLE, value.toString());
+ }
+ }
+ return ParserEditStatus.EDITABLE_STATUS;
+ }
+
+ /**
+ * @generated
+ */
+ protected Object getValidNewValue(EAttribute feature, Object value) {
+ EClassifier type = feature.getEType();
+ if (type instanceof EDataType) {
+ Class iClass = type.getInstanceClass();
+ if (Boolean.TYPE.equals(iClass)) {
+ if (value instanceof Boolean) {
+ // ok
+ } else if (value instanceof String) {
+ value = Boolean.valueOf((String) value);
+ } else {
+ value = new InvalidValue(NLS.bind(
+ Messages.AbstractParser_UnexpectedValueType,
+ iClass.getName()));
+ }
+ } else if (Character.TYPE.equals(iClass)) {
+ if (value instanceof Character) {
+ // ok
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ value = new Character(s.charAt(0));
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(
+ Messages.AbstractParser_UnexpectedValueType,
+ iClass.getName()));
+ }
+ } else if (Byte.TYPE.equals(iClass)) {
+ if (value instanceof Byte) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Byte(((Number) value).byteValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Byte.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(
+ NLS.bind(
+ Messages.AbstractParser_WrongStringConversion,
+ iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(
+ Messages.AbstractParser_UnexpectedValueType,
+ iClass.getName()));
+ }
+ } else if (Short.TYPE.equals(iClass)) {
+ if (value instanceof Short) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Short(((Number) value).shortValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Short.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(
+ NLS.bind(
+ Messages.AbstractParser_WrongStringConversion,
+ iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(
+ Messages.AbstractParser_UnexpectedValueType,
+ iClass.getName()));
+ }
+ } else if (Integer.TYPE.equals(iClass)) {
+ if (value instanceof Integer) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Integer(((Number) value).intValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Integer.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(
+ NLS.bind(
+ Messages.AbstractParser_WrongStringConversion,
+ iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(
+ Messages.AbstractParser_UnexpectedValueType,
+ iClass.getName()));
+ }
+ } else if (Long.TYPE.equals(iClass)) {
+ if (value instanceof Long) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Long(((Number) value).longValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Long.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(
+ NLS.bind(
+ Messages.AbstractParser_WrongStringConversion,
+ iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(
+ Messages.AbstractParser_UnexpectedValueType,
+ iClass.getName()));
+ }
+ } else if (Float.TYPE.equals(iClass)) {
+ if (value instanceof Float) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Float(((Number) value).floatValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Float.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(
+ NLS.bind(
+ Messages.AbstractParser_WrongStringConversion,
+ iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(
+ Messages.AbstractParser_UnexpectedValueType,
+ iClass.getName()));
+ }
+ } else if (Double.TYPE.equals(iClass)) {
+ if (value instanceof Double) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Double(((Number) value).doubleValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Double.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(
+ NLS.bind(
+ Messages.AbstractParser_WrongStringConversion,
+ iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(
+ Messages.AbstractParser_UnexpectedValueType,
+ iClass.getName()));
+ }
+ } else if (type instanceof EEnum) {
+ if (value instanceof String) {
+ EEnumLiteral literal = ((EEnum) type)
+ .getEEnumLiteralByLiteral((String) value);
+ if (literal == null) {
+ value = new InvalidValue(NLS.bind(
+ Messages.AbstractParser_UnknownLiteral, value));
+ } else {
+ value = literal.getInstance();
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(
+ Messages.AbstractParser_UnexpectedValueType,
+ String.class.getName()));
+ }
+ }
+ }
+ return value;
+ }
+
+ /**
+ * @generated
+ */
+ protected class InvalidValue {
+
+ /**
+ * @generated
+ */
+ private String description;
+
+ /**
+ * @generated
+ */
+ public InvalidValue(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @generated
+ */
+ public String toString() {
+ return description;
+ }
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/parsers/MessageFormatParser.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/parsers/MessageFormatParser.java
new file mode 100644
index 00000000000..89f2573129d
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/parsers/MessageFormatParser.java
@@ -0,0 +1,204 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.parsers;
+
+import java.text.FieldPosition;
+import java.text.MessageFormat;
+import java.text.ParsePosition;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.Messages;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+
+/**
+ * @generated
+ */
+public class MessageFormatParser extends AbstractParser {
+
+ /**
+ * @generated
+ */
+ private String defaultPattern;
+
+ /**
+ * @generated
+ */
+ private String defaultEditablePattern;
+
+ /**
+ * @generated
+ */
+ private MessageFormat viewProcessor;
+
+ /**
+ * @generated
+ */
+ private MessageFormat editorProcessor;
+
+ /**
+ * @generated
+ */
+ private MessageFormat editProcessor;
+
+ /**
+ * @generated
+ */
+ public MessageFormatParser(EAttribute[] features) {
+ super(features);
+ }
+
+ /**
+ * @generated
+ */
+ public MessageFormatParser(EAttribute[] features,
+ EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ /**
+ * @generated
+ */
+ protected String getDefaultPattern() {
+ if (defaultPattern == null) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < features.length; i++) {
+ if (i > 0) {
+ sb.append(' ');
+ }
+ sb.append('{');
+ sb.append(i);
+ sb.append('}');
+ }
+ defaultPattern = sb.toString();
+ }
+ return defaultPattern;
+ }
+
+ /**
+ * @generated
+ */
+ public void setViewPattern(String viewPattern) {
+ super.setViewPattern(viewPattern);
+ viewProcessor = null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setEditorPattern(String editorPattern) {
+ super.setEditorPattern(editorPattern);
+ editorProcessor = null;
+ }
+
+ /**
+ * @generated
+ */
+ protected MessageFormat getViewProcessor() {
+ if (viewProcessor == null) {
+ viewProcessor = new MessageFormat(
+ getViewPattern() == null ? getDefaultPattern()
+ : getViewPattern());
+ }
+ return viewProcessor;
+ }
+
+ /**
+ * @generated
+ */
+ protected MessageFormat getEditorProcessor() {
+ if (editorProcessor == null) {
+ editorProcessor = new MessageFormat(
+ getEditorPattern() == null ? getDefaultEditablePattern()
+ : getEditorPattern());
+ }
+ return editorProcessor;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getDefaultEditablePattern() {
+ if (defaultEditablePattern == null) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < editableFeatures.length; i++) {
+ if (i > 0) {
+ sb.append(' ');
+ }
+ sb.append('{');
+ sb.append(i);
+ sb.append('}');
+ }
+ defaultEditablePattern = sb.toString();
+ }
+ return defaultEditablePattern;
+ }
+
+ /**
+ * @generated
+ */
+ public void setEditPattern(String editPattern) {
+ super.setEditPattern(editPattern);
+ editProcessor = null;
+ }
+
+ /**
+ * @generated
+ */
+ protected MessageFormat getEditProcessor() {
+ if (editProcessor == null) {
+ editProcessor = new MessageFormat(
+ getEditPattern() == null ? getDefaultEditablePattern()
+ : getEditPattern());
+ }
+ return editProcessor;
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditString(IAdaptable adapter, int flags) {
+ EObject element = (EObject) adapter.getAdapter(EObject.class);
+ return getEditorProcessor().format(getEditableValues(element),
+ new StringBuffer(), new FieldPosition(0)).toString();
+ }
+
+ /**
+ * @generated
+ */
+ public IParserEditStatus isValidEditString(IAdaptable adapter,
+ String editString) {
+ ParsePosition pos = new ParsePosition(0);
+ Object[] values = getEditProcessor().parse(editString, pos);
+ if (values == null) {
+ return new ParserEditStatus(UMLDiagramEditorPlugin.ID,
+ IParserEditStatus.UNEDITABLE, NLS.bind(
+ Messages.MessageFormatParser_InvalidInputError,
+ new Integer(pos.getErrorIndex())));
+ }
+ return validateNewValues(values);
+ }
+
+ /**
+ * @generated
+ */
+ public ICommand getParseCommand(IAdaptable adapter, String newString,
+ int flags) {
+ Object[] values = getEditProcessor().parse(newString,
+ new ParsePosition(0));
+ return getParseCommand(adapter, values, flags);
+ }
+
+ /**
+ * @generated
+ */
+ public String getPrintString(IAdaptable adapter, int flags) {
+ EObject element = (EObject) adapter.getAdapter(EObject.class);
+ return getViewProcessor().format(getValues(element),
+ new StringBuffer(), new FieldPosition(0)).toString();
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/DeleteElementAction.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/DeleteElementAction.java
new file mode 100644
index 00000000000..e73f96c8896
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/DeleteElementAction.java
@@ -0,0 +1,3 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+//This file is not used.
+//The DeleteElementAction is removed from the plugin and replaced by DeleteFromModelAction in the plugin org.eclipse.diagram.common.
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/DiagramEditorContextMenuProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/DiagramEditorContextMenuProvider.java
new file mode 100644
index 00000000000..262669de761
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/DiagramEditorContextMenuProvider.java
@@ -0,0 +1,58 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService;
+import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
+import org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @generated
+ */
+public class DiagramEditorContextMenuProvider extends
+ DiagramContextMenuProvider {
+
+ /**
+ * @generated
+ */
+ private IWorkbenchPart part;
+
+ /**
+ * @generated
+ */
+ public DiagramEditorContextMenuProvider(IWorkbenchPart part,
+ EditPartViewer viewer) {
+ super(part, viewer);
+ this.part = part;
+
+ }
+
+ /**
+ * @generated
+ */
+ public void buildContextMenu(final IMenuManager menu) {
+ getViewer().flush();
+ try {
+ TransactionUtil.getEditingDomain(
+ (EObject) getViewer().getContents().getModel())
+ .runExclusive(new Runnable() {
+
+ public void run() {
+ ContributionItemService
+ .getInstance()
+ .contributeToPopupMenu(
+ DiagramEditorContextMenuProvider.this,
+ part);
+ menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL);
+
+ }
+ });
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Error building context menu", e);
+ }
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/LoadResourceAction.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/LoadResourceAction.java
new file mode 100644
index 00000000000..040d7e7f999
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/LoadResourceAction.java
@@ -0,0 +1,31 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * @generated
+ */
+public class LoadResourceAction extends AbstractHandler {
+ /**
+ * @generated
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IEditorPart diagramEditor = HandlerUtil.getActiveEditorChecked(event);
+ Shell shell = diagramEditor.getEditorSite().getShell();
+ assert diagramEditor instanceof DiagramEditor;
+ TransactionalEditingDomain editingDomain = ((DiagramEditor) diagramEditor)
+ .getEditingDomain();
+ org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog loadResourceDialog = new org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog(
+ shell, editingDomain);
+ loadResourceDialog.open();
+ return null;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/Messages.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/Messages.java
new file mode 100644
index 00000000000..7c22a98c419
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/Messages.java
@@ -0,0 +1,299 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @generated
+ */
+public class Messages extends NLS {
+
+ /**
+ * @generated
+ */
+ static {
+ NLS.initializeMessages("messages", Messages.class); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ private Messages() {
+ }
+
+ /**
+ * @generated
+ */
+ public static String UMLCreationWizardTitle;
+
+ /**
+ * @generated
+ */
+ public static String UMLCreationWizard_DiagramModelFilePageTitle;
+
+ /**
+ * @generated
+ */
+ public static String UMLCreationWizard_DiagramModelFilePageDescription;
+
+ /**
+ * @generated
+ */
+ public static String UMLCreationWizard_DomainModelFilePageTitle;
+
+ /**
+ * @generated
+ */
+ public static String UMLCreationWizard_DomainModelFilePageDescription;
+
+ /**
+ * @generated
+ */
+ public static String UMLCreationWizardOpenEditorError;
+
+ /**
+ * @generated
+ */
+ public static String UMLCreationWizardCreationError;
+
+ /**
+ * @generated
+ */
+ public static String UMLCreationWizardPageExtensionError;
+
+ /**
+ * @generated
+ */
+ public static String UMLDiagramEditorUtil_OpenModelResourceErrorDialogTitle;
+
+ /**
+ * @generated
+ */
+ public static String UMLDiagramEditorUtil_OpenModelResourceErrorDialogMessage;
+
+ /**
+ * @generated
+ */
+ public static String UMLDiagramEditorUtil_CreateDiagramProgressTask;
+
+ /**
+ * @generated
+ */
+ public static String UMLDiagramEditorUtil_CreateDiagramCommandLabel;
+
+ /**
+ * @generated
+ */
+ public static String UMLDocumentProvider_isModifiable;
+
+ /**
+ * @generated
+ */
+ public static String UMLDocumentProvider_handleElementContentChanged;
+
+ /**
+ * @generated
+ */
+ public static String UMLDocumentProvider_IncorrectInputError;
+
+ /**
+ * @generated
+ */
+ public static String UMLDocumentProvider_NoDiagramInResourceError;
+
+ /**
+ * @generated
+ */
+ public static String UMLDocumentProvider_DiagramLoadingError;
+
+ /**
+ * @generated
+ */
+ public static String UMLDocumentProvider_UnsynchronizedFileSaveError;
+
+ /**
+ * @generated
+ */
+ public static String UMLDocumentProvider_SaveDiagramTask;
+
+ /**
+ * @generated
+ */
+ public static String UMLDocumentProvider_SaveNextResourceTask;
+
+ /**
+ * @generated
+ */
+ public static String UMLDocumentProvider_SaveAsOperation;
+
+ /**
+ * @generated
+ */
+ public static String InitDiagramFile_ResourceErrorDialogTitle;
+
+ /**
+ * @generated
+ */
+ public static String InitDiagramFile_ResourceErrorDialogMessage;
+
+ /**
+ * @generated
+ */
+ public static String InitDiagramFile_WizardTitle;
+
+ /**
+ * @generated
+ */
+ public static String InitDiagramFile_OpenModelFileDialogTitle;
+
+ /**
+ * @generated
+ */
+ public static String UMLNewDiagramFileWizard_CreationPageName;
+
+ /**
+ * @generated
+ */
+ public static String UMLNewDiagramFileWizard_CreationPageTitle;
+
+ /**
+ * @generated
+ */
+ public static String UMLNewDiagramFileWizard_CreationPageDescription;
+
+ /**
+ * @generated
+ */
+ public static String UMLNewDiagramFileWizard_RootSelectionPageName;
+
+ /**
+ * @generated
+ */
+ public static String UMLNewDiagramFileWizard_RootSelectionPageTitle;
+
+ /**
+ * @generated
+ */
+ public static String UMLNewDiagramFileWizard_RootSelectionPageDescription;
+
+ /**
+ * @generated
+ */
+ public static String UMLNewDiagramFileWizard_RootSelectionPageSelectionTitle;
+
+ /**
+ * @generated
+ */
+ public static String UMLNewDiagramFileWizard_RootSelectionPageNoSelectionMessage;
+
+ /**
+ * @generated
+ */
+ public static String UMLNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage;
+
+ /**
+ * @generated
+ */
+ public static String UMLNewDiagramFileWizard_InitDiagramCommand;
+
+ /**
+ * @generated
+ */
+ public static String UMLNewDiagramFileWizard_IncorrectRootError;
+
+ /**
+ * @generated
+ */
+ public static String UMLDiagramEditor_SavingDeletedFile;
+
+ /**
+ * @generated
+ */
+ public static String UMLDiagramEditor_SaveAsErrorTitle;
+
+ /**
+ * @generated
+ */
+ public static String UMLDiagramEditor_SaveAsErrorMessage;
+
+ /**
+ * @generated
+ */
+ public static String UMLDiagramEditor_SaveErrorTitle;
+
+ /**
+ * @generated
+ */
+ public static String UMLDiagramEditor_SaveErrorMessage;
+
+ /**
+ * @generated
+ */
+ public static String UMLElementChooserDialog_SelectModelElementTitle;
+
+ /**
+ * @generated
+ */
+ public static String ModelElementSelectionPageMessage;
+
+ /**
+ * @generated
+ */
+ public static String ValidateActionMessage;
+
+ /**
+ * @generated
+ */
+ public static String createUml1Group_title;
+
+ /**
+ * @generated
+ */
+ public static String createComponent1CreationTool_title;
+
+ /**
+ * @generated
+ */
+ public static String createComponent1CreationTool_desc;
+
+ /**
+ * @generated
+ */
+ public static String CommandName_OpenDiagram;
+
+ /**
+ * @generated
+ */
+ public static String NavigatorActionProvider_OpenDiagramActionName;
+
+ /**
+ * @generated
+ */
+ public static String AbstractParser_UnexpectedValueType;
+
+ /**
+ * @generated
+ */
+ public static String AbstractParser_WrongStringConversion;
+
+ /**
+ * @generated
+ */
+ public static String AbstractParser_UnknownLiteral;
+
+ /**
+ * @generated
+ */
+ public static String MessageFormatParser_InvalidInputError;
+
+ /**
+ * @generated
+ */
+ public static String UMLModelingAssistantProviderTitle;
+
+ /**
+ * @generated
+ */
+ public static String UMLModelingAssistantProviderMessage;
+
+ //TODO: put accessor fields manually
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/ModelElementSelectionPage.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/ModelElementSelectionPage.java
new file mode 100644
index 00000000000..3f38408b03d
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/ModelElementSelectionPage.java
@@ -0,0 +1,150 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.edit.provider.IWrapperItemProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * Wizard page that allows to select element from model.
+ * @generated
+ */
+public class ModelElementSelectionPage extends WizardPage {
+ /**
+ * @generated
+ */
+ protected EObject selectedModelElement;
+
+ /**
+ * @generated
+ */
+ private TreeViewer modelViewer;
+
+ /**
+ * @generated
+ */
+ public ModelElementSelectionPage(String pageName) {
+ super(pageName);
+ }
+
+ /**
+ * @generated
+ */
+ public EObject getModelElement() {
+ return selectedModelElement;
+ }
+
+ /**
+ * @generated
+ */
+ public void setModelElement(EObject modelElement) {
+ selectedModelElement = modelElement;
+ if (modelViewer != null) {
+ if (selectedModelElement != null) {
+ modelViewer.setInput(selectedModelElement.eResource());
+ modelViewer.setSelection(new StructuredSelection(
+ selectedModelElement));
+ } else {
+ modelViewer.setInput(null);
+ }
+ setPageComplete(validatePage());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite plate = new Composite(parent, SWT.NONE);
+ plate.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ plate.setLayout(layout);
+ setControl(plate);
+
+ Label label = new Label(plate, SWT.NONE);
+ label.setText(getSelectionTitle());
+ label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ modelViewer = new TreeViewer(plate, SWT.SINGLE | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.BORDER);
+ GridData layoutData = new GridData(GridData.FILL_BOTH);
+ layoutData.heightHint = 300;
+ layoutData.widthHint = 300;
+ modelViewer.getTree().setLayoutData(layoutData);
+ modelViewer.setContentProvider(new AdapterFactoryContentProvider(
+ UMLDiagramEditorPlugin.getInstance()
+ .getItemProvidersAdapterFactory()));
+ modelViewer.setLabelProvider(new AdapterFactoryLabelProvider(
+ UMLDiagramEditorPlugin.getInstance()
+ .getItemProvidersAdapterFactory()));
+ if (selectedModelElement != null) {
+ modelViewer.setInput(selectedModelElement.eResource());
+ modelViewer.setSelection(new StructuredSelection(
+ selectedModelElement));
+ }
+ modelViewer
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ ModelElementSelectionPage.this
+ .updateSelection((IStructuredSelection) event
+ .getSelection());
+ }
+ });
+
+ setPageComplete(validatePage());
+ }
+
+ /**
+ * Override to provide custom model element description.
+ * @generated
+ */
+ protected String getSelectionTitle() {
+ return Messages.ModelElementSelectionPageMessage;
+ }
+
+ /**
+ * @generated
+ */
+ protected void updateSelection(IStructuredSelection selection) {
+ selectedModelElement = null;
+ if (selection.size() == 1) {
+ Object selectedElement = selection.getFirstElement();
+ if (selectedElement instanceof IWrapperItemProvider) {
+ selectedElement = ((IWrapperItemProvider) selectedElement)
+ .getValue();
+ }
+ if (selectedElement instanceof FeatureMap.Entry) {
+ selectedElement = ((FeatureMap.Entry) selectedElement)
+ .getValue();
+ }
+ if (selectedElement instanceof EObject) {
+ selectedModelElement = (EObject) selectedElement;
+ }
+ }
+ setPageComplete(validatePage());
+ }
+
+ /**
+ * Override to provide specific validation of the selected model element.
+ * @generated
+ */
+ protected boolean validatePage() {
+ return true;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLCreationWizard.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLCreationWizard.java
new file mode 100644
index 00000000000..ad751a67752
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLCreationWizard.java
@@ -0,0 +1,173 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+/**
+ * @generated
+ */
+public class UMLCreationWizard extends Wizard implements INewWizard {
+
+ /**
+ * @generated
+ */
+ private IWorkbench workbench;
+
+ /**
+ * @generated
+ */
+ protected IStructuredSelection selection;
+
+ /**
+ * @generated
+ */
+ protected UMLCreationWizardPage diagramModelFilePage;
+
+ /**
+ * @generated
+ */
+ protected UMLCreationWizardPage domainModelFilePage;
+
+ /**
+ * @generated
+ */
+ protected Resource diagram;
+
+ /**
+ * @generated
+ */
+ private boolean openNewlyCreatedDiagramEditor = true;
+
+ /**
+ * @generated
+ */
+ public IWorkbench getWorkbench() {
+ return workbench;
+ }
+
+ /**
+ * @generated
+ */
+ public IStructuredSelection getSelection() {
+ return selection;
+ }
+
+ /**
+ * @generated
+ */
+ public final Resource getDiagram() {
+ return diagram;
+ }
+
+ /**
+ * @generated
+ */
+ public final boolean isOpenNewlyCreatedDiagramEditor() {
+ return openNewlyCreatedDiagramEditor;
+ }
+
+ /**
+ * @generated
+ */
+ public void setOpenNewlyCreatedDiagramEditor(
+ boolean openNewlyCreatedDiagramEditor) {
+ this.openNewlyCreatedDiagramEditor = openNewlyCreatedDiagramEditor;
+ }
+
+ /**
+ * @generated
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ setWindowTitle(Messages.UMLCreationWizardTitle);
+ setDefaultPageImageDescriptor(UMLDiagramEditorPlugin
+ .getBundledImageDescriptor("icons/wizban/NewUMLWizard.gif")); //$NON-NLS-1$
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * @generated
+ */
+ public void addPages() {
+ diagramModelFilePage = new UMLCreationWizardPage(
+ "DiagramModelFile", getSelection(), "PapyrusNewDiagram_diagram"); //$NON-NLS-1$ //$NON-NLS-2$
+ diagramModelFilePage
+ .setTitle(Messages.UMLCreationWizard_DiagramModelFilePageTitle);
+ diagramModelFilePage
+ .setDescription(Messages.UMLCreationWizard_DiagramModelFilePageDescription);
+ addPage(diagramModelFilePage);
+
+ domainModelFilePage = new UMLCreationWizardPage(
+ "DomainModelFile", getSelection(), "PapyrusNewDiagram") { //$NON-NLS-1$ //$NON-NLS-2$
+
+ public void setVisible(boolean visible) {
+ if (visible) {
+ String fileName = diagramModelFilePage.getFileName();
+ fileName = fileName.substring(0, fileName.length()
+ - ".PapyrusNewDiagram_diagram".length()); //$NON-NLS-1$
+ setFileName(UMLDiagramEditorUtil.getUniqueFileName(
+ getContainerFullPath(), fileName,
+ "PapyrusNewDiagram")); //$NON-NLS-1$
+ }
+ super.setVisible(visible);
+ }
+ };
+ domainModelFilePage
+ .setTitle(Messages.UMLCreationWizard_DomainModelFilePageTitle);
+ domainModelFilePage
+ .setDescription(Messages.UMLCreationWizard_DomainModelFilePageDescription);
+ addPage(domainModelFilePage);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean performFinish() {
+ IRunnableWithProgress op = new WorkspaceModifyOperation(null) {
+
+ protected void execute(IProgressMonitor monitor)
+ throws CoreException, InterruptedException {
+ diagram = UMLDiagramEditorUtil.createDiagram(
+ diagramModelFilePage.getURI(),
+ domainModelFilePage.getURI(), monitor);
+ if (isOpenNewlyCreatedDiagramEditor() && diagram != null) {
+ try {
+ UMLDiagramEditorUtil.openDiagram(diagram);
+ } catch (PartInitException e) {
+ ErrorDialog.openError(getContainer().getShell(),
+ Messages.UMLCreationWizardOpenEditorError,
+ null, e.getStatus());
+ }
+ }
+ }
+ };
+ try {
+ getContainer().run(false, true, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ if (e.getTargetException() instanceof CoreException) {
+ ErrorDialog.openError(getContainer().getShell(),
+ Messages.UMLCreationWizardCreationError, null,
+ ((CoreException) e.getTargetException()).getStatus());
+ } else {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Error creating diagram", e.getTargetException()); //$NON-NLS-1$
+ }
+ return false;
+ }
+ return diagram != null;
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLCreationWizardPage.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLCreationWizardPage.java
new file mode 100644
index 00000000000..cd8e8a17270
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLCreationWizardPage.java
@@ -0,0 +1,87 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+/**
+ * @generated
+ */
+public class UMLCreationWizardPage extends WizardNewFileCreationPage {
+
+ /**
+ * @generated
+ */
+ private final String fileExtension;
+
+ /**
+ * @generated
+ */
+ public UMLCreationWizardPage(String pageName,
+ IStructuredSelection selection, String fileExtension) {
+ super(pageName, selection);
+ this.fileExtension = fileExtension;
+ }
+
+ /**
+ * Override to create files with this extension.
+ *
+ * @generated
+ */
+ protected String getExtension() {
+ return fileExtension;
+ }
+
+ /**
+ * @generated
+ */
+ public URI getURI() {
+ return URI.createPlatformResourceURI(getFilePath().toString(), false);
+ }
+
+ /**
+ * @generated
+ */
+ protected IPath getFilePath() {
+ IPath path = getContainerFullPath();
+ if (path == null) {
+ path = new Path(""); //$NON-NLS-1$
+ }
+ String fileName = getFileName();
+ if (fileName != null) {
+ path = path.append(fileName);
+ }
+ return path;
+ }
+
+ /**
+ * @generated
+ */
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ setFileName(UMLDiagramEditorUtil.getUniqueFileName(
+ getContainerFullPath(), getFileName(), getExtension()));
+ setPageComplete(validatePage());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean validatePage() {
+ if (!super.validatePage()) {
+ return false;
+ }
+ String extension = getExtension();
+ if (extension != null
+ && !getFilePath().toString().endsWith("." + extension)) {
+ setErrorMessage(NLS.bind(
+ Messages.UMLCreationWizardPageExtensionError, extension));
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramActionBarContributor.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramActionBarContributor.java
new file mode 100644
index 00000000000..1088c2d01d9
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramActionBarContributor.java
@@ -0,0 +1,39 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramActionBarContributor;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * @generated
+ */
+public class UMLDiagramActionBarContributor extends DiagramActionBarContributor {
+
+ /**
+ * @generated
+ */
+ protected Class getEditorClass() {
+ return UMLDiagramEditor.class;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getEditorId() {
+ return UMLDiagramEditor.ID;
+ }
+
+ /**
+ * @generated
+ */
+ public void init(IActionBars bars, IWorkbenchPage page) {
+ super.init(bars, page);
+ // print preview
+ IMenuManager fileMenu = bars.getMenuManager().findMenuUsingPath(
+ IWorkbenchActionConstants.M_FILE);
+ assert fileMenu != null;
+ fileMenu.remove("pageSetupAction"); //$NON-NLS-1$
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditor.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditor.java
new file mode 100644
index 00000000000..5eb9655bd73
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditor.java
@@ -0,0 +1,540 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import java.util.EventObject;
+
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.KeyHandler;
+import org.eclipse.gef.Tool;
+import org.eclipse.gef.commands.CommandStackListener;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.ui.palette.PaletteViewer;
+import org.eclipse.gef.ui.palette.PaletteViewerProvider;
+import org.eclipse.gmf.runtime.common.core.service.IProviderChangeListener;
+import org.eclipse.gmf.runtime.common.core.service.ProviderChangeEvent;
+import org.eclipse.gmf.runtime.common.ui.services.marker.MarkerNavigationService;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
+import org.eclipse.gmf.runtime.diagram.ui.internal.parts.PaletteToolTransferDragSourceListener;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.core.adaptor.gmf.GmfMultiDiagramDocumentProvider;
+import org.eclipse.papyrus.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.core.services.ServicesRegistry;
+import org.eclipse.papyrus.diagram.common.listeners.DropTargetListener;
+import org.eclipse.papyrus.diagram.common.part.PapyrusPaletteContextMenuProvider;
+import org.eclipse.papyrus.diagram.common.part.PapyrusPaletteViewer;
+import org.eclipse.papyrus.diagram.common.part.UmlGmfDiagramEditor;
+import org.eclipse.papyrus.diagram.common.service.PapyrusPaletteService;
+import org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.ide.IGotoMarker;
+import org.eclipse.ui.navigator.resources.ProjectExplorer;
+import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.part.ShowInContext;
+
+/**
+ * @generated
+ */
+public class UMLDiagramEditor extends UmlGmfDiagramEditor implements
+ IProviderChangeListener, IGotoMarker {
+
+ /**
+ * @generated
+ */
+ public static final String ID = "org.eclipse.papyrus.diagram.newdiagram.part.UMLDiagramEditorID"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final String CONTEXT_ID = "org.eclipse.papyrus.diagram.newdiagram.ui.diagramContext"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ private KeyHandler paletteKeyHandler = null;
+
+ /**
+ * @generated
+ */
+ private MouseListener paletteMouseListener = null;
+
+ /**
+ * @generated
+ */
+ private IUndoableOperation savedOperation = null;
+
+ /**
+ * @generated
+ */
+ private TransactionalEditingDomain editingDomain;
+
+ /**
+ * @generated
+ */
+ private IDocumentProvider documentProvider;
+
+ /**
+ * @generated
+ */
+ public UMLDiagramEditor(ServicesRegistry servicesRegistry, Diagram diagram)
+ throws ServiceException {
+ super(servicesRegistry, diagram);
+
+ // adds a listener to the palette service, which reacts to palette customizations
+ PapyrusPaletteService.getInstance().addProviderChangeListener(this);
+
+ // Share the same editing provider
+ editingDomain = servicesRegistry
+ .getService(TransactionalEditingDomain.class);
+ documentProvider = new GmfMultiDiagramDocumentProvider(editingDomain);
+
+ // overrides editing domain created by super constructor
+ setDocumentProvider(documentProvider);
+
+ }
+
+ /**
+ * @generated
+ */
+ protected String getContextID() {
+ return CONTEXT_ID;
+ }
+
+ /**
+ * @generated
+ */
+ protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) {
+ PaletteRoot paletteRoot;
+ if (existingPaletteRoot == null) {
+ paletteRoot = PapyrusPaletteService.getInstance().createPalette(
+ this, getDefaultPaletteContent());
+ } else {
+ PapyrusPaletteService.getInstance().updatePalette(
+ existingPaletteRoot, this, getDefaultPaletteContent());
+ paletteRoot = existingPaletteRoot;
+ }
+ applyCustomizationsToPalette(paletteRoot);
+ return paletteRoot;
+ }
+
+ /**
+ * @generated
+ */
+ protected PreferencesHint getPreferencesHint() {
+ return UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT;
+ }
+
+ /**
+ * @generated
+ */
+ public String getContributorId() {
+ return UMLDiagramEditorPlugin.ID;
+ }
+
+ /**
+ * @generated
+ */
+ public Object getAdapter(Class type) {
+ if (type == IShowInTargetList.class) {
+ return new IShowInTargetList() {
+ public String[] getShowInTargetIds() {
+ return new String[] { ProjectExplorer.VIEW_ID };
+ }
+ };
+ }
+ return super.getAdapter(type);
+ }
+
+ /**
+ * @generated
+ */
+ protected final IDocumentProvider getDocumentProvider(IEditorInput input) {
+ return documentProvider;
+ }
+
+ /**
+ * @generated
+ */
+ public TransactionalEditingDomain getEditingDomain() {
+ return editingDomain;
+ }
+
+ /**
+ * @generated
+ */
+ protected final void setDocumentProvider(IEditorInput input) {
+ // Already set in the constructor
+ }
+
+ /**
+ * @generated
+ */
+ public void gotoMarker(IMarker marker) {
+ MarkerNavigationService.getInstance().gotoMarker(this, marker);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ public void doSaveAs() {
+ performSaveAs(new NullProgressMonitor());
+ }
+
+ /**
+ * @generated
+ */
+ protected void performSaveAs(IProgressMonitor progressMonitor) {
+ // Nothing
+ }
+
+ /**
+ * @generated
+ */
+ public ShowInContext getShowInContext() {
+ return new ShowInContext(getEditorInput(), getNavigatorSelection());
+ }
+
+ /**
+ * @generated
+ */
+ private ISelection getNavigatorSelection() {
+ IDiagramDocument document = getDiagramDocument();
+ if (document == null) {
+ return StructuredSelection.EMPTY;
+ }
+ Diagram diagram = document.getDiagram();
+ IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
+ if (file != null) {
+ UMLNavigatorItem item = new UMLNavigatorItem(diagram, file, false);
+ return new StructuredSelection(item);
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ /**
+ * @generated
+ */
+ protected void configureGraphicalViewer() {
+ super.configureGraphicalViewer();
+ DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(
+ this, getDiagramGraphicalViewer());
+ getDiagramGraphicalViewer().setContextMenu(provider);
+ getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU,
+ provider, getDiagramGraphicalViewer());
+ }
+
+ /**
+ * @generated
+ */
+ protected TransactionalEditingDomain createEditingDomain() {
+ // Already configured
+ return editingDomain;
+ }
+
+ /**
+ * @generated
+ */
+ protected void configureDiagramEditDomain() {
+ super.configureDiagramEditDomain();
+ getDiagramEditDomain().getDiagramCommandStack()
+ .addCommandStackListener(new CommandStackListener() {
+
+ public void commandStackChanged(EventObject event) {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ public void doSave(IProgressMonitor progressMonitor) {
+ // The saving of the resource is done by the CoreMultiDiagramEditor
+ savedOperation = getOperationHistory().getUndoOperation(
+ getUndoContext());
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isDirty() {
+ IUndoableOperation op = getOperationHistory().getUndoOperation(
+ getUndoContext());
+ return savedOperation != op;
+ }
+
+ /**
+ * @generated
+ */
+ public void providerChanged(ProviderChangeEvent event) {
+ // update the palette if the palette service has changed
+ if (PapyrusPaletteService.getInstance().equals(event.getSource())) {
+ PapyrusPaletteService.getInstance().updatePalette(
+ getPaletteViewer().getPaletteRoot(), this,
+ getDefaultPaletteContent());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ // remove palette service listener
+ // remove preference listener
+ PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+
+ super.dispose();
+ }
+
+ /**
+ * @generated
+ */
+ protected PaletteViewer getPaletteViewer() {
+ return getEditDomain().getPaletteViewer();
+ }
+
+ /**
+ * @generated
+ */
+ protected PaletteViewer constructPaletteViewer() {
+ return new PapyrusPaletteViewer();
+ }
+
+ /**
+ * @generated
+ */
+ protected PaletteViewerProvider createPaletteViewerProvider() {
+ getEditDomain().setPaletteRoot(createPaletteRoot(null));
+ return new PaletteViewerProvider(getEditDomain()) {
+
+ /**
+ * Override to provide the additional behavior for the tools. Will intialize with a
+ * PaletteEditPartFactory that has a TrackDragger that understand how to handle the
+ * mouseDoubleClick event for shape creation tools. Also will initialize the palette
+ * with a defaultTool that is the SelectToolEx that undestands how to handle the enter
+ * key which will result in the creation of the shape also.
+ */
+ protected void configurePaletteViewer(PaletteViewer viewer) {
+ super.configurePaletteViewer(viewer);
+
+ // customize menu...
+ viewer.setContextMenu(new PapyrusPaletteContextMenuProvider(
+ viewer));
+
+ viewer.getKeyHandler().setParent(getPaletteKeyHandler());
+ viewer.getControl().addMouseListener(getPaletteMouseListener());
+
+ // Add a transfer drag target listener that is supported on
+ // palette template entries whose template is a creation tool.
+ // This will enable drag and drop of the palette shape creation
+ // tools.
+ viewer.addDragSourceListener(new PaletteToolTransferDragSourceListener(
+ viewer));
+ viewer.setCustomizer(createPaletteCustomizer());
+ }
+
+ public PaletteViewer createPaletteViewer(Composite parent) {
+ PaletteViewer pViewer = constructPaletteViewer();
+ pViewer.createControl(parent);
+ configurePaletteViewer(pViewer);
+ hookPaletteViewer(pViewer);
+ return pViewer;
+ }
+
+ /**
+ * @return Palette Key Handler for the palette
+ */
+ private KeyHandler getPaletteKeyHandler() {
+
+ if (paletteKeyHandler == null) {
+
+ paletteKeyHandler = new KeyHandler() {
+
+ /**
+ * Processes a <i>key released </i> event. This method is called by the Tool
+ * whenever a key is released, and the Tool is in the proper state. Override
+ * to support pressing the enter key to create a shape or connection
+ * (between two selected shapes)
+ *
+ * @param event
+ * the KeyEvent
+ * @return <code>true</code> if KeyEvent was handled in some way
+ */
+ public boolean keyReleased(KeyEvent event) {
+
+ if (event.keyCode == SWT.Selection) {
+
+ Tool tool = getPaletteViewer().getActiveTool()
+ .createTool();
+
+ if (toolSupportsAccessibility(tool)) {
+
+ tool.keyUp(event,
+ getDiagramGraphicalViewer());
+
+ // deactivate current selection
+ getPaletteViewer().setActiveTool(null);
+
+ return true;
+ }
+
+ }
+ return super.keyReleased(event);
+ }
+
+ };
+
+ }
+ return paletteKeyHandler;
+ }
+
+ /**
+ * @return Palette Mouse listener for the palette
+ */
+ private MouseListener getPaletteMouseListener() {
+
+ if (paletteMouseListener == null) {
+
+ paletteMouseListener = new MouseListener() {
+
+ /**
+ * Flag to indicate that the current active tool should be cleared after a
+ * mouse double-click event.
+ */
+ private boolean clearActiveTool = false;
+
+ /**
+ * Override to support double-clicking a palette tool entry to create a
+ * shape or connection (between two selected shapes).
+ *
+ * @see MouseListener#mouseDoubleClick(MouseEvent)
+ */
+ public void mouseDoubleClick(MouseEvent e) {
+ Tool tool = getPaletteViewer().getActiveTool()
+ .createTool();
+
+ if (toolSupportsAccessibility(tool)) {
+
+ tool.setViewer(getDiagramGraphicalViewer());
+ tool.setEditDomain(getDiagramGraphicalViewer()
+ .getEditDomain());
+ tool.mouseDoubleClick(e,
+ getDiagramGraphicalViewer());
+
+ // Current active tool should be deactivated,
+ // but if it is down here it will get
+ // reactivated deep in GEF palette code after
+ // receiving mouse up events.
+ clearActiveTool = true;
+ }
+ }
+
+ public void mouseDown(MouseEvent e) {
+ // do nothing
+ }
+
+ public void mouseUp(MouseEvent e) {
+ // Deactivate current active tool here if a
+ // double-click was handled.
+ if (clearActiveTool) {
+ getPaletteViewer().setActiveTool(null);
+ clearActiveTool = false;
+ }
+
+ }
+ };
+
+ }
+ return paletteMouseListener;
+ }
+
+ };
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public GraphicalViewer getGraphicalViewer() {
+ return super.getGraphicalViewer();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void initializeGraphicalViewer() {
+ super.initializeGraphicalViewer();
+
+ // Enable Drop
+ getDiagramGraphicalViewer().addDropTargetListener(
+ new DropTargetListener(getDiagramGraphicalViewer(),
+ LocalSelectionTransfer.getTransfer()) {
+
+ @Override
+ protected Object getJavaObject(TransferData data) {
+ return LocalSelectionTransfer.getTransfer()
+ .nativeToJava(data);
+ }
+
+ @Override
+ protected TransactionalEditingDomain getTransactionalEditingDomain() {
+ return getEditingDomain();
+ }
+ });
+
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (getSite().getPage().getActiveEditor() instanceof IMultiDiagramEditor) {
+ IMultiDiagramEditor editor = (IMultiDiagramEditor) getSite()
+ .getPage().getActiveEditor();
+ // If not the active editor, ignore selection changed.
+ if (this.equals(editor.getActiveEditor())) {
+ updateActions(getSelectionActions());
+ super.selectionChanged(part, selection);
+ } else {
+ super.selectionChanged(part, selection);
+ }
+ } else {
+ super.selectionChanged(part, selection);
+ }
+ // from
+ // org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.selectionChanged(IWorkbenchPart,
+ // ISelection)
+ if (part == this) {
+ rebuildStatusLine();
+ }
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditorPlugin.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditorPlugin.java
new file mode 100644
index 00000000000..1596fcc0732
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditorPlugin.java
@@ -0,0 +1,284 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.example.diagram.simplediagram.preferences.DiagramPreferenceInitializer;
+import org.eclipse.papyrus.example.diagram.simplediagram.providers.ElementInitializers;
+import org.eclipse.papyrus.preferences.Activator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @generated
+ */
+public class UMLDiagramEditorPlugin extends AbstractUIPlugin {
+
+ /**
+ * @generated
+ */
+ public static final String ID = "org.eclipse.uml2.uml.diagram"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final PreferencesHint DIAGRAM_PREFERENCES_HINT = new PreferencesHint(
+ ID);
+
+ /**
+ * @generated
+ */
+ private static UMLDiagramEditorPlugin instance;
+
+ /**
+ * @generated
+ */
+ private ComposedAdapterFactory adapterFactory;
+
+ /**
+ * @generated
+ */
+ private UMLDocumentProvider documentProvider;
+
+ /**
+ * @generated
+ */
+ private ElementInitializers initializers;
+
+ /**
+ * @generated
+ */
+ public UMLDiagramEditorPlugin() {
+ }
+
+ /**
+ * @generated
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ instance = this;
+ PreferencesHint.registerPreferenceStore(DIAGRAM_PREFERENCES_HINT,
+ getPreferenceStore());
+ adapterFactory = createAdapterFactory();
+ DiagramPreferenceInitializer diagramPreferenceInitializer = new DiagramPreferenceInitializer();
+ diagramPreferenceInitializer.initializeDefaultPreferences();
+ }
+
+ /**
+ * @generated
+ */
+ public void stop(BundleContext context) throws Exception {
+ adapterFactory.dispose();
+ adapterFactory = null;
+ initializers = null;
+ instance = null;
+ super.stop(context);
+ }
+
+ /**
+ * @generated
+ */
+ public static UMLDiagramEditorPlugin getInstance() {
+ return instance;
+ }
+
+ /**
+ * @generated
+ */
+ public IPreferenceStore getPreferenceStore() {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ return store;
+ }
+
+ /**
+ * @generated
+ */
+ protected ComposedAdapterFactory createAdapterFactory() {
+ ArrayList<AdapterFactory> factories = new ArrayList<AdapterFactory>();
+ fillItemProviderFactories(factories);
+ return new ComposedAdapterFactory(factories);
+ }
+
+ /**
+ * @generated
+ */
+ protected void fillItemProviderFactories(List<AdapterFactory> factories) {
+ factories.add(new UMLItemProviderAdapterFactory());
+ factories.add(new EcoreItemProviderAdapterFactory());
+ factories.add(new ResourceItemProviderAdapterFactory());
+ factories.add(new ReflectiveItemProviderAdapterFactory());
+ }
+
+ /**
+ * @generated
+ */
+ public AdapterFactory getItemProvidersAdapterFactory() {
+ return adapterFactory;
+ }
+
+ /**
+ * @generated
+ */
+ public ImageDescriptor getItemImageDescriptor(Object item) {
+ IItemLabelProvider labelProvider = (IItemLabelProvider) adapterFactory
+ .adapt(item, IItemLabelProvider.class);
+ if (labelProvider != null) {
+ return ExtendedImageRegistry.getInstance().getImageDescriptor(
+ labelProvider.getImage(item));
+ }
+ return null;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ *
+ * @generated
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getBundledImageDescriptor(String path) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path);
+ }
+
+ /**
+ * Respects images residing in any plug-in. If path is relative,
+ * then this bundle is looked up for the image, otherwise, for absolute
+ * path, first segment is taken as id of plug-in with image
+ *
+ * @generated
+ * @param path the path to image, either absolute (with plug-in id as first segment), or relative for bundled images
+ * @return the image descriptor
+ */
+ public static ImageDescriptor findImageDescriptor(String path) {
+ final IPath p = new Path(path);
+ if (p.isAbsolute() && p.segmentCount() > 1) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin(p.segment(0), p
+ .removeFirstSegments(1).makeAbsolute().toString());
+ } else {
+ return getBundledImageDescriptor(p.makeAbsolute().toString());
+ }
+ }
+
+ /**
+ * Returns an image for the image file at the given plug-in relative path.
+ * Client do not need to dispose this image. Images will be disposed automatically.
+ *
+ * @generated
+ * @param path the path
+ * @return image instance
+ */
+ public Image getBundledImage(String path) {
+ Image image = getImageRegistry().get(path);
+ if (image == null) {
+ getImageRegistry().put(path, getBundledImageDescriptor(path));
+ image = getImageRegistry().get(path);
+ }
+ return image;
+ }
+
+ /**
+ * Returns string from plug-in's resource bundle
+ *
+ * @generated
+ */
+ public static String getString(String key) {
+ return Platform.getResourceString(getInstance().getBundle(), "%" + key); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ public UMLDocumentProvider getDocumentProvider() {
+ if (documentProvider == null) {
+ documentProvider = new UMLDocumentProvider();
+ }
+ return documentProvider;
+ }
+
+ /**
+ * @generated
+ */
+ public ElementInitializers getElementInitializers() {
+ return initializers;
+ }
+
+ /**
+ * @generated
+ */
+ public void setElementInitializers(ElementInitializers i) {
+ this.initializers = i;
+ }
+
+ /**
+ * @generated
+ */
+ public void logError(String error) {
+ logError(error, null);
+ }
+
+ /**
+ * @generated
+ */
+ public void logError(String error, Throwable throwable) {
+ if (error == null && throwable != null) {
+ error = throwable.getMessage();
+ }
+ getLog().log(
+ new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID,
+ IStatus.OK, error, throwable));
+ debug(error, throwable);
+ }
+
+ /**
+ * @generated
+ */
+ public void logInfo(String message) {
+ logInfo(message, null);
+ }
+
+ /**
+ * @generated
+ */
+ public void logInfo(String message, Throwable throwable) {
+ if (message == null && throwable != null) {
+ message = throwable.getMessage();
+ }
+ getLog().log(
+ new Status(IStatus.INFO, UMLDiagramEditorPlugin.ID, IStatus.OK,
+ message, throwable));
+ debug(message, throwable);
+ }
+
+ /**
+ * @generated
+ */
+ private void debug(String message, Throwable throwable) {
+ if (!isDebugging()) {
+ return;
+ }
+ if (message != null) {
+ System.err.println(message);
+ }
+ if (throwable != null) {
+ throwable.printStackTrace();
+ }
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditorUtil.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditorUtil.java
new file mode 100644
index 00000000000..821ce202a75
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramEditorUtil.java
@@ -0,0 +1,415 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * @generated
+ */
+public class UMLDiagramEditorUtil {
+
+ /**
+ * @generated
+ */
+ public static Map<?, ?> getSaveOptions() {
+ HashMap<String, Object> saveOptions = new HashMap<String, Object>();
+ saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
+ saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED,
+ Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+ return saveOptions;
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean openDiagram(Resource diagram)
+ throws PartInitException {
+ String path = diagram.getURI().toPlatformString(true);
+ IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(new Path(path));
+ if (workspaceResource instanceof IFile) {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ return null != page.openEditor(new FileEditorInput(
+ (IFile) workspaceResource), UMLDiagramEditor.ID);
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public static void setCharset(IFile file) {
+ if (file == null) {
+ return;
+ }
+ try {
+ file.setCharset("UTF-8", new NullProgressMonitor()); //$NON-NLS-1$
+ } catch (CoreException e) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Unable to set charset for file " + file.getFullPath(), e); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public static String getUniqueFileName(IPath containerFullPath,
+ String fileName, String extension) {
+ if (containerFullPath == null) {
+ containerFullPath = new Path(""); //$NON-NLS-1$
+ }
+ if (fileName == null || fileName.trim().length() == 0) {
+ fileName = "default"; //$NON-NLS-1$
+ }
+ IPath filePath = containerFullPath.append(fileName);
+ if (extension != null && !extension.equals(filePath.getFileExtension())) {
+ filePath = filePath.addFileExtension(extension);
+ }
+ extension = filePath.getFileExtension();
+ fileName = filePath.removeFileExtension().lastSegment();
+ int i = 1;
+ while (ResourcesPlugin.getWorkspace().getRoot().exists(filePath)) {
+ i++;
+ filePath = containerFullPath.append(fileName + i);
+ if (extension != null) {
+ filePath = filePath.addFileExtension(extension);
+ }
+ }
+ return filePath.lastSegment();
+ }
+
+ /**
+ * Runs the wizard in a dialog.
+ *
+ * @generated
+ */
+ public static void runWizard(Shell shell, Wizard wizard, String settingsKey) {
+ IDialogSettings pluginDialogSettings = UMLDiagramEditorPlugin
+ .getInstance().getDialogSettings();
+ IDialogSettings wizardDialogSettings = pluginDialogSettings
+ .getSection(settingsKey);
+ if (wizardDialogSettings == null) {
+ wizardDialogSettings = pluginDialogSettings
+ .addNewSection(settingsKey);
+ }
+ wizard.setDialogSettings(wizardDialogSettings);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.create();
+ dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x),
+ 500);
+ dialog.open();
+ }
+
+ /**
+ * This method should be called within a workspace modify operation since it creates resources.
+ * @generated
+ */
+ public static Resource createDiagram(URI diagramURI, URI modelURI,
+ IProgressMonitor progressMonitor) {
+ TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE
+ .createEditingDomain();
+ progressMonitor.beginTask(
+ Messages.UMLDiagramEditorUtil_CreateDiagramProgressTask, 3);
+ final Resource diagramResource = editingDomain.getResourceSet()
+ .createResource(diagramURI);
+ final Resource modelResource = editingDomain.getResourceSet()
+ .createResource(modelURI);
+ final String diagramName = diagramURI.lastSegment();
+ AbstractTransactionalCommand command = new AbstractTransactionalCommand(
+ editingDomain,
+ Messages.UMLDiagramEditorUtil_CreateDiagramCommandLabel,
+ Collections.EMPTY_LIST) {
+ protected CommandResult doExecuteWithResult(
+ IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ Model model = createInitialModel();
+ attachModelToResource(model, modelResource);
+
+ Diagram diagram = ViewService.createDiagram(model,
+ ModelEditPart.MODEL_ID,
+ UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
+ if (diagram != null) {
+ diagramResource.getContents().add(diagram);
+ diagram.setName(diagramName);
+ diagram.setElement(model);
+ }
+
+ try {
+ modelResource
+ .save(org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorUtil
+ .getSaveOptions());
+ diagramResource
+ .save(org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorUtil
+ .getSaveOptions());
+ } catch (IOException e) {
+
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Unable to store model and diagram resources", e); //$NON-NLS-1$
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ try {
+ OperationHistoryFactory.getOperationHistory().execute(command,
+ new SubProgressMonitor(progressMonitor, 1), null);
+ } catch (ExecutionException e) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Unable to create model and diagram", e); //$NON-NLS-1$
+ }
+ setCharset(WorkspaceSynchronizer.getFile(modelResource));
+ setCharset(WorkspaceSynchronizer.getFile(diagramResource));
+ return diagramResource;
+ }
+
+ /**
+ * Create a new instance of domain element associated with canvas.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static Model createInitialModel() {
+ return UMLFactory.eINSTANCE.createModel();
+ }
+
+ /**
+ * Store model element in the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static void attachModelToResource(Model model, Resource resource) {
+ resource.getContents().add(model);
+ }
+
+ /**
+ * @generated
+ */
+ public static void selectElementsInDiagram(
+ IDiagramWorkbenchPart diagramPart, List<EditPart> editParts) {
+ diagramPart.getDiagramGraphicalViewer().deselectAll();
+
+ EditPart firstPrimary = null;
+ for (EditPart nextPart : editParts) {
+ diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart);
+ if (firstPrimary == null && nextPart instanceof IPrimaryEditPart) {
+ firstPrimary = nextPart;
+ }
+ }
+
+ if (!editParts.isEmpty()) {
+ diagramPart.getDiagramGraphicalViewer().reveal(
+ firstPrimary != null ? firstPrimary : (EditPart) editParts
+ .get(0));
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private static int findElementsInDiagramByID(DiagramEditPart diagramPart,
+ EObject element, List<EditPart> editPartCollector) {
+ IDiagramGraphicalViewer viewer = (IDiagramGraphicalViewer) diagramPart
+ .getViewer();
+ final int intialNumOfEditParts = editPartCollector.size();
+
+ if (element instanceof View) { // support notation element lookup
+ EditPart editPart = (EditPart) viewer.getEditPartRegistry().get(
+ element);
+ if (editPart != null) {
+ editPartCollector.add(editPart);
+ return 1;
+ }
+ }
+
+ String elementID = EMFCoreUtil.getProxyID(element);
+ @SuppressWarnings("unchecked")
+ List<EditPart> associatedParts = viewer.findEditPartsForElement(
+ elementID, IGraphicalEditPart.class);
+ // perform the possible hierarchy disjoint -> take the top-most parts only
+ for (EditPart nextPart : associatedParts) {
+ EditPart parentPart = nextPart.getParent();
+ while (parentPart != null && !associatedParts.contains(parentPart)) {
+ parentPart = parentPart.getParent();
+ }
+ if (parentPart == null) {
+ editPartCollector.add(nextPart);
+ }
+ }
+
+ if (intialNumOfEditParts == editPartCollector.size()) {
+ if (!associatedParts.isEmpty()) {
+ editPartCollector.add(associatedParts.get(0));
+ } else {
+ if (element.eContainer() != null) {
+ return findElementsInDiagramByID(diagramPart,
+ element.eContainer(), editPartCollector);
+ }
+ }
+ }
+ return editPartCollector.size() - intialNumOfEditParts;
+ }
+
+ /**
+ * @generated
+ */
+ public static View findView(DiagramEditPart diagramEditPart,
+ EObject targetElement, LazyElement2ViewMap lazyElement2ViewMap) {
+ boolean hasStructuralURI = false;
+ if (targetElement.eResource() instanceof XMLResource) {
+ hasStructuralURI = ((XMLResource) targetElement.eResource())
+ .getID(targetElement) == null;
+ }
+
+ View view = null;
+ LinkedList<EditPart> editPartHolder = new LinkedList<EditPart>();
+ if (hasStructuralURI
+ && !lazyElement2ViewMap.getElement2ViewMap().isEmpty()) {
+ view = lazyElement2ViewMap.getElement2ViewMap().get(targetElement);
+ } else if (findElementsInDiagramByID(diagramEditPart, targetElement,
+ editPartHolder) > 0) {
+ EditPart editPart = editPartHolder.get(0);
+ view = editPart.getModel() instanceof View ? (View) editPart
+ .getModel() : null;
+ }
+
+ return (view == null) ? diagramEditPart.getDiagramView() : view;
+ }
+
+ /**
+ * XXX This is quite suspicious code (especially editPartTmpHolder) and likely to be removed soon
+ * @generated
+ */
+ public static class LazyElement2ViewMap {
+ /**
+ * @generated
+ */
+ private Map<EObject, View> element2ViewMap;
+
+ /**
+ * @generated
+ */
+ private View scope;
+
+ /**
+ * @generated
+ */
+ private Set<? extends EObject> elementSet;
+
+ /**
+ * @generated
+ */
+ public LazyElement2ViewMap(View scope, Set<? extends EObject> elements) {
+ this.scope = scope;
+ this.elementSet = elements;
+ }
+
+ /**
+ * @generated
+ */
+ public final Map<EObject, View> getElement2ViewMap() {
+ if (element2ViewMap == null) {
+ element2ViewMap = new HashMap<EObject, View>();
+ // map possible notation elements to itself as these can't be found by view.getElement()
+ for (EObject element : elementSet) {
+ if (element instanceof View) {
+ View view = (View) element;
+ if (view.getDiagram() == scope.getDiagram()) {
+ element2ViewMap.put(element, view); // take only those that part of our diagram
+ }
+ }
+ }
+
+ buildElement2ViewMap(scope, element2ViewMap, elementSet);
+ }
+ return element2ViewMap;
+ }
+
+ /**
+ * @generated
+ */
+ private static boolean buildElement2ViewMap(View parentView,
+ Map<EObject, View> element2ViewMap,
+ Set<? extends EObject> elements) {
+ if (elements.size() == element2ViewMap.size()) {
+ return true;
+ }
+
+ if (parentView.isSetElement()
+ && !element2ViewMap.containsKey(parentView.getElement())
+ && elements.contains(parentView.getElement())) {
+ element2ViewMap.put(parentView.getElement(), parentView);
+ if (elements.size() == element2ViewMap.size()) {
+ return true;
+ }
+ }
+ boolean complete = false;
+ for (Iterator<?> it = parentView.getChildren().iterator(); it
+ .hasNext() && !complete;) {
+ complete = buildElement2ViewMap((View) it.next(),
+ element2ViewMap, elements);
+ }
+ for (Iterator<?> it = parentView.getSourceEdges().iterator(); it
+ .hasNext() && !complete;) {
+ complete = buildElement2ViewMap((View) it.next(),
+ element2ViewMap, elements);
+ }
+ for (Iterator<?> it = parentView.getTargetEdges().iterator(); it
+ .hasNext() && !complete;) {
+ complete = buildElement2ViewMap((View) it.next(),
+ element2ViewMap, elements);
+ }
+ return complete;
+ }
+ } //LazyElement2ViewMap
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramUpdateCommand.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramUpdateCommand.java
new file mode 100644
index 00000000000..58a23387d93
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramUpdateCommand.java
@@ -0,0 +1,85 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @generated
+ */
+public class UMLDiagramUpdateCommand implements IHandler {
+
+ /**
+ * @generated
+ */
+ public void addHandlerListener(IHandlerListener handlerListener) {
+ }
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ }
+
+ /**
+ * @generated
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getSelectionService()
+ .getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ if (structuredSelection.size() != 1) {
+ return null;
+ }
+ if (structuredSelection.getFirstElement() instanceof EditPart
+ && ((EditPart) structuredSelection.getFirstElement())
+ .getModel() instanceof View) {
+ EObject modelElement = ((View) ((EditPart) structuredSelection
+ .getFirstElement()).getModel()).getElement();
+ List editPolicies = CanonicalEditPolicy
+ .getRegisteredEditPolicies(modelElement);
+ for (Iterator it = editPolicies.iterator(); it.hasNext();) {
+ CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy) it
+ .next();
+ nextEditPolicy.refresh();
+ }
+
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isEnabled() {
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isHandled() {
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ public void removeHandlerListener(IHandlerListener handlerListener) {
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramUpdater.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramUpdater.java
new file mode 100644
index 00000000000..be72a27ae6b
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDiagramUpdater.java
@@ -0,0 +1,119 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.PackageableElement;
+
+/**
+ * @generated
+ */
+public class UMLDiagramUpdater {
+
+ /**
+ * @generated
+ */
+ public static List<UMLNodeDescriptor> getSemanticChildren(View view) {
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ case ModelEditPart.VISUAL_ID:
+ return getModel_1000SemanticChildren(view);
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public static List<UMLNodeDescriptor> getModel_1000SemanticChildren(
+ View view) {
+ if (!view.isSetElement()) {
+ return Collections.EMPTY_LIST;
+ }
+ Model modelElement = (Model) view.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getPackagedElements().iterator(); it
+ .hasNext();) {
+ PackageableElement childElement = (PackageableElement) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view,
+ childElement);
+ if (visualID == ComponentEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public static List<UMLLinkDescriptor> getContainedLinks(View view) {
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ case ModelEditPart.VISUAL_ID:
+ return getModel_1000ContainedLinks(view);
+ case ComponentEditPart.VISUAL_ID:
+ return getComponent_2001ContainedLinks(view);
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public static List<UMLLinkDescriptor> getIncomingLinks(View view) {
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ case ComponentEditPart.VISUAL_ID:
+ return getComponent_2001IncomingLinks(view);
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public static List<UMLLinkDescriptor> getOutgoingLinks(View view) {
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ case ComponentEditPart.VISUAL_ID:
+ return getComponent_2001OutgoingLinks(view);
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public static List<UMLLinkDescriptor> getModel_1000ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public static List<UMLLinkDescriptor> getComponent_2001ContainedLinks(
+ View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public static List<UMLLinkDescriptor> getComponent_2001IncomingLinks(
+ View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public static List<UMLLinkDescriptor> getComponent_2001OutgoingLinks(
+ View view) {
+ return Collections.emptyList();
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDocumentProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDocumentProvider.java
new file mode 100644
index 00000000000..b35c429b2d1
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLDocumentProvider.java
@@ -0,0 +1,1124 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.MultiRule;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.transaction.NotificationFilter;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocumentProvider;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.EditorStatusCodes;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.util.DiagramIOUtil;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * @generated
+ */
+public class UMLDocumentProvider extends AbstractDocumentProvider implements
+ IDiagramDocumentProvider {
+
+ /**
+ * @generated
+ */
+ protected ElementInfo createElementInfo(Object element)
+ throws CoreException {
+ if (false == element instanceof FileEditorInput
+ && false == element instanceof URIEditorInput) {
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ UMLDiagramEditorPlugin.ID,
+ 0,
+ NLS.bind(
+ Messages.UMLDocumentProvider_IncorrectInputError,
+ new Object[] {
+ element,
+ "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
+ null));
+ }
+ IEditorInput editorInput = (IEditorInput) element;
+ IDiagramDocument document = (IDiagramDocument) createDocument(editorInput);
+
+ ResourceSetInfo info = new ResourceSetInfo(document, editorInput);
+ info.setModificationStamp(computeModificationStamp(info));
+ info.fStatus = null;
+ return info;
+ }
+
+ /**
+ * @generated
+ */
+ protected IDocument createDocument(Object element) throws CoreException {
+ if (false == element instanceof FileEditorInput
+ && false == element instanceof URIEditorInput) {
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ UMLDiagramEditorPlugin.ID,
+ 0,
+ NLS.bind(
+ Messages.UMLDocumentProvider_IncorrectInputError,
+ new Object[] {
+ element,
+ "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
+ null));
+ }
+ IDocument document = createEmptyDocument();
+ setDocumentContent(document, (IEditorInput) element);
+ setupDocument(element, document);
+ return document;
+ }
+
+ /**
+ * Sets up the given document as it would be provided for the given element. The
+ * content of the document is not changed. This default implementation is empty.
+ * Subclasses may reimplement.
+ *
+ * @param element the blue-print element
+ * @param document the document to set up
+ * @generated
+ */
+ protected void setupDocument(Object element, IDocument document) {
+ // for subclasses
+ }
+
+ /**
+ * @generated
+ */
+ private long computeModificationStamp(ResourceSetInfo info) {
+ int result = 0;
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
+ .hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ if (file.getLocation() != null) {
+ result += file.getLocation().toFile().lastModified();
+ } else {
+ result += file.getModificationStamp();
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected IDocument createEmptyDocument() {
+ DiagramDocument document = new DiagramDocument();
+ document.setEditingDomain(createEditingDomain());
+ return document;
+ }
+
+ /**
+ * @generated
+ */
+ private TransactionalEditingDomain createEditingDomain() {
+ TransactionalEditingDomain editingDomain = DiagramEditingDomainFactory
+ .getInstance().createEditingDomain();
+ editingDomain.setID("org.eclipse.uml2.uml.diagram.EditingDomain"); //$NON-NLS-1$
+ final NotificationFilter diagramResourceModifiedFilter = NotificationFilter
+ .createNotifierFilter(editingDomain.getResourceSet())
+ .and(NotificationFilter.createEventTypeFilter(Notification.ADD))
+ .and(NotificationFilter.createFeatureFilter(ResourceSet.class,
+ ResourceSet.RESOURCE_SET__RESOURCES));
+ editingDomain.getResourceSet().eAdapters().add(new Adapter() {
+
+ private Notifier myTarger;
+
+ public Notifier getTarget() {
+ return myTarger;
+ }
+
+ public boolean isAdapterForType(Object type) {
+ return false;
+ }
+
+ public void notifyChanged(Notification notification) {
+ if (diagramResourceModifiedFilter.matches(notification)) {
+ Object value = notification.getNewValue();
+ if (value instanceof Resource) {
+ ((Resource) value).setTrackingModification(true);
+ }
+ }
+ }
+
+ public void setTarget(Notifier newTarget) {
+ myTarger = newTarget;
+ }
+
+ });
+
+ return editingDomain;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setDocumentContent(IDocument document, IEditorInput element)
+ throws CoreException {
+ IDiagramDocument diagramDocument = (IDiagramDocument) document;
+ TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
+ if (element instanceof FileEditorInput) {
+ IStorage storage = ((FileEditorInput) element).getStorage();
+ Diagram diagram = DiagramIOUtil.load(domain, storage, true,
+ getProgressMonitor());
+ document.setContent(diagram);
+ } else if (element instanceof URIEditorInput) {
+ URI uri = ((URIEditorInput) element).getURI();
+ Resource resource = null;
+ try {
+ resource = domain.getResourceSet().getResource(
+ uri.trimFragment(), false);
+ if (resource == null) {
+ resource = domain.getResourceSet().createResource(
+ uri.trimFragment());
+ }
+ if (!resource.isLoaded()) {
+ try {
+ Map options = new HashMap(
+ GMFResourceFactory.getDefaultLoadOptions());
+ // @see 171060
+ // options.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
+ resource.load(options);
+ } catch (IOException e) {
+ resource.unload();
+ throw e;
+ }
+ }
+ if (uri.fragment() != null) {
+ EObject rootElement = resource.getEObject(uri.fragment());
+ if (rootElement instanceof Diagram) {
+ document.setContent((Diagram) rootElement);
+ return;
+ }
+ } else {
+ for (Iterator it = resource.getContents().iterator(); it
+ .hasNext();) {
+ Object rootElement = it.next();
+ if (rootElement instanceof Diagram) {
+ document.setContent((Diagram) rootElement);
+ return;
+ }
+ }
+ }
+ throw new RuntimeException(
+ Messages.UMLDocumentProvider_NoDiagramInResourceError);
+ } catch (Exception e) {
+ CoreException thrownExcp = null;
+ if (e instanceof CoreException) {
+ thrownExcp = (CoreException) e;
+ } else {
+ String msg = e.getLocalizedMessage();
+ thrownExcp = new CoreException(
+ new Status(
+ IStatus.ERROR,
+ UMLDiagramEditorPlugin.ID,
+ 0,
+ msg != null ? msg
+ : Messages.UMLDocumentProvider_DiagramLoadingError,
+ e));
+ }
+ throw thrownExcp;
+ }
+ } else {
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ UMLDiagramEditorPlugin.ID,
+ 0,
+ NLS.bind(
+ Messages.UMLDocumentProvider_IncorrectInputError,
+ new Object[] {
+ element,
+ "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
+ null));
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public long getModificationStamp(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ return computeModificationStamp(info);
+ }
+ return super.getModificationStamp(element);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isDeleted(Object element) {
+ IDiagramDocument document = getDiagramDocument(element);
+ if (document != null) {
+ Resource diagramResource = document.getDiagram().eResource();
+ if (diagramResource != null) {
+ IFile file = WorkspaceSynchronizer.getFile(diagramResource);
+ return file == null || file.getLocation() == null
+ || !file.getLocation().toFile().exists();
+ }
+ }
+ return super.isDeleted(element);
+ }
+
+ /**
+ * @generated
+ */
+ public ResourceSetInfo getResourceSetInfo(Object editorInput) {
+ return (ResourceSetInfo) super.getElementInfo(editorInput);
+ }
+
+ /**
+ * @generated
+ */
+ protected void disposeElementInfo(Object element, ElementInfo info) {
+ if (info instanceof ResourceSetInfo) {
+ ResourceSetInfo resourceSetInfo = (ResourceSetInfo) info;
+ resourceSetInfo.dispose();
+ }
+ super.disposeElementInfo(element, info);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doValidateState(Object element, Object computationContext)
+ throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ LinkedList<IFile> files2Validate = new LinkedList<IFile>();
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
+ .hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null && file.isReadOnly()) {
+ files2Validate.add(file);
+ }
+ }
+ ResourcesPlugin.getWorkspace().validateEdit(
+ (IFile[]) files2Validate.toArray(new IFile[files2Validate
+ .size()]), computationContext);
+ }
+
+ super.doValidateState(element, computationContext);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isReadOnly(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ if (info.isUpdateCache()) {
+ try {
+ updateCache(element);
+ } catch (CoreException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ Messages.UMLDocumentProvider_isModifiable, ex);
+ // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable
+ }
+ }
+ return info.isReadOnly();
+ }
+ return super.isReadOnly(element);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isModifiable(Object element) {
+ if (!isStateValidated(element)) {
+ if (element instanceof FileEditorInput
+ || element instanceof URIEditorInput) {
+ return true;
+ }
+ }
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ if (info.isUpdateCache()) {
+ try {
+ updateCache(element);
+ } catch (CoreException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ Messages.UMLDocumentProvider_isModifiable, ex);
+ // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable
+ }
+ }
+ return info.isModifiable();
+ }
+ return super.isModifiable(element);
+ }
+
+ /**
+ * @generated
+ */
+ protected void updateCache(Object element) throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
+ .hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null && file.isReadOnly()) {
+ info.setReadOnly(true);
+ info.setModifiable(false);
+ return;
+ }
+ }
+ info.setReadOnly(false);
+ info.setModifiable(true);
+ return;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void doUpdateStateCache(Object element) throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ info.setUpdateCache(true);
+ }
+ super.doUpdateStateCache(element);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isSynchronized(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ return info.isSynchronized();
+ }
+ return super.isSynchronized(element);
+ }
+
+ /**
+ * @generated
+ */
+ protected ISchedulingRule getResetRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
+ .hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ rules.add(ResourcesPlugin.getWorkspace().getRuleFactory()
+ .modifyRule(file));
+ }
+ }
+ return new MultiRule(
+ (ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules
+ .size()]));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected ISchedulingRule getSaveRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
+ .hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ rules.add(computeSchedulingRule(file));
+ }
+ }
+ return new MultiRule(
+ (ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules
+ .size()]));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected ISchedulingRule getSynchronizeRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
+ .hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ rules.add(ResourcesPlugin.getWorkspace().getRuleFactory()
+ .refreshRule(file));
+ }
+ }
+ return new MultiRule(
+ (ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules
+ .size()]));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected ISchedulingRule getValidateStateRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ LinkedList<ISchedulingRule> files = new LinkedList<ISchedulingRule>();
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
+ .hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ files.add(file);
+ }
+ }
+ return ResourcesPlugin
+ .getWorkspace()
+ .getRuleFactory()
+ .validateEditRule(
+ (IFile[]) files.toArray(new IFile[files.size()]));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) {
+ if (toCreateOrModify.exists())
+ return ResourcesPlugin.getWorkspace().getRuleFactory()
+ .modifyRule(toCreateOrModify);
+
+ IResource parent = toCreateOrModify;
+ do {
+ /*
+ * XXX This is a workaround for
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67601
+ * IResourceRuleFactory.createRule should iterate the hierarchy
+ * itself.
+ */
+ toCreateOrModify = parent;
+ parent = toCreateOrModify.getParent();
+ } while (parent != null && !parent.exists());
+
+ return ResourcesPlugin.getWorkspace().getRuleFactory()
+ .createRule(toCreateOrModify);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doSynchronize(Object element, IProgressMonitor monitor)
+ throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
+ .hasNext();) {
+ Resource nextResource = it.next();
+ handleElementChanged(info, nextResource, monitor);
+ }
+ return;
+ }
+ super.doSynchronize(element, monitor);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doSaveDocument(IProgressMonitor monitor, Object element,
+ IDocument document, boolean overwrite) throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ if (!overwrite && !info.isSynchronized()) {
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ UMLDiagramEditorPlugin.ID,
+ IResourceStatus.OUT_OF_SYNC_LOCAL,
+ Messages.UMLDocumentProvider_UnsynchronizedFileSaveError,
+ null));
+ }
+ info.stopResourceListening();
+ fireElementStateChanging(element);
+ try {
+ monitor.beginTask(Messages.UMLDocumentProvider_SaveDiagramTask,
+ info.getResourceSet().getResources().size() + 1); //"Saving diagram"
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
+ .hasNext();) {
+ Resource nextResource = it.next();
+ monitor.setTaskName(NLS.bind(
+ Messages.UMLDocumentProvider_SaveNextResourceTask,
+ nextResource.getURI()));
+ if (nextResource.isLoaded()
+ && !info.getEditingDomain()
+ .isReadOnly(nextResource)) {
+ try {
+ nextResource.save(UMLDiagramEditorUtil
+ .getSaveOptions());
+ } catch (IOException e) {
+ fireElementStateChangeFailed(element);
+ throw new CoreException(new Status(IStatus.ERROR,
+ UMLDiagramEditorPlugin.ID,
+ EditorStatusCodes.RESOURCE_FAILURE,
+ e.getLocalizedMessage(), null));
+ }
+ }
+ monitor.worked(1);
+ }
+ monitor.done();
+ info.setModificationStamp(computeModificationStamp(info));
+ } catch (RuntimeException x) {
+ fireElementStateChangeFailed(element);
+ throw x;
+ } finally {
+ info.startResourceListening();
+ }
+ } else {
+ URI newResoruceURI;
+ List<IFile> affectedFiles = null;
+ if (element instanceof FileEditorInput) {
+ IFile newFile = ((FileEditorInput) element).getFile();
+ affectedFiles = Collections.singletonList(newFile);
+ newResoruceURI = URI.createPlatformResourceURI(newFile
+ .getFullPath().toString(), true);
+ } else if (element instanceof URIEditorInput) {
+ newResoruceURI = ((URIEditorInput) element).getURI();
+ } else {
+ fireElementStateChangeFailed(element);
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ UMLDiagramEditorPlugin.ID,
+ 0,
+ NLS.bind(
+ Messages.UMLDocumentProvider_IncorrectInputError,
+ new Object[] {
+ element,
+ "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
+ null));
+ }
+ if (false == document instanceof IDiagramDocument) {
+ fireElementStateChangeFailed(element);
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ UMLDiagramEditorPlugin.ID,
+ 0,
+ "Incorrect document used: " + document + " instead of org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument", null)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ IDiagramDocument diagramDocument = (IDiagramDocument) document;
+ final Resource newResource = diagramDocument.getEditingDomain()
+ .getResourceSet().createResource(newResoruceURI);
+ final Diagram diagramCopy = (Diagram) EcoreUtil
+ .copy(diagramDocument.getDiagram());
+ try {
+ new AbstractTransactionalCommand(
+ diagramDocument.getEditingDomain(), NLS.bind(
+ Messages.UMLDocumentProvider_SaveAsOperation,
+ diagramCopy.getName()), affectedFiles) {
+ protected CommandResult doExecuteWithResult(
+ IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ newResource.getContents().add(diagramCopy);
+ return CommandResult.newOKCommandResult();
+ }
+ }.execute(monitor, null);
+ newResource.save(UMLDiagramEditorUtil.getSaveOptions());
+ } catch (ExecutionException e) {
+ fireElementStateChangeFailed(element);
+ throw new CoreException(new Status(IStatus.ERROR,
+ UMLDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(),
+ null));
+ } catch (IOException e) {
+ fireElementStateChangeFailed(element);
+ throw new CoreException(new Status(IStatus.ERROR,
+ UMLDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(),
+ null));
+ }
+ newResource.unload();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleElementChanged(ResourceSetInfo info,
+ Resource changedResource, IProgressMonitor monitor) {
+ IFile file = WorkspaceSynchronizer.getFile(changedResource);
+ if (file != null) {
+ try {
+ file.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ } catch (CoreException ex) {
+ UMLDiagramEditorPlugin
+ .getInstance()
+ .logError(
+ Messages.UMLDocumentProvider_handleElementContentChanged,
+ ex);
+ // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.FileDocumentProvider_handleElementContentChanged
+ }
+ }
+ changedResource.unload();
+
+ fireElementContentAboutToBeReplaced(info.getEditorInput());
+ removeUnchangedElementListeners(info.getEditorInput(), info);
+ info.fStatus = null;
+ try {
+ setDocumentContent(info.fDocument, info.getEditorInput());
+ } catch (CoreException e) {
+ info.fStatus = e.getStatus();
+ }
+ if (!info.fCanBeSaved) {
+ info.setModificationStamp(computeModificationStamp(info));
+ }
+ addUnchangedElementListeners(info.getEditorInput(), info);
+ fireElementContentReplaced(info.getEditorInput());
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleElementMoved(IEditorInput input, URI uri) {
+ if (input instanceof FileEditorInput) {
+ IFile newFile = ResourcesPlugin
+ .getWorkspace()
+ .getRoot()
+ .getFile(
+ new Path(URI.decode(uri.path()))
+ .removeFirstSegments(1));
+ fireElementMoved(input, newFile == null ? null
+ : new FileEditorInput(newFile));
+ return;
+ }
+ // TODO: append suffix to the URI! (use diagram as a parameter)
+ fireElementMoved(input, new URIEditorInput(uri));
+ }
+
+ /**
+ * @generated
+ */
+ public IEditorInput createInputWithEditingDomain(IEditorInput editorInput,
+ TransactionalEditingDomain domain) {
+ return editorInput;
+ }
+
+ /**
+ * @generated
+ */
+ public IDiagramDocument getDiagramDocument(Object element) {
+ IDocument doc = getDocument(element);
+ if (doc instanceof IDiagramDocument) {
+ return (IDiagramDocument) doc;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected class ResourceSetInfo extends ElementInfo {
+
+ /**
+ * @generated
+ */
+ private long myModificationStamp = IResource.NULL_STAMP;
+
+ /**
+ * @generated
+ */
+ private WorkspaceSynchronizer mySynchronizer;
+
+ /**
+ * @generated
+ */
+ private LinkedList<Resource> myUnSynchronizedResources = new LinkedList<Resource>();
+
+ /**
+ * @generated
+ */
+ private IDiagramDocument myDocument;
+
+ /**
+ * @generated
+ */
+ private IEditorInput myEditorInput;
+
+ /**
+ * @generated
+ */
+ private boolean myUpdateCache = true;
+
+ /**
+ * @generated
+ */
+ private boolean myModifiable = false;
+
+ /**
+ * @generated
+ */
+ private boolean myReadOnly = true;
+
+ /**
+ * @generated
+ */
+ private ResourceSetModificationListener myResourceSetListener;
+
+ /**
+ * @generated
+ */
+ public ResourceSetInfo(IDiagramDocument document,
+ IEditorInput editorInput) {
+ super(document);
+ myDocument = document;
+ myEditorInput = editorInput;
+ startResourceListening();
+ myResourceSetListener = new ResourceSetModificationListener(this);
+ getResourceSet().eAdapters().add(myResourceSetListener);
+ }
+
+ /**
+ * @generated
+ */
+ public long getModificationStamp() {
+ return myModificationStamp;
+ }
+
+ /**
+ * @generated
+ */
+ public void setModificationStamp(long modificationStamp) {
+ myModificationStamp = modificationStamp;
+ }
+
+ /**
+ * @generated
+ */
+ public TransactionalEditingDomain getEditingDomain() {
+ return myDocument.getEditingDomain();
+ }
+
+ /**
+ * @generated
+ */
+ public ResourceSet getResourceSet() {
+ return getEditingDomain().getResourceSet();
+ }
+
+ /**
+ * @generated
+ */
+ public Iterator<Resource> getLoadedResourcesIterator() {
+ return new ArrayList<Resource>(getResourceSet().getResources())
+ .iterator();
+ }
+
+ /**
+ * @generated
+ */
+ public IEditorInput getEditorInput() {
+ return myEditorInput;
+ }
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ stopResourceListening();
+ getResourceSet().eAdapters().remove(myResourceSetListener);
+ for (Iterator<Resource> it = getLoadedResourcesIterator(); it
+ .hasNext();) {
+ Resource resource = it.next();
+ resource.unload();
+ }
+ getEditingDomain().dispose();
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isSynchronized() {
+ return myUnSynchronizedResources.size() == 0;
+ }
+
+ /**
+ * @generated
+ */
+ public void setUnSynchronized(Resource resource) {
+ myUnSynchronizedResources.add(resource);
+ }
+
+ /**
+ * @generated
+ */
+ public void setSynchronized(Resource resource) {
+ myUnSynchronizedResources.remove(resource);
+ }
+
+ /**
+ * @generated
+ */
+ public final void stopResourceListening() {
+ mySynchronizer.dispose();
+ mySynchronizer = null;
+ }
+
+ /**
+ * @generated
+ */
+ public final void startResourceListening() {
+ mySynchronizer = new WorkspaceSynchronizer(getEditingDomain(),
+ new SynchronizerDelegate());
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isUpdateCache() {
+ return myUpdateCache;
+ }
+
+ /**
+ * @generated
+ */
+ public void setUpdateCache(boolean update) {
+ myUpdateCache = update;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isModifiable() {
+ return myModifiable;
+ }
+
+ /**
+ * @generated
+ */
+ public void setModifiable(boolean modifiable) {
+ myModifiable = modifiable;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isReadOnly() {
+ return myReadOnly;
+ }
+
+ /**
+ * @generated
+ */
+ public void setReadOnly(boolean readOnly) {
+ myReadOnly = readOnly;
+ }
+
+ /**
+ * @generated
+ */
+ private class SynchronizerDelegate implements
+ WorkspaceSynchronizer.Delegate {
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ }
+
+ /**
+ * @generated
+ */
+ public boolean handleResourceChanged(final Resource resource) {
+ synchronized (ResourceSetInfo.this) {
+ if (ResourceSetInfo.this.fCanBeSaved) {
+ ResourceSetInfo.this.setUnSynchronized(resource);
+ return true;
+ }
+ }
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ handleElementChanged(ResourceSetInfo.this, resource,
+ null);
+ }
+ });
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean handleResourceDeleted(Resource resource) {
+ synchronized (ResourceSetInfo.this) {
+ if (ResourceSetInfo.this.fCanBeSaved) {
+ ResourceSetInfo.this.setUnSynchronized(resource);
+ return true;
+ }
+ }
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ fireElementDeleted(ResourceSetInfo.this
+ .getEditorInput());
+ }
+ });
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean handleResourceMoved(Resource resource,
+ final URI newURI) {
+ synchronized (ResourceSetInfo.this) {
+ if (ResourceSetInfo.this.fCanBeSaved) {
+ ResourceSetInfo.this.setUnSynchronized(resource);
+ return true;
+ }
+ }
+ if (myDocument.getDiagram().eResource() == resource) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ handleElementMoved(
+ ResourceSetInfo.this.getEditorInput(),
+ newURI);
+ }
+ });
+ } else {
+ handleResourceDeleted(resource);
+ }
+ return true;
+ }
+
+ }
+
+ }
+
+ /**
+ * @generated
+ */
+ private class ResourceSetModificationListener extends EContentAdapter {
+
+ /**
+ * @generated
+ */
+ private NotificationFilter myModifiedFilter;
+
+ /**
+ * @generated
+ */
+ private ResourceSetInfo myInfo;
+
+ /**
+ * @generated
+ */
+ public ResourceSetModificationListener(ResourceSetInfo info) {
+ myInfo = info;
+ myModifiedFilter = NotificationFilter
+ .createEventTypeFilter(Notification.SET)
+ .or(NotificationFilter
+ .createEventTypeFilter(Notification.UNSET))
+ .and(NotificationFilter.createFeatureFilter(Resource.class,
+ Resource.RESOURCE__IS_MODIFIED));
+ }
+
+ /**
+ * @generated
+ */
+ public void notifyChanged(Notification notification) {
+ if (notification.getNotifier() instanceof ResourceSet) {
+ super.notifyChanged(notification);
+ }
+ if (!notification.isTouch()
+ && myModifiedFilter.matches(notification)) {
+ if (notification.getNotifier() instanceof Resource) {
+ Resource resource = (Resource) notification.getNotifier();
+ if (resource.isLoaded()) {
+ boolean modified = false;
+ for (Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/it = myInfo
+ .getLoadedResourcesIterator(); it.hasNext()
+ && !modified;) {
+ Resource nextResource = (Resource) it.next();
+ if (nextResource.isLoaded()) {
+ modified = nextResource.isModified();
+ }
+ }
+ boolean dirtyStateChanged = false;
+ synchronized (myInfo) {
+ if (modified != myInfo.fCanBeSaved) {
+ myInfo.fCanBeSaved = modified;
+ dirtyStateChanged = true;
+ }
+ if (!resource.isModified()) {
+ myInfo.setSynchronized(resource);
+ }
+ }
+ if (dirtyStateChanged) {
+ fireElementDirtyStateChanged(
+ myInfo.getEditorInput(), modified);
+
+ if (!modified) {
+ myInfo.setModificationStamp(computeModificationStamp(myInfo));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLInitDiagramFileAction.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLInitDiagramFileAction.java
new file mode 100644
index 00000000000..0f23057afae
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLInitDiagramFileAction.java
@@ -0,0 +1,95 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @generated
+ */
+public class UMLInitDiagramFileAction implements IObjectActionDelegate {
+
+ /**
+ * @generated
+ */
+ private IWorkbenchPart targetPart;
+
+ /**
+ * @generated
+ */
+ private URI domainModelURI;
+
+ /**
+ * @generated
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ this.targetPart = targetPart;
+ }
+
+ /**
+ * @generated
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ domainModelURI = null;
+ action.setEnabled(false);
+ if (selection instanceof IStructuredSelection == false
+ || selection.isEmpty()) {
+ return;
+ }
+ IFile file = (IFile) ((IStructuredSelection) selection)
+ .getFirstElement();
+ domainModelURI = URI.createPlatformResourceURI(file.getFullPath()
+ .toString(), true);
+ action.setEnabled(true);
+ }
+
+ /**
+ * @generated
+ */
+ private Shell getShell() {
+ return targetPart.getSite().getShell();
+ }
+
+ /**
+ * @generated
+ */
+ public void run(IAction action) {
+ TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE
+ .createEditingDomain();
+ ResourceSet resourceSet = editingDomain.getResourceSet();
+ EObject diagramRoot = null;
+ try {
+ Resource resource = resourceSet.getResource(domainModelURI, true);
+ diagramRoot = (EObject) resource.getContents().get(0);
+ } catch (WrappedException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Unable to load resource: " + domainModelURI, ex); //$NON-NLS-1$
+ }
+ if (diagramRoot == null) {
+ MessageDialog.openError(getShell(),
+ Messages.InitDiagramFile_ResourceErrorDialogTitle,
+ Messages.InitDiagramFile_ResourceErrorDialogMessage);
+ return;
+ }
+ Wizard wizard = new UMLNewDiagramFileWizard(domainModelURI,
+ diagramRoot, editingDomain);
+ wizard.setWindowTitle(NLS.bind(Messages.InitDiagramFile_WizardTitle,
+ ModelEditPart.MODEL_ID));
+ UMLDiagramEditorUtil.runWizard(getShell(), wizard, "InitDiagramFile"); //$NON-NLS-1$
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLLinkDescriptor.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLLinkDescriptor.java
new file mode 100644
index 00000000000..0e87fda150c
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLLinkDescriptor.java
@@ -0,0 +1,93 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+
+/**
+ * @generated
+ */
+public class UMLLinkDescriptor extends UMLNodeDescriptor {
+
+ /**
+ * @generated
+ */
+ private EObject mySource;
+
+ /**
+ * @generated
+ */
+ private EObject myDestination;
+
+ /**
+ * @generated
+ */
+ private IAdaptable mySemanticAdapter;
+
+ /**
+ * @generated
+ */
+ private UMLLinkDescriptor(EObject source, EObject destination,
+ EObject linkElement, int linkVID) {
+ super(linkElement, linkVID);
+ mySource = source;
+ myDestination = destination;
+ }
+
+ /**
+ * @generated
+ */
+ public UMLLinkDescriptor(EObject source, EObject destination,
+ IElementType elementType, int linkVID) {
+ this(source, destination, (EObject) null, linkVID);
+ final IElementType elementTypeCopy = elementType;
+ mySemanticAdapter = new IAdaptable() {
+ public Object getAdapter(Class adapter) {
+ if (IElementType.class.equals(adapter)) {
+ return elementTypeCopy;
+ }
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public UMLLinkDescriptor(EObject source, EObject destination,
+ EObject linkElement, IElementType elementType, int linkVID) {
+ this(source, destination, linkElement, linkVID);
+ final IElementType elementTypeCopy = elementType;
+ mySemanticAdapter = new EObjectAdapter(linkElement) {
+ public Object getAdapter(Class adapter) {
+ if (IElementType.class.equals(adapter)) {
+ return elementTypeCopy;
+ }
+ return super.getAdapter(adapter);
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public EObject getSource() {
+ return mySource;
+ }
+
+ /**
+ * @generated
+ */
+ public EObject getDestination() {
+ return myDestination;
+ }
+
+ /**
+ * @generated
+ */
+ public IAdaptable getSemanticAdapter() {
+ return mySemanticAdapter;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLMatchingStrategy.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLMatchingStrategy.java
new file mode 100644
index 00000000000..a40fb2f4c6b
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLMatchingStrategy.java
@@ -0,0 +1,36 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorMatchingStrategy;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * @generated
+ */
+public class UMLMatchingStrategy implements IEditorMatchingStrategy {
+
+ /**
+ * @generated
+ */
+ public boolean matches(IEditorReference editorRef, IEditorInput input) {
+ IEditorInput editorInput;
+ try {
+ editorInput = editorRef.getEditorInput();
+ } catch (PartInitException e) {
+ return false;
+ }
+
+ if (editorInput.equals(input)) {
+ return true;
+ }
+ if (editorInput instanceof URIEditorInput
+ && input instanceof URIEditorInput) {
+ return ((URIEditorInput) editorInput).getURI().equals(
+ ((URIEditorInput) input).getURI());
+ }
+ return false;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLNewDiagramFileWizard.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLNewDiagramFileWizard.java
new file mode 100644
index 00000000000..f985437f054
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLNewDiagramFileWizard.java
@@ -0,0 +1,196 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import java.io.IOException;
+import java.util.LinkedList;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+/**
+ * @generated
+ */
+public class UMLNewDiagramFileWizard extends Wizard {
+
+ /**
+ * @generated
+ */
+ private WizardNewFileCreationPage myFileCreationPage;
+
+ /**
+ * @generated
+ */
+ private ModelElementSelectionPage diagramRootElementSelectionPage;
+
+ /**
+ * @generated
+ */
+ private TransactionalEditingDomain myEditingDomain;
+
+ /**
+ * @generated
+ */
+ public UMLNewDiagramFileWizard(URI domainModelURI, EObject diagramRoot,
+ TransactionalEditingDomain editingDomain) {
+ assert domainModelURI != null : "Domain model uri must be specified"; //$NON-NLS-1$
+ assert diagramRoot != null : "Doagram root element must be specified"; //$NON-NLS-1$
+ assert editingDomain != null : "Editing domain must be specified"; //$NON-NLS-1$
+
+ myFileCreationPage = new WizardNewFileCreationPage(
+ Messages.UMLNewDiagramFileWizard_CreationPageName,
+ StructuredSelection.EMPTY);
+ myFileCreationPage
+ .setTitle(Messages.UMLNewDiagramFileWizard_CreationPageTitle);
+ myFileCreationPage.setDescription(NLS.bind(
+ Messages.UMLNewDiagramFileWizard_CreationPageDescription,
+ ModelEditPart.MODEL_ID));
+ IPath filePath;
+ String fileName = URI.decode(domainModelURI.trimFileExtension()
+ .lastSegment());
+ if (domainModelURI.isPlatformResource()) {
+ filePath = new Path(domainModelURI.trimSegments(1)
+ .toPlatformString(true));
+ } else if (domainModelURI.isFile()) {
+ filePath = new Path(domainModelURI.trimSegments(1).toFileString());
+ } else {
+ // TODO : use some default path
+ throw new IllegalArgumentException(
+ "Unsupported URI: " + domainModelURI); //$NON-NLS-1$
+ }
+ myFileCreationPage.setContainerFullPath(filePath);
+ myFileCreationPage.setFileName(UMLDiagramEditorUtil.getUniqueFileName(
+ filePath, fileName, "PapyrusNewDiagram_diagram")); //$NON-NLS-1$
+
+ diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(
+ Messages.UMLNewDiagramFileWizard_RootSelectionPageName);
+ diagramRootElementSelectionPage
+ .setTitle(Messages.UMLNewDiagramFileWizard_RootSelectionPageTitle);
+ diagramRootElementSelectionPage
+ .setDescription(Messages.UMLNewDiagramFileWizard_RootSelectionPageDescription);
+ diagramRootElementSelectionPage.setModelElement(diagramRoot);
+
+ myEditingDomain = editingDomain;
+ }
+
+ /**
+ * @generated
+ */
+ public void addPages() {
+ addPage(myFileCreationPage);
+ addPage(diagramRootElementSelectionPage);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean performFinish() {
+ LinkedList<IFile> affectedFiles = new LinkedList<IFile>();
+ IFile diagramFile = myFileCreationPage.createNewFile();
+ UMLDiagramEditorUtil.setCharset(diagramFile);
+ affectedFiles.add(diagramFile);
+ URI diagramModelURI = URI.createPlatformResourceURI(diagramFile
+ .getFullPath().toString(), true);
+ ResourceSet resourceSet = myEditingDomain.getResourceSet();
+ final Resource diagramResource = resourceSet
+ .createResource(diagramModelURI);
+ AbstractTransactionalCommand command = new AbstractTransactionalCommand(
+ myEditingDomain,
+ Messages.UMLNewDiagramFileWizard_InitDiagramCommand,
+ affectedFiles) {
+
+ protected CommandResult doExecuteWithResult(
+ IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ int diagramVID = UMLVisualIDRegistry
+ .getDiagramVisualID(diagramRootElementSelectionPage
+ .getModelElement());
+ if (diagramVID != ModelEditPart.VISUAL_ID) {
+ return CommandResult
+ .newErrorCommandResult(Messages.UMLNewDiagramFileWizard_IncorrectRootError);
+ }
+ Diagram diagram = ViewService.createDiagram(
+ diagramRootElementSelectionPage.getModelElement(),
+ ModelEditPart.MODEL_ID,
+ UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
+ diagramResource.getContents().add(diagram);
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ try {
+ OperationHistoryFactory.getOperationHistory().execute(command,
+ new NullProgressMonitor(), null);
+ diagramResource.save(UMLDiagramEditorUtil.getSaveOptions());
+ UMLDiagramEditorUtil.openDiagram(diagramResource);
+ } catch (ExecutionException e) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Unable to create model and diagram", e); //$NON-NLS-1$
+ } catch (IOException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Save operation failed for: " + diagramModelURI, ex); //$NON-NLS-1$
+ } catch (PartInitException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Unable to open editor", ex); //$NON-NLS-1$
+ }
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ private static class DiagramRootElementSelectionPage extends
+ ModelElementSelectionPage {
+
+ /**
+ * @generated
+ */
+ protected DiagramRootElementSelectionPage(String pageName) {
+ super(pageName);
+ }
+
+ /**
+ * @generated
+ */
+ protected String getSelectionTitle() {
+ return Messages.UMLNewDiagramFileWizard_RootSelectionPageSelectionTitle;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean validatePage() {
+ if (selectedModelElement == null) {
+ setErrorMessage(Messages.UMLNewDiagramFileWizard_RootSelectionPageNoSelectionMessage);
+ return false;
+ }
+ boolean result = ViewService.getInstance().provides(
+ new CreateDiagramViewOperation(new EObjectAdapter(
+ selectedModelElement), ModelEditPart.MODEL_ID,
+ UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT));
+ setErrorMessage(result ? null
+ : Messages.UMLNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage);
+ return result;
+ }
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLNodeDescriptor.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLNodeDescriptor.java
new file mode 100644
index 00000000000..752c4887205
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLNodeDescriptor.java
@@ -0,0 +1,42 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * @generated
+ */
+public class UMLNodeDescriptor {
+
+ /**
+ * @generated
+ */
+ private final EObject myModelElement;
+
+ /**
+ * @generated
+ */
+ private final int myVisualID;
+
+ /**
+ * @generated
+ */
+ public UMLNodeDescriptor(EObject modelElement, int visualID) {
+ myModelElement = modelElement;
+ myVisualID = visualID;
+ }
+
+ /**
+ * @generated
+ */
+ public EObject getModelElement() {
+ return myModelElement;
+ }
+
+ /**
+ * @generated
+ */
+ public int getVisualID() {
+ return myVisualID;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLPaletteFactory.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLPaletteFactory.java
new file mode 100644
index 00000000000..6a5069a1161
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLPaletteFactory.java
@@ -0,0 +1,61 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.gef.Tool;
+import org.eclipse.gmf.runtime.diagram.ui.services.palette.PaletteFactory;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.diagram.common.service.AspectUnspecifiedTypeCreationTool;
+import org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class UMLPaletteFactory extends PaletteFactory.Adapter {
+
+ /**
+ * @generated
+ */
+ private final static String CREATECOMPONENT1CREATIONTOOL = "createComponent1CreationTool"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public UMLPaletteFactory() {
+
+ }
+
+ /**
+ * @generated
+ */
+ public Tool createTool(String toolId) {
+ if (toolId.equals(CREATECOMPONENT1CREATIONTOOL)) {
+ return createComponent1CreationTool();
+ }
+
+ // default return: null
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public Object getTemplate(String templateId) {
+
+ // default return: null
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private Tool createComponent1CreationTool() {
+ List<IElementType> types = new ArrayList<IElementType>(1);
+ types.add(UMLElementTypes.Component_2001);
+
+ Tool tool = new AspectUnspecifiedTypeCreationTool(types);
+ return tool;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLUriEditorInputTester.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLUriEditorInputTester.java
new file mode 100644
index 00000000000..3c39cadcea1
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLUriEditorInputTester.java
@@ -0,0 +1,23 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.emf.common.ui.URIEditorInput;
+
+/**
+ * @generated
+ */
+public class UMLUriEditorInputTester extends PropertyTester {
+
+ /**
+ * @generated
+ */
+ public boolean test(Object receiver, String method, Object[] args,
+ Object expectedValue) {
+ if (false == receiver instanceof URIEditorInput) {
+ return false;
+ }
+ URIEditorInput editorInput = (URIEditorInput) receiver;
+ return "PapyrusNewDiagram_diagram".equals(editorInput.getURI().fileExtension()); //$NON-NLS-1$
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLVisualIDRegistry.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLVisualIDRegistry.java
new file mode 100644
index 00000000000..417f55ea18e
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/part/UMLVisualIDRegistry.java
@@ -0,0 +1,217 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.part;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.diagram.common.providers.BaseViewInfo;
+import org.eclipse.papyrus.diagram.common.providers.ViewInfo;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentNameEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * This registry is used to determine which type of visual object should be
+ * created for the corresponding Diagram, Node, ChildNode or Link represented
+ * by a domain model object.
+ *
+ * @generated
+ */
+public class UMLVisualIDRegistry {
+
+ /**
+ * @generated
+ */
+ private static final String DEBUG_KEY = "org.eclipse.uml2.uml.diagram/debug/visualID"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static int getVisualID(View view) {
+ if (view instanceof Diagram) {
+ if (ModelEditPart.MODEL_ID.equals(view.getType())) {
+ return ModelEditPart.VISUAL_ID;
+ } else {
+ return -1;
+ }
+ }
+ return org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry
+ .getVisualID(view.getType());
+ }
+
+ /**
+ * @generated
+ */
+ public static String getModelID(View view) {
+ View diagram = view.getDiagram();
+ while (view != diagram) {
+ EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
+ if (annotation != null) {
+ return (String) annotation.getDetails().get("modelID"); //$NON-NLS-1$
+ }
+ view = (View) view.eContainer();
+ }
+ return diagram != null ? diagram.getType() : null;
+ }
+
+ /**
+ * @generated
+ */
+ public static int getVisualID(String type) {
+ try {
+ return Integer.parseInt(type);
+ } catch (NumberFormatException e) {
+ if (Boolean.TRUE.toString().equalsIgnoreCase(
+ Platform.getDebugOption(DEBUG_KEY))) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Unable to parse view type as a visualID number: "
+ + type);
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * @generated
+ */
+ public static String getType(int visualID) {
+ return Integer.toString(visualID);
+ }
+
+ /**
+ * @generated
+ */
+ public static int getDiagramVisualID(EObject domainElement) {
+ if (domainElement == null) {
+ return -1;
+ }
+ if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(
+ domainElement.eClass())
+ && isDiagram((Model) domainElement)) {
+ return ModelEditPart.VISUAL_ID;
+ }
+
+ return -1;
+ }
+
+ /**
+ * @generated
+ */
+ public static int getNodeVisualID(View containerView, EObject domainElement) {
+ if (domainElement == null) {
+ return -1;
+ }
+ String containerModelID = org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry
+ .getModelID(containerView);
+ if (!ModelEditPart.MODEL_ID.equals(containerModelID)) {
+ return -1;
+ }
+ int containerVisualID;
+ if (ModelEditPart.MODEL_ID.equals(containerModelID)) {
+ containerVisualID = org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry
+ .getVisualID(containerView);
+ } else {
+ if (containerView instanceof Diagram) {
+ containerVisualID = ModelEditPart.VISUAL_ID;
+ } else {
+ return -1;
+ }
+ }
+ switch (containerVisualID) {
+ case ModelEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getComponent().isSuperTypeOf(
+ domainElement.eClass())
+
+ ) {
+ return ComponentEditPart.VISUAL_ID;
+ }
+ break;
+ }
+ return -1;
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean canCreateNode(View containerView, int nodeVisualID) {
+ String containerModelID = org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry
+ .getModelID(containerView);
+ if (!ModelEditPart.MODEL_ID.equals(containerModelID)) {
+ return false;
+ }
+ int containerVisualID;
+ if (ModelEditPart.MODEL_ID.equals(containerModelID)) {
+ containerVisualID = org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry
+ .getVisualID(containerView);
+ } else {
+ if (containerView instanceof Diagram) {
+ containerVisualID = ModelEditPart.VISUAL_ID;
+ } else {
+ return false;
+ }
+ }
+ switch (containerVisualID) {
+ case ModelEditPart.VISUAL_ID:
+ if (ComponentEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ComponentEditPart.VISUAL_ID:
+ if (ComponentNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public static int getLinkWithClassVisualID(EObject domainElement) {
+ if (domainElement == null) {
+ return -1;
+ }
+ return -1;
+ }
+
+ /**
+ * "User can change implementation of this method to handle some specific\n""situations not covered by default logic.\n"
+ * @generated
+ */
+ private static boolean isDiagram(Model element) {
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ private static ViewInfo diagramViewInfo = null;
+
+ /**
+ * @generated
+ */
+ public static ViewInfo getDiagramViewInfo() {
+ if (diagramViewInfo == null) {
+ diagramViewInfo = getModel_1000ViewInfo();
+ }
+ return diagramViewInfo;
+ }
+
+ /**
+ * @generated
+ */
+ protected static ViewInfo getModel_1000ViewInfo() {
+ ViewInfo root = new BaseViewInfo(1000, ViewInfo.Head, "", null, null);
+ ViewInfo viewInfo = null;
+ ViewInfo labelInfo = null;
+
+ viewInfo = new BaseViewInfo(2001, ViewInfo.Node, "Component");
+ root.addNode(1000, viewInfo);
+ return root;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/ComponentPreferencePage.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/ComponentPreferencePage.java
new file mode 100644
index 00000000000..17928ba8079
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/ComponentPreferencePage.java
@@ -0,0 +1,53 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.preferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.preferences.pages.AbstractPapyrusNodePreferencePage;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+
+/**
+ * @generated
+ */
+public class ComponentPreferencePage extends AbstractPapyrusNodePreferencePage {
+
+ /**
+ * @generated
+ */
+ public ComponentPreferencePage() {
+ super();
+ setPreferenceKey(ModelEditPart.MODEL_ID + "_Component");
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getBundleId() {
+ return UMLDiagramEditorPlugin.ID;
+ }
+
+ /**
+ * @generated
+ */
+ public static void initDefaults(IPreferenceStore store) {
+
+ String key = ModelEditPart.MODEL_ID + "_Component";
+ store.setDefault(PreferenceConstantHelper.getElementConstant(key,
+ PreferenceConstantHelper.WIDTH), 40);
+ store.setDefault(PreferenceConstantHelper.getElementConstant(key,
+ PreferenceConstantHelper.HEIGHT), 40);
+
+ //org.eclipse.jface.preference.PreferenceConverter.setDefault(store, org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper.COLOR_FILL), new org.eclipse.swt.graphics.RGB(255, 255, 255));
+ //org.eclipse.jface.preference.PreferenceConverter.setDefault(store, org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper.COLOR_LINE), new org.eclipse.swt.graphics.RGB(0, 0, 0));
+
+ // Set the default for the gradient
+ //store.setDefault(org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper.GRADIENT_POLICY),false);
+ //org.eclipse.papyrus.preferences.utils.GradientPreferenceConverter gradientPreferenceConverter = new org.eclipse.papyrus.preferences.utils.GradientPreferenceConverter(
+ // new org.eclipse.swt.graphics.RGB(255, 255, 255),
+ // new org.eclipse.swt.graphics.RGB(0, 0, 0), 0, 0);
+ //store.setDefault(org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper.COLOR_GRADIENT), gradientPreferenceConverter.getPreferenceValue());
+
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramAppearancePreferencePage.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramAppearancePreferencePage.java
new file mode 100644
index 00000000000..871c93d7388
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramAppearancePreferencePage.java
@@ -0,0 +1,19 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.preferences;
+
+import org.eclipse.gmf.runtime.diagram.ui.preferences.AppearancePreferencePage;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+
+/**
+ * @generated
+ */
+public class DiagramAppearancePreferencePage extends AppearancePreferencePage {
+
+ /**
+ * @generated
+ */
+ public DiagramAppearancePreferencePage() {
+ setPreferenceStore(UMLDiagramEditorPlugin.getInstance()
+ .getPreferenceStore());
+
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramConnectionsPreferencePage.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramConnectionsPreferencePage.java
new file mode 100644
index 00000000000..57a01e873a4
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramConnectionsPreferencePage.java
@@ -0,0 +1,19 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.preferences;
+
+import org.eclipse.gmf.runtime.diagram.ui.preferences.ConnectionsPreferencePage;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+
+/**
+ * @generated
+ */
+public class DiagramConnectionsPreferencePage extends ConnectionsPreferencePage {
+
+ /**
+ * @generated
+ */
+ public DiagramConnectionsPreferencePage() {
+ setPreferenceStore(UMLDiagramEditorPlugin.getInstance()
+ .getPreferenceStore());
+
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramGeneralPreferencePage.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramGeneralPreferencePage.java
new file mode 100644
index 00000000000..db443791fb8
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramGeneralPreferencePage.java
@@ -0,0 +1,21 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.preferences;
+
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.preferences.pages.DiagramPreferencePage;
+
+/**
+ * @generated
+ */
+public class DiagramGeneralPreferencePage extends DiagramPreferencePage {
+
+ /**
+ * @generated
+ */
+ public DiagramGeneralPreferencePage() {
+ setPreferenceStore(UMLDiagramEditorPlugin.getInstance()
+ .getPreferenceStore());
+ setPreferenceKey(ModelEditPart.MODEL_ID);
+
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramPreferenceInitializer.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramPreferenceInitializer.java
new file mode 100644
index 00000000000..ae1e14dd679
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramPreferenceInitializer.java
@@ -0,0 +1,28 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+
+/**
+ * @generated
+ */
+public class DiagramPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /**
+ * @generated
+ */
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = getPreferenceStore();
+
+ ComponentPreferencePage.initDefaults(store);
+
+ }
+
+ /**
+ * @generated
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ return UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramPrintingPreferencePage.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramPrintingPreferencePage.java
new file mode 100644
index 00000000000..9bd4336f181
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramPrintingPreferencePage.java
@@ -0,0 +1,19 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.preferences;
+
+import org.eclipse.gmf.runtime.diagram.ui.preferences.PrintingPreferencePage;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+
+/**
+ * @generated
+ */
+public class DiagramPrintingPreferencePage extends PrintingPreferencePage {
+
+ /**
+ * @generated
+ */
+ public DiagramPrintingPreferencePage() {
+ setPreferenceStore(UMLDiagramEditorPlugin.getInstance()
+ .getPreferenceStore());
+
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramRulersAndGridPreferencePage.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramRulersAndGridPreferencePage.java
new file mode 100644
index 00000000000..f8b5b47c65d
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/preferences/DiagramRulersAndGridPreferencePage.java
@@ -0,0 +1,19 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.preferences;
+
+import org.eclipse.gmf.runtime.diagram.ui.preferences.RulerGridPreferencePage;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+
+/**
+ * @generated
+ */
+public class DiagramRulersAndGridPreferencePage extends RulerGridPreferencePage {
+
+ /**
+ * @generated
+ */
+ public DiagramRulersAndGridPreferencePage() {
+ setPreferenceStore(UMLDiagramEditorPlugin.getInstance()
+ .getPreferenceStore());
+
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/ElementInitializers.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/ElementInitializers.java
new file mode 100644
index 00000000000..7d81fb4cd34
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/ElementInitializers.java
@@ -0,0 +1,26 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.providers;
+
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+
+/**
+ * @generated
+ */
+public class ElementInitializers {
+
+ protected ElementInitializers() {
+ // use #getInstance to access cached instance
+ }
+
+ /**
+ * @generated
+ */
+ public static ElementInitializers getInstance() {
+ ElementInitializers cached = UMLDiagramEditorPlugin.getInstance()
+ .getElementInitializers();
+ if (cached == null) {
+ UMLDiagramEditorPlugin.getInstance().setElementInitializers(
+ cached = new ElementInitializers());
+ }
+ return cached;
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLEditPartProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLEditPartProvider.java
new file mode 100644
index 00000000000..aaa77ed3770
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLEditPartProvider.java
@@ -0,0 +1,142 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.providers;
+
+import java.lang.ref.WeakReference;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.CreateGraphicEditPartOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.IEditPartOperation;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.UMLEditPartFactory;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+
+/**
+ * @generated
+ */
+public class UMLEditPartProvider extends AbstractEditPartProvider {
+
+ /**
+ * @generated
+ */
+ private EditPartFactory factory;
+
+ /**
+ * @generated
+ */
+ private boolean allowCaching;
+
+ /**
+ * @generated
+ */
+ private WeakReference cachedPart;
+
+ /**
+ * @generated
+ */
+ private WeakReference cachedView;
+
+ /**
+ * @generated
+ */
+ public UMLEditPartProvider() {
+ setFactory(new UMLEditPartFactory());
+ setAllowCaching(true);
+ }
+
+ /**
+ * @generated
+ */
+ public final EditPartFactory getFactory() {
+ return factory;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFactory(EditPartFactory factory) {
+ this.factory = factory;
+ }
+
+ /**
+ * @generated
+ */
+ public final boolean isAllowCaching() {
+ return allowCaching;
+ }
+
+ /**
+ * @generated
+ */
+ protected synchronized void setAllowCaching(boolean allowCaching) {
+ this.allowCaching = allowCaching;
+ if (!allowCaching) {
+ cachedPart = null;
+ cachedView = null;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected IGraphicalEditPart createEditPart(View view) {
+ EditPart part = factory.createEditPart(null, view);
+ if (part instanceof IGraphicalEditPart) {
+ return (IGraphicalEditPart) part;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected IGraphicalEditPart getCachedPart(View view) {
+ if (cachedView != null && cachedView.get() == view) {
+ return (IGraphicalEditPart) cachedPart.get();
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public synchronized IGraphicalEditPart createGraphicEditPart(View view) {
+ if (isAllowCaching()) {
+ IGraphicalEditPart part = getCachedPart(view);
+ cachedPart = null;
+ cachedView = null;
+ if (part != null) {
+ return part;
+ }
+ }
+ return createEditPart(view);
+ }
+
+ /**
+ * @generated
+ */
+ public synchronized boolean provides(IOperation operation) {
+ if (operation instanceof CreateGraphicEditPartOperation) {
+ View view = ((IEditPartOperation) operation).getView();
+ if (!ModelEditPart.MODEL_ID.equals(UMLVisualIDRegistry
+ .getModelID(view))) {
+ return false;
+ }
+ if (isAllowCaching() && getCachedPart(view) != null) {
+ return true;
+ }
+ IGraphicalEditPart part = createEditPart(view);
+ if (part != null) {
+ if (isAllowCaching()) {
+ cachedPart = new WeakReference(part);
+ cachedView = new WeakReference(view);
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLElementTypes.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLElementTypes.java
new file mode 100644
index 00000000000..d6fe111f6af
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLElementTypes.java
@@ -0,0 +1,208 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.providers;
+
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class UMLElementTypes {
+
+ /**
+ * @generated
+ */
+ private UMLElementTypes() {
+ }
+
+ /**
+ * @generated
+ */
+ private static Map<IElementType, ENamedElement> elements;
+
+ /**
+ * @generated
+ */
+ private static ImageRegistry imageRegistry;
+
+ /**
+ * @generated
+ */
+ private static Set<IElementType> KNOWN_ELEMENT_TYPES;
+
+ /**
+ * @generated
+ */
+ public static final IElementType Model_1000 = getElementType("org.eclipse.uml2.uml.diagram.Model_1000"); //$NON-NLS-1$
+ /**
+ * @generated
+ */
+ public static final IElementType Component_2001 = getElementType("org.eclipse.uml2.uml.diagram.Component_2001"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ private static ImageRegistry getImageRegistry() {
+ if (imageRegistry == null) {
+ imageRegistry = new ImageRegistry();
+ }
+ return imageRegistry;
+ }
+
+ /**
+ * @generated
+ */
+ private static String getImageRegistryKey(ENamedElement element) {
+ return element.getName();
+ }
+
+ /**
+ * @generated
+ */
+ private static ImageDescriptor getProvidedImageDescriptor(
+ ENamedElement element) {
+ if (element instanceof EStructuralFeature) {
+ EStructuralFeature feature = ((EStructuralFeature) element);
+ EClass eContainingClass = feature.getEContainingClass();
+ EClassifier eType = feature.getEType();
+ if (eContainingClass != null && !eContainingClass.isAbstract()) {
+ element = eContainingClass;
+ } else if (eType instanceof EClass
+ && !((EClass) eType).isAbstract()) {
+ element = eType;
+ }
+ }
+ if (element instanceof EClass) {
+ EClass eClass = (EClass) element;
+ if (!eClass.isAbstract()) {
+ return UMLDiagramEditorPlugin.getInstance()
+ .getItemImageDescriptor(
+ eClass.getEPackage().getEFactoryInstance()
+ .create(eClass));
+ }
+ }
+ // TODO : support structural features
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public static ImageDescriptor getImageDescriptor(ENamedElement element) {
+ String key = getImageRegistryKey(element);
+ ImageDescriptor imageDescriptor = getImageRegistry().getDescriptor(key);
+ if (imageDescriptor == null) {
+ imageDescriptor = getProvidedImageDescriptor(element);
+ if (imageDescriptor == null) {
+ imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
+ }
+ getImageRegistry().put(key, imageDescriptor);
+ }
+ return imageDescriptor;
+ }
+
+ /**
+ * @generated
+ */
+ public static Image getImage(ENamedElement element) {
+ String key = getImageRegistryKey(element);
+ Image image = getImageRegistry().get(key);
+ if (image == null) {
+ ImageDescriptor imageDescriptor = getProvidedImageDescriptor(element);
+ if (imageDescriptor == null) {
+ imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
+ }
+ getImageRegistry().put(key, imageDescriptor);
+ image = getImageRegistry().get(key);
+ }
+ return image;
+ }
+
+ /**
+ * @generated
+ */
+ public static ImageDescriptor getImageDescriptor(IAdaptable hint) {
+ ENamedElement element = getElement(hint);
+ if (element == null) {
+ return null;
+ }
+ return getImageDescriptor(element);
+ }
+
+ /**
+ * @generated
+ */
+ public static Image getImage(IAdaptable hint) {
+ ENamedElement element = getElement(hint);
+ if (element == null) {
+ return null;
+ }
+ return getImage(element);
+ }
+
+ /**
+ * Returns 'type' of the ecore object associated with the hint.
+ *
+ * @generated
+ */
+ public static ENamedElement getElement(IAdaptable hint) {
+ Object type = hint.getAdapter(IElementType.class);
+ if (elements == null) {
+ elements = new IdentityHashMap<IElementType, ENamedElement>();
+
+ elements.put(Model_1000, UMLPackage.eINSTANCE.getModel());
+
+ elements.put(Component_2001, UMLPackage.eINSTANCE.getComponent());
+ }
+ return (ENamedElement) elements.get(type);
+ }
+
+ /**
+ * @generated
+ */
+ private static IElementType getElementType(String id) {
+ return ElementTypeRegistry.getInstance().getType(id);
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean isKnownElementType(IElementType elementType) {
+ if (KNOWN_ELEMENT_TYPES == null) {
+ KNOWN_ELEMENT_TYPES = new HashSet<IElementType>();
+ KNOWN_ELEMENT_TYPES.add(Model_1000);
+ KNOWN_ELEMENT_TYPES.add(Component_2001);
+ }
+ return KNOWN_ELEMENT_TYPES.contains(elementType);
+ }
+
+ /**
+ * @generated
+ */
+ public static IElementType getElementType(int visualID) {
+ switch (visualID) {
+ case ModelEditPart.VISUAL_ID:
+ return Model_1000;
+ case ComponentEditPart.VISUAL_ID:
+ return Component_2001;
+ }
+ return null;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLIconProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLIconProvider.java
new file mode 100644
index 00000000000..5a5b73494a3
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLIconProvider.java
@@ -0,0 +1,31 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.providers;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.common.ui.services.icon.GetIconOperation;
+import org.eclipse.gmf.runtime.common.ui.services.icon.IIconProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class UMLIconProvider extends AbstractProvider implements IIconProvider {
+
+ /**
+ * @generated
+ */
+ public Image getIcon(IAdaptable hint, int flags) {
+ return UMLElementTypes.getImage(hint);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean provides(IOperation operation) {
+ if (operation instanceof GetIconOperation) {
+ return ((GetIconOperation) operation).execute(this) != null;
+ }
+ return false;
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLModelingAssistantProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLModelingAssistantProvider.java
new file mode 100644
index 00000000000..bace27bba21
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLModelingAssistantProvider.java
@@ -0,0 +1,171 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.providers;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.ui.services.modelingassistant.ModelingAssistantProvider;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.Messages;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLDiagramEditorPlugin;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+/**
+ * @generated
+ */
+public class UMLModelingAssistantProvider extends ModelingAssistantProvider {
+
+ /**
+ * @generated
+ */
+ public List getTypesForPopupBar(IAdaptable host) {
+ IGraphicalEditPart editPart = (IGraphicalEditPart) host
+ .getAdapter(IGraphicalEditPart.class);
+ if (editPart instanceof ModelEditPart) {
+ ArrayList<IElementType> types = new ArrayList<IElementType>(1);
+ types.add(UMLElementTypes.Component_2001);
+ return types;
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public List getRelTypesOnSource(IAdaptable source) {
+ IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
+ .getAdapter(IGraphicalEditPart.class);
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public List getRelTypesOnTarget(IAdaptable target) {
+ IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
+ .getAdapter(IGraphicalEditPart.class);
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public List getRelTypesOnSourceAndTarget(IAdaptable source,
+ IAdaptable target) {
+ IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
+ .getAdapter(IGraphicalEditPart.class);
+ IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
+ .getAdapter(IGraphicalEditPart.class);
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public List getTypesForSource(IAdaptable target,
+ IElementType relationshipType) {
+ IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
+ .getAdapter(IGraphicalEditPart.class);
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public List getTypesForTarget(IAdaptable source,
+ IElementType relationshipType) {
+ IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
+ .getAdapter(IGraphicalEditPart.class);
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public EObject selectExistingElementForSource(IAdaptable target,
+ IElementType relationshipType) {
+ return selectExistingElement(target,
+ getTypesForSource(target, relationshipType));
+ }
+
+ /**
+ * @generated
+ */
+ public EObject selectExistingElementForTarget(IAdaptable source,
+ IElementType relationshipType) {
+ return selectExistingElement(source,
+ getTypesForTarget(source, relationshipType));
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject selectExistingElement(IAdaptable host, Collection types) {
+ if (types.isEmpty()) {
+ return null;
+ }
+ IGraphicalEditPart editPart = (IGraphicalEditPart) host
+ .getAdapter(IGraphicalEditPart.class);
+ if (editPart == null) {
+ return null;
+ }
+ Diagram diagram = (Diagram) editPart.getRoot().getContents().getModel();
+ HashSet<EObject> elements = new HashSet<EObject>();
+ for (Iterator<EObject> it = diagram.getElement().eAllContents(); it
+ .hasNext();) {
+ EObject element = it.next();
+ if (isApplicableElement(element, types)) {
+ elements.add(element);
+ }
+ }
+ if (elements.isEmpty()) {
+ return null;
+ }
+ return selectElement((EObject[]) elements.toArray(new EObject[elements
+ .size()]));
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isApplicableElement(EObject element, Collection types) {
+ IElementType type = ElementTypeRegistry.getInstance().getElementType(
+ element);
+ return types.contains(type);
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject selectElement(EObject[] elements) {
+ Shell shell = Display.getCurrent().getActiveShell();
+ ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
+ UMLDiagramEditorPlugin.getInstance()
+ .getItemProvidersAdapterFactory());
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(
+ shell, labelProvider);
+ dialog.setMessage(Messages.UMLModelingAssistantProviderMessage);
+ dialog.setTitle(Messages.UMLModelingAssistantProviderTitle);
+ dialog.setMultipleSelection(false);
+ dialog.setElements(elements);
+ EObject selected = null;
+ if (dialog.open() == Window.OK) {
+ selected = (EObject) dialog.getFirstResult();
+ }
+ return selected;
+ }
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLParserProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLParserProvider.java
new file mode 100644
index 00000000000..288e52dc800
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLParserProvider.java
@@ -0,0 +1,124 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.providers;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentNameEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.parsers.MessageFormatParser;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class UMLParserProvider extends AbstractProvider implements
+ IParserProvider {
+
+ /**
+ * @generated
+ */
+ private IParser componentName_5001Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getComponentName_5001Parser() {
+ if (componentName_5001Parser == null) {
+ EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE
+ .getNamedElement_Name() };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ componentName_5001Parser = parser;
+ }
+ return componentName_5001Parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected IParser getParser(int visualID) {
+ switch (visualID) {
+ case ComponentNameEditPart.VISUAL_ID:
+ return getComponentName_5001Parser();
+ }
+ return null;
+ }
+
+ /**
+ * Utility method that consults ParserService
+ * @generated
+ */
+ public static IParser getParser(IElementType type, EObject object,
+ String parserHint) {
+ return ParserService.getInstance().getParser(
+ new HintAdapter(type, object, parserHint));
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser(IAdaptable hint) {
+ String vid = (String) hint.getAdapter(String.class);
+ if (vid != null) {
+ return getParser(UMLVisualIDRegistry.getVisualID(vid));
+ }
+ View view = (View) hint.getAdapter(View.class);
+ if (view != null) {
+ return getParser(UMLVisualIDRegistry.getVisualID(view));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean provides(IOperation operation) {
+ if (operation instanceof GetParserOperation) {
+ IAdaptable hint = ((GetParserOperation) operation).getHint();
+ if (UMLElementTypes.getElement(hint) == null) {
+ return false;
+ }
+ return getParser(hint) != null;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ private static class HintAdapter extends ParserHintAdapter {
+
+ /**
+ * @generated
+ */
+ private final IElementType elementType;
+
+ /**
+ * @generated
+ */
+ public HintAdapter(IElementType type, EObject object, String parserHint) {
+ super(object, parserHint);
+ assert type != null;
+ elementType = type;
+ }
+
+ /**
+ * @generated
+ */
+ public Object getAdapter(Class adapter) {
+ if (IElementType.class.equals(adapter)) {
+ return elementType;
+ }
+ return super.getAdapter(adapter);
+ }
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLViewProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLViewProvider.java
new file mode 100644
index 00000000000..c6ccc0f3716
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/providers/UMLViewProvider.java
@@ -0,0 +1,381 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.providers;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
+import org.eclipse.gmf.runtime.notation.DecorationNode;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.FillStyle;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.MeasurementUnit;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.Shape;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.papyrus.diagram.common.helper.PreferenceInitializerForElementHelper;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ComponentNameEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.preferences.utils.GradientPreferenceConverter;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+
+/**
+ * @generated
+ */
+public class UMLViewProvider extends AbstractProvider implements IViewProvider {
+
+ /**
+ * @generated
+ */
+ public final boolean provides(IOperation operation) {
+ if (operation instanceof CreateViewForKindOperation) {
+ return provides((CreateViewForKindOperation) operation);
+ }
+ assert operation instanceof CreateViewOperation;
+ if (operation instanceof CreateDiagramViewOperation) {
+ return provides((CreateDiagramViewOperation) operation);
+ } else if (operation instanceof CreateEdgeViewOperation) {
+ return provides((CreateEdgeViewOperation) operation);
+ } else if (operation instanceof CreateNodeViewOperation) {
+ return provides((CreateNodeViewOperation) operation);
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateViewForKindOperation op) {
+ /*
+ if (op.getViewKind() == Node.class)
+ return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+ if (op.getViewKind() == Edge.class)
+ return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+ */
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateDiagramViewOperation op) {
+ return ModelEditPart.MODEL_ID.equals(op.getSemanticHint())
+ && UMLVisualIDRegistry.getDiagramVisualID(getSemanticElement(op
+ .getSemanticAdapter())) != -1;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateNodeViewOperation op) {
+ if (op.getContainerView() == null) {
+ return false;
+ }
+ IElementType elementType = getSemanticElementType(op
+ .getSemanticAdapter());
+ EObject domainElement = getSemanticElement(op.getSemanticAdapter());
+ int visualID;
+ if (op.getSemanticHint() == null) {
+ // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy.
+ // In this situation there should be NO elementType, visualID will be determined
+ // by VisualIDRegistry.getNodeVisualID() for domainElement.
+ if (elementType != null || domainElement == null) {
+ return false;
+ }
+ visualID = UMLVisualIDRegistry.getNodeVisualID(
+ op.getContainerView(), domainElement);
+ } else {
+ visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint());
+ if (elementType != null) {
+ if (!UMLElementTypes.isKnownElementType(elementType)
+ || (!(elementType instanceof IHintedType))) {
+ return false; // foreign element type
+ }
+ String elementTypeHint = ((IHintedType) elementType)
+ .getSemanticHint();
+ if (!op.getSemanticHint().equals(elementTypeHint)) {
+ return false; // if semantic hint is specified it should be the same as in element type
+ }
+ if (domainElement != null
+ && visualID != UMLVisualIDRegistry.getNodeVisualID(
+ op.getContainerView(), domainElement)) {
+ return false; // visual id for node EClass should match visual id from element type
+ }
+ } else {
+ if (!ModelEditPart.MODEL_ID.equals(UMLVisualIDRegistry
+ .getModelID(op.getContainerView()))) {
+ return false; // foreign diagram
+ }
+ switch (visualID) {
+ case ComponentEditPart.VISUAL_ID:
+ if (domainElement == null
+ || visualID != UMLVisualIDRegistry.getNodeVisualID(
+ op.getContainerView(), domainElement)) {
+ return false; // visual id in semantic hint should match visual id for domain element
+ }
+ break;
+ default:
+ return false;
+ }
+ }
+ }
+ return ComponentEditPart.VISUAL_ID == visualID;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateEdgeViewOperation op) {
+ IElementType elementType = getSemanticElementType(op
+ .getSemanticAdapter());
+ if (!UMLElementTypes.isKnownElementType(elementType)
+ || (!(elementType instanceof IHintedType))) {
+ return false; // foreign element type
+ }
+ String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
+ if (elementTypeHint == null
+ || (op.getSemanticHint() != null && !elementTypeHint.equals(op
+ .getSemanticHint()))) {
+ return false; // our hint is visual id and must be specified, and it should be the same as in element type
+ }
+ int visualID = UMLVisualIDRegistry.getVisualID(elementTypeHint);
+ EObject domainElement = getSemanticElement(op.getSemanticAdapter());
+ if (domainElement != null
+ && visualID != UMLVisualIDRegistry
+ .getLinkWithClassVisualID(domainElement)) {
+ return false; // visual id for link EClass should match visual id from element type
+ }
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ public Diagram createDiagram(IAdaptable semanticAdapter,
+ String diagramKind, PreferencesHint preferencesHint) {
+ Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
+ diagram.setType(ModelEditPart.MODEL_ID);
+ diagram.setElement(getSemanticElement(semanticAdapter));
+ diagram.setMeasurementUnit(MeasurementUnit.PIXEL_LITERAL);
+ return diagram;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createNode(IAdaptable semanticAdapter, View containerView,
+ String semanticHint, int index, boolean persisted,
+ PreferencesHint preferencesHint) {
+ final EObject domainElement = getSemanticElement(semanticAdapter);
+ final int visualID;
+ if (semanticHint == null) {
+ visualID = UMLVisualIDRegistry.getNodeVisualID(containerView,
+ domainElement);
+ } else {
+ visualID = UMLVisualIDRegistry.getVisualID(semanticHint);
+ }
+ switch (visualID) {
+ case ComponentEditPart.VISUAL_ID:
+ return createComponent_2001(domainElement, containerView, index,
+ persisted, preferencesHint);
+ }
+ // can't happen, provided #provides(CreateNodeViewOperation) is correct
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createEdge(IAdaptable semanticAdapter, View containerView,
+ String semanticHint, int index, boolean persisted,
+ PreferencesHint preferencesHint) {
+ IElementType elementType = getSemanticElementType(semanticAdapter);
+ String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
+ switch (UMLVisualIDRegistry.getVisualID(elementTypeHint)) {
+ }
+ // can never happen, provided #provides(CreateEdgeViewOperation) is correct
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createComponent_2001(EObject domainElement, View containerView,
+ int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ComponentEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint
+ .getPreferenceStore();
+
+ PreferenceInitializerForElementHelper.initForegroundFromPrefs(node,
+ prefStore, "Component");
+
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node,
+ prefStore, "Component");
+
+ PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node,
+ prefStore, "Component");
+
+ Node label5001 = createLabel(node,
+ UMLVisualIDRegistry.getType(ComponentNameEditPart.VISUAL_ID));
+
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ protected void stampShortcut(View containerView, Node target) {
+ if (!ModelEditPart.MODEL_ID.equals(UMLVisualIDRegistry
+ .getModelID(containerView))) {
+ EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE
+ .createEAnnotation();
+ shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$
+ shortcutAnnotation.getDetails().put(
+ "modelID", ModelEditPart.MODEL_ID); //$NON-NLS-1$
+ target.getEAnnotations().add(shortcutAnnotation);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Node createLabel(View owner, String hint) {
+ DecorationNode rv = NotationFactory.eINSTANCE.createDecorationNode();
+ rv.setType(hint);
+ ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true);
+ return rv;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getSemanticElement(IAdaptable semanticAdapter) {
+ if (semanticAdapter == null) {
+ return null;
+ }
+ EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
+ if (eObject != null) {
+ return EMFCoreUtil.resolve(
+ TransactionUtil.getEditingDomain(eObject), eObject);
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected IElementType getSemanticElementType(IAdaptable semanticAdapter) {
+ if (semanticAdapter == null) {
+ return null;
+ }
+ return (IElementType) semanticAdapter.getAdapter(IElementType.class);
+ }
+
+ /**
+ * @generated
+ */
+ private void initFontStyleFromPrefs(View view,
+ final IPreferenceStore store, String elementName) {
+ String fontConstant = PreferenceConstantHelper.getElementConstant(
+ elementName, PreferenceConstantHelper.FONT);
+ String fontColorConstant = PreferenceConstantHelper.getElementConstant(
+ elementName, PreferenceConstantHelper.COLOR_FONT);
+
+ FontStyle viewFontStyle = (FontStyle) view
+ .getStyle(NotationPackage.Literals.FONT_STYLE);
+ if (viewFontStyle != null) {
+ FontData fontData = PreferenceConverter.getFontData(store,
+ fontConstant);
+ viewFontStyle.setFontName(fontData.getName());
+ viewFontStyle.setFontHeight(fontData.getHeight());
+ viewFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
+ viewFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
+
+ org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter
+ .getColor(store, fontColorConstant);
+ viewFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB)
+ .intValue());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void initForegroundFromPrefs(View view,
+ final IPreferenceStore store, String elementName) {
+ String lineColorConstant = PreferenceConstantHelper.getElementConstant(
+ elementName, PreferenceConstantHelper.COLOR_LINE);
+ org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(
+ store, lineColorConstant);
+ ViewUtil.setStructuralFeatureValue(view,
+ NotationPackage.eINSTANCE.getLineStyle_LineColor(),
+ FigureUtilities.RGBToInteger(lineRGB));
+ }
+
+ /**
+ * @generated
+ */
+ private void initBackgroundFromPrefs(View view,
+ final IPreferenceStore store, String elementName) {
+ String fillColorConstant = PreferenceConstantHelper.getElementConstant(
+ elementName, PreferenceConstantHelper.COLOR_FILL);
+ String gradientColorConstant = PreferenceConstantHelper
+ .getElementConstant(elementName,
+ PreferenceConstantHelper.COLOR_GRADIENT);
+ String gradientPolicyConstant = PreferenceConstantHelper
+ .getElementConstant(elementName,
+ PreferenceConstantHelper.GRADIENT_POLICY);
+
+ org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(
+ store, fillColorConstant);
+ ViewUtil.setStructuralFeatureValue(view,
+ NotationPackage.eINSTANCE.getFillStyle_FillColor(),
+ FigureUtilities.RGBToInteger(fillRGB));
+
+ FillStyle fillStyle = (FillStyle) view
+ .getStyle(NotationPackage.Literals.FILL_STYLE);
+ fillStyle
+ .setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue());
+
+ ;
+ if (store.getBoolean(gradientPolicyConstant)) {
+ GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(
+ store.getString(gradientColorConstant));
+ fillStyle
+ .setGradient(gradientPreferenceConverter.getGradientData());
+ fillStyle.setTransparency(gradientPreferenceConverter
+ .getTransparency());
+ }
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/sheet/UMLPropertySection.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/sheet/UMLPropertySection.java
new file mode 100644
index 00000000000..01417565693
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/sheet/UMLPropertySection.java
@@ -0,0 +1,117 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.sheet;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.ui.provider.PropertySource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.properties.sections.AdvancedPropertySection;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.IPropertySourceProvider;
+
+/**
+ * @generated
+ */
+public class UMLPropertySection extends AdvancedPropertySection implements
+ IPropertySourceProvider {
+
+ /**
+ * @generated
+ */
+ public IPropertySource getPropertySource(Object object) {
+ if (object instanceof IPropertySource) {
+ return (IPropertySource) object;
+ }
+ AdapterFactory af = getAdapterFactory(object);
+ if (af != null) {
+ IItemPropertySource ips = (IItemPropertySource) af.adapt(object,
+ IItemPropertySource.class);
+ if (ips != null) {
+ return new PropertySource(object, ips);
+ }
+ }
+ if (object instanceof IAdaptable) {
+ return (IPropertySource) ((IAdaptable) object)
+ .getAdapter(IPropertySource.class);
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected IPropertySourceProvider getPropertySourceProvider() {
+ return this;
+ }
+
+ /**
+ * Modify/unwrap selection.
+ * @generated
+ */
+ protected Object transformSelection(Object selected) {
+
+ if (selected instanceof EditPart) {
+ Object model = ((EditPart) selected).getModel();
+ return model instanceof View ? ((View) model).getElement() : null;
+ }
+ if (selected instanceof View) {
+ return ((View) selected).getElement();
+ }
+ if (selected instanceof IAdaptable) {
+ View view = (View) ((IAdaptable) selected).getAdapter(View.class);
+ if (view != null) {
+ return view.getElement();
+ }
+ }
+ return selected;
+ }
+
+ /**
+ * @generated
+ */
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ if (selection.isEmpty()
+ || false == selection instanceof StructuredSelection) {
+ super.setInput(part, selection);
+ return;
+ }
+ final StructuredSelection structuredSelection = ((StructuredSelection) selection);
+ ArrayList transformedSelection = new ArrayList(
+ structuredSelection.size());
+ for (Iterator it = structuredSelection.iterator(); it.hasNext();) {
+ Object r = transformSelection(it.next());
+ if (r != null) {
+ transformedSelection.add(r);
+ }
+ }
+ super.setInput(part, new StructuredSelection(transformedSelection));
+ }
+
+ /**
+ * @generated
+ */
+ protected AdapterFactory getAdapterFactory(Object object) {
+ if (getEditingDomain() instanceof AdapterFactoryEditingDomain) {
+ return ((AdapterFactoryEditingDomain) getEditingDomain())
+ .getAdapterFactory();
+ }
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(object);
+ if (editingDomain != null) {
+ return ((AdapterFactoryEditingDomain) editingDomain)
+ .getAdapterFactory();
+ }
+ return null;
+ }
+
+}
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/sheet/UMLSheetLabelProvider.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/sheet/UMLSheetLabelProvider.java
new file mode 100644
index 00000000000..75a51a70c39
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/sheet/UMLSheetLabelProvider.java
@@ -0,0 +1,80 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.sheet;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.example.diagram.simplediagram.navigator.UMLNavigatorGroup;
+import org.eclipse.papyrus.example.diagram.simplediagram.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLElementTypes;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class UMLSheetLabelProvider extends BaseLabelProvider implements
+ ILabelProvider {
+
+ /**
+ * @generated
+ */
+ public String getText(Object element) {
+ element = unwrap(element);
+ if (element instanceof UMLNavigatorGroup) {
+ return ((UMLNavigatorGroup) element).getGroupName();
+ }
+ IElementType etype = getElementType(getView(element));
+ return etype == null ? "" : etype.getDisplayName();
+ }
+
+ /**
+ * @generated
+ */
+ public Image getImage(Object element) {
+ IElementType etype = getElementType(getView(unwrap(element)));
+ return etype == null ? null : UMLElementTypes.getImage(etype);
+ }
+
+ /**
+ * @generated
+ */
+ private Object unwrap(Object element) {
+ if (element instanceof IStructuredSelection) {
+ return ((IStructuredSelection) element).getFirstElement();
+ }
+ return element;
+ }
+
+ /**
+ * @generated
+ */
+ private View getView(Object element) {
+ if (element instanceof View) {
+ return (View) element;
+ }
+ if (element instanceof IAdaptable) {
+ return (View) ((IAdaptable) element).getAdapter(View.class);
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private IElementType getElementType(View view) {
+ // For intermediate views climb up the containment hierarchy to find the one associated with an element type.
+ while (view != null) {
+ int vid = UMLVisualIDRegistry.getVisualID(view);
+ IElementType etype = UMLElementTypes.getElementType(vid);
+ if (etype != null) {
+ return etype;
+ }
+ view = view.eContainer() instanceof View ? (View) view.eContainer()
+ : null;
+ }
+ return null;
+ }
+
+}

Back to the top