summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Wouters2014-03-18 06:12:20 (EDT)
committerVincent Lorenzo2014-03-18 10:11:22 (EDT)
commitdf564cab87942def943c87fa6ef0609e7c5dff5e (patch)
treeb5297782fa8f5755962ac90b98bf87072d61aab5
parentc84d4e3beb08abcd3a93ea432759b5d5bdb44550 (diff)
downloadorg.eclipse.papyrus-df564cab87942def943c87fa6ef0609e7c5dff5e.zip
org.eclipse.papyrus-df564cab87942def943c87fa6ef0609e7c5dff5e.tar.gz
org.eclipse.papyrus-df564cab87942def943c87fa6ef0609e7c5dff5e.tar.bz2
399860: Fixing issue with old Package diagrams not opening properly
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399860 Signed-off-by: Laurent Wouters <laurent.wouters@cea.fr>
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/PackageDiagramEditorFactory.java82
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/plugin.xml7
2 files changed, 88 insertions, 1 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/PackageDiagramEditorFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/PackageDiagramEditorFactory.java
new file mode 100755
index 0000000..48ffe26
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/PackageDiagramEditorFactory.java
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.clazz;
+
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceSet;
+import org.eclipse.papyrus.infra.gmfdiag.common.GmfEditorFactory;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils;
+import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
+
+/**
+ * Factory for legacy package diagrams tht migrates them to the viewpoints-defined ones
+ *
+ * @author Laurent Wouters
+ *
+ */
+public class PackageDiagramEditorFactory extends GmfEditorFactory {
+
+ /**
+ * Initializes this factory
+ */
+ public PackageDiagramEditorFactory() {
+ super(UmlClassDiagramForMultiEditor.class, "Package");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.GmfEditorFactory#createIPageModel(java.lang.Object)
+ */
+ public IPageModel createIPageModel(Object pageIdentifier) {
+ migrate((Diagram) pageIdentifier);
+ return super.createIPageModel(pageIdentifier);
+ }
+
+ /**
+ * Migrate the given package diagram to the viewpoints-defined one
+ *
+ * @param diagram
+ * The diagram to migrate
+ */
+ private void migrate(final Diagram diagram) {
+ TransactionalEditingDomain domain = null;
+ try {
+ domain = ServiceUtilsForResourceSet.getInstance().getTransactionalEditingDomain(diagram.eResource().getResourceSet());
+ } catch (ServiceException e) {
+ return;
+ }
+ domain.getCommandStack().execute(new AbstractCommand() {
+ @Override
+ public void execute() {
+ ViewPrototype proto = DiagramUtils.getPrototype(diagram);
+ DiagramUtils.setPrototype(diagram, proto);
+ diagram.setType("PapyrusUMLClassDiagram");
+ }
+ @Override
+ public void redo() {
+ execute();
+ }
+
+ @Override
+ public boolean canExecute() {
+ return true;
+ }
+ });
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/plugin.xml
index cfe2cee..55733b1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/plugin.xml
@@ -1365,7 +1365,12 @@
id="org.eclipse.papyrus.uml.diagram.clazz.CreateClassDiagramCommand"
language="uml"
label="UML Class Diagram">
- </creationCommand>
+ </creationCommand>
+ <editorDiagram
+ actionBarContributorId="org.eclipse.papyrus.uml.diagram.common.part.UMLDiagramActionBarContributor"
+ factoryClass="org.eclipse.papyrus.uml.diagram.clazz.PackageDiagramEditorFactory"
+ icon="platform:/plugin/org.eclipse.papyrus.infra.viewpoints.policy/icons/Diagram_Package.gif">
+ </editorDiagram>
</extension>
<!--extension
point="org.eclipse.gmf.runtime.diagram.ui.editpolicyProviders">