Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2020-03-27 11:03:14 +0000
committervincent lorenzo2020-03-31 15:06:23 +0000
commit28f97f2babda87ae35aad3756d577e1cd2ebec76 (patch)
tree58e91f9b92a10f91bc3ad666d82ad825bb36d595
parentf3da59e577a6d9c9e02a930950fc6f23b2a5db21 (diff)
downloadorg.eclipse.papyrus-28f97f2babda87ae35aad3756d577e1cd2ebec76.tar.gz
org.eclipse.papyrus-28f97f2babda87ae35aad3756d577e1cd2ebec76.tar.xz
org.eclipse.papyrus-28f97f2babda87ae35aad3756d577e1cd2ebec76.zip
Bug 561512: [StateMachineDiagram] The creation of the first region in a State must use the Papyrus Edition Service
Change-Id: I57e0ac3b7f423ca110678af49d5ac1a8aa33bab1 Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/META-INF/MANIFEST.MF2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/commands/CustomFirstRegionInCompositeStateCreateElementCommand.java47
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/commands/CustomFirstRegionInStateMachineCreateElementCommand.java28
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/pom.xml2
4 files changed, 48 insertions, 31 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/META-INF/MANIFEST.MF
index 311846f9c47..7b8e62e9ad1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/META-INF/MANIFEST.MF
@@ -78,7 +78,7 @@ Require-Bundle: org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)";visibility
Bundle-Vendor: %providerName
Ant-Version: Apache Ant 1.7.0
Eclipse-LazyStart: true
-Bundle-Version: 3.2.100.qualifier
+Bundle-Version: 3.2.200.qualifier
Bundle-Activator: org.eclipse.papyrus.uml.diagram.statemachine.part.UMLDiagramEditorPlugin
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.statemachine; singleton:=true
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/commands/CustomFirstRegionInCompositeStateCreateElementCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/commands/CustomFirstRegionInCompositeStateCreateElementCommand.java
index 9ed0b2c2aa9..cdfa80bd483 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/commands/CustomFirstRegionInCompositeStateCreateElementCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/commands/CustomFirstRegionInCompositeStateCreateElementCommand.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2020 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) - vincent.lorenzo@cea.fr - bug 561512
*/
package org.eclipse.papyrus.uml.diagram.statemachine.custom.commands;
@@ -18,6 +19,7 @@ import java.util.Iterator;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -34,16 +36,17 @@ import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationFactory;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.adapter.SemanticAdapter;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.uml.diagram.statemachine.custom.helpers.Zone;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.RegionEditPart;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.StateCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.StateNameEditPart;
import org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.statemachine.providers.ElementInitializers;
import org.eclipse.papyrus.uml.diagram.statemachine.providers.UMLElementTypes;
import org.eclipse.uml2.uml.Region;
import org.eclipse.uml2.uml.State;
-import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
/**
* Create a region (UML and associated view)
@@ -53,14 +56,16 @@ public class CustomFirstRegionInCompositeStateCreateElementCommand extends Abstr
IAdaptable adaptableForDropped = null;
PreferencesHint prefHints;
CreateViewRequest.ViewDescriptor viewDescriptor;
- CreateElementRequest createElementRequest;
String dropLocation = Zone.NONE;
-
+
+ CreateElementRequest createElementRequest;
+
+
/**
* An existing UML region
*/
protected Region umlRegion;
-
+
public CustomFirstRegionInCompositeStateCreateElementCommand(IAdaptable adaptable, IAdaptable adaptableForDropped, PreferencesHint prefHints, TransactionalEditingDomain domain, String label, String dropLocation) {
super(domain, label, null);
this.adaptable = adaptable;
@@ -76,16 +81,18 @@ public class CustomFirstRegionInCompositeStateCreateElementCommand extends Abstr
/**
* Pass an existing (semantic) region. In this case, no new region is created during command
- * execution, only the view is passed.
- * @param umlRegion an existing semantic region
+ * execution, only the view is passed.
+ *
+ * @param umlRegion
+ * an existing semantic region
*/
public void useExistingRegion(Region umlRegion) {
- this.umlRegion = umlRegion;
+ this.umlRegion = umlRegion;
}
-
+
@Override
public boolean canExecute() {
- View compartment = (View) adaptable.getAdapter(View.class);
+ View compartment = adaptable.getAdapter(View.class);
if (compartment.getChildren().isEmpty()) {
View owner = (View) compartment.eContainer();
State state = (State) owner.getElement();
@@ -96,6 +103,10 @@ public class CustomFirstRegionInCompositeStateCreateElementCommand extends Abstr
return false;
}
+ /**
+ * TODO : useless since 3.2.200
+ */
+ @Deprecated
protected void doConfigure(Region newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
IElementType elementType = createElementRequest.getElementType();
ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
@@ -123,15 +134,15 @@ public class CustomFirstRegionInCompositeStateCreateElementCommand extends Abstr
width = Zone.defaultWidth;
Zone.setWidth(ownerView, width);
}
-
+
if (adaptableForDropped == null) {
if (umlRegion == null) {
- umlRegion = UMLFactory.eINSTANCE.createRegion();
- createElementRequest = new CreateElementRequest(getEditingDomain(), ownerView, UMLElementTypes.Region_Shape);
- State umlState = (State) ownerView.getElement();
- umlState.getRegions().add(umlRegion);
- ElementInitializers.getInstance().init_Region_Shape(umlRegion);
- doConfigure(umlRegion, monitor, info);
+ final State umlState = (State) ownerView.getElement();
+ final CreateElementRequest request = new CreateElementRequest(umlState, org.eclipse.papyrus.uml.service.types.element.UMLElementTypes.REGION, UMLPackage.eINSTANCE.getState_Region());
+ final IElementEditService service = ElementEditServiceUtils.getCommandProvider(umlState);
+ final ICommand cmd = service.getEditCommand(request);
+ cmd.execute(new NullProgressMonitor(), null);
+ umlRegion = (Region) request.getNewElement();
}
adaptableForDropped = new SemanticAdapter(umlRegion, null);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/commands/CustomFirstRegionInStateMachineCreateElementCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/commands/CustomFirstRegionInStateMachineCreateElementCommand.java
index 161510b8f99..f60faae48ca 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/commands/CustomFirstRegionInStateMachineCreateElementCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/commands/CustomFirstRegionInStateMachineCreateElementCommand.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2020 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,12 +10,14 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) - vincent.lorenzo@cea.fr - bug 561512
*/
package org.eclipse.papyrus.uml.diagram.statemachine.custom.commands;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -33,12 +35,13 @@ import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.adapter.SemanticAdapter;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.uml.diagram.statemachine.custom.helpers.Zone;
-import org.eclipse.papyrus.uml.diagram.statemachine.providers.ElementInitializers;
import org.eclipse.papyrus.uml.diagram.statemachine.providers.UMLElementTypes;
import org.eclipse.uml2.uml.Region;
-import org.eclipse.uml2.uml.StateMachine;
-import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.State;
+import org.eclipse.uml2.uml.UMLPackage;
/**
* Create a region.
@@ -64,6 +67,10 @@ public class CustomFirstRegionInStateMachineCreateElementCommand extends Abstrac
this.dropLocation = dropLocation;
}
+ /**
+ * TODO : useless since 3.2.200
+ */
+ @Deprecated
protected void doConfigure(Region newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
IElementType elementType = createElementRequest.getElementType();
ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
@@ -92,13 +99,12 @@ public class CustomFirstRegionInStateMachineCreateElementCommand extends Abstrac
Zone.setWidth(ownerView, width);
}
if (adaptableForDropped == null) {
- Region umlRegion = UMLFactory.eINSTANCE.createRegion();
- createElementRequest = new CreateElementRequest(getEditingDomain(), ownerView, UMLElementTypes.Region_Shape);
- StateMachine umlState = (StateMachine) ownerView.getElement();
- umlState.getRegions().add(umlRegion);
- ElementInitializers.getInstance().init_Region_Shape(umlRegion);
- doConfigure(umlRegion, monitor, info);
- adaptableForDropped = new SemanticAdapter(umlRegion, null);
+ final State umlState = (State) ownerView.getElement();
+ final CreateElementRequest request = new CreateElementRequest(umlState, org.eclipse.papyrus.uml.service.types.element.UMLElementTypes.REGION, UMLPackage.eINSTANCE.getState_Region());
+ final IElementEditService service = ElementEditServiceUtils.getCommandProvider(umlState);
+ final ICommand cmd = service.getEditCommand(request);
+ cmd.execute(new NullProgressMonitor(), null);
+ adaptableForDropped = new SemanticAdapter(request.getNewElement(), null);
}
// create a view for the new region on the stateMachineCompartment
String semanticHint = ((IHintedType) UMLElementTypes.Region_Shape).getSemanticHint();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/pom.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/pom.xml
index fdb8f3056c7..7f40b6bdaaf 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/pom.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/pom.xml
@@ -9,6 +9,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.diagram.statemachine</artifactId>
- <version>3.2.100-SNAPSHOT</version>
+ <version>3.2.200-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>

Back to the top