summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradaussy2013-12-17 12:32:31 (EST)
committeradaussy2013-12-17 12:32:31 (EST)
commit5a541d893b1227308530d22a3af02beab720303c (patch)
treeb7d3cbe068c80cc39e435e9c6ae1904f2d1f1ae6
parent93f5f530587595ce13556b0288a23df0b7f45d4b (diff)
downloadorg.eclipse.papyrus-5a541d893b1227308530d22a3af02beab720303c.zip
org.eclipse.papyrus-5a541d893b1227308530d22a3af02beab720303c.tar.gz
org.eclipse.papyrus-5a541d893b1227308530d22a3af02beab720303c.tar.bz2
Bug 402905 - [Control Mode] Refactoring of the control command to be
more stable https://bugs.eclipse.org/bugs/show_bug.cgi?id=402905 Compute the affected resource with a control command for collab mode
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/META-INF/MANIFEST.MF1
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/BasicControlCommand.java17
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/helper/ControlCommandHelper.java19
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/MoveStereotypeApplicationToControlResource.java28
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/participants/UMLProfileParticipant.java5
5 files changed, 46 insertions, 24 deletions
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/META-INF/MANIFEST.MF b/plugins/core/org.eclipse.papyrus.controlmode/META-INF/MANIFEST.MF
index feebdc3..ddd5482 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/META-INF/MANIFEST.MF
+++ b/plugins/core/org.eclipse.papyrus.controlmode/META-INF/MANIFEST.MF
@@ -2,6 +2,7 @@ Manifest-Version: 1.0
Export-Package: org.eclipse.papyrus.controlmode,
org.eclipse.papyrus.controlmode.action,
org.eclipse.papyrus.controlmode.commands,
+ org.eclipse.papyrus.controlmode.helper,
org.eclipse.papyrus.controlmode.interfaces,
org.eclipse.papyrus.controlmode.request,
org.eclipse.papyrus.controlmode.ui
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/BasicControlCommand.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/BasicControlCommand.java
index 970085b..6d3b771 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/BasicControlCommand.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/BasicControlCommand.java
@@ -14,8 +14,6 @@
package org.eclipse.papyrus.controlmode.commands;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
@@ -25,14 +23,10 @@ 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.workspace.util.WorkspaceSynchronizer;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.papyrus.controlmode.helper.ControlCommandHelper;
import org.eclipse.papyrus.controlmode.request.ControlModeRequest;
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-
/**
* This command do the basic operation of the control. That is to say move the semantic element to a new resource previously created.
* This resource id got thanks to the request.
@@ -48,18 +42,11 @@ public class BasicControlCommand extends AbstractControlCommandRequest {
*/
public BasicControlCommand(ControlModeRequest request) {
super("Control command", null, request);
- Set<Resource> affectedResources = new HashSet<Resource>();
- ControlCommandHelper.getAffectedResourceByControlCommand(request.getTargetObject(), affectedResources);
- Collection<IFile> affectedFile = Collections2.transform(affectedResources, new Function<Resource, IFile>() {
-
- public IFile apply(Resource arg0) {
- return WorkspaceSynchronizer.getFile(arg0);
- }
- });
- System.out.println(affectedFile);
+ Collection<IFile> affectedFile = ControlCommandHelper.getAffecterFileByMoveToNewResouceCommand(request.getTargetObject());
getAffectedFiles().addAll(affectedFile);
}
+
/*
* (non-Javadoc)
*
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/helper/ControlCommandHelper.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/helper/ControlCommandHelper.java
index 6ab2d34..628d32c 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/helper/ControlCommandHelper.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/helper/ControlCommandHelper.java
@@ -14,15 +14,21 @@
package org.eclipse.papyrus.controlmode.helper;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
import org.eclipse.papyrus.core.utils.PapyrusEcoreUtils;
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+
/**
* Helper for control command
*
@@ -50,6 +56,19 @@ public class ControlCommandHelper {
return false;
}
+ public static Collection<IFile> getAffecterFileByMoveToNewResouceCommand(EObject eObject) {
+ Set<Resource> affectedResources = new HashSet<Resource>();
+ ControlCommandHelper.getAffectedResourceByControlCommand(eObject, affectedResources);
+ Collection<IFile> affectedFile = Collections2.transform(affectedResources, new Function<Resource, IFile>() {
+
+ public IFile apply(Resource arg0) {
+ return WorkspaceSynchronizer.getFile(arg0);
+ }
+ });
+ return affectedFile;
+ }
+
+
public static Set<Resource> getAffectedResourceByControlCommand(EObject source, Set<Resource> affectedResources) {
Collection<Setting> settings = PapyrusEcoreUtils.getUsages(source);
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/MoveStereotypeApplicationToControlResource.java b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/MoveStereotypeApplicationToControlResource.java
index be25e9f..6aae6c3 100644
--- a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/MoveStereotypeApplicationToControlResource.java
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/MoveStereotypeApplicationToControlResource.java
@@ -13,10 +13,11 @@
*****************************************************************************/
package org.eclipse.papyrus.controlmode.umlprofiles.commands;
-import java.util.List;
+import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.EList;
@@ -26,6 +27,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.papyrus.controlmode.commands.AbstractControlCommandRequest;
+import org.eclipse.papyrus.controlmode.helper.ControlCommandHelper;
import org.eclipse.papyrus.controlmode.request.ControlModeRequest;
import org.eclipse.papyrus.resource.uml.UmlModel;
import org.eclipse.uml2.uml.Element;
@@ -41,9 +43,25 @@ import com.google.common.collect.Sets;
public final class MoveStereotypeApplicationToControlResource extends AbstractControlCommandRequest {
- @SuppressWarnings("rawtypes")
- public MoveStereotypeApplicationToControlResource(List affectedFiles, ControlModeRequest request) {
- super("Move setereotype application", affectedFiles, request);
+ public MoveStereotypeApplicationToControlResource(ControlModeRequest request) {
+ super("Move setereotype application", null, request);
+ Element elem = (Element)getRequest().getTargetObject();
+ TreeIterator<Object> contents = EcoreUtil.getAllProperContents(elem, true);
+ Set<Element> elements = Sets.newHashSet(elem);
+ while(contents.hasNext()) {
+ EObject eObject = (EObject)contents.next();
+ if(eObject instanceof Element) {
+ elements.add((Element)eObject);
+ }
+ }
+ Set<IFile> affectedFiles = new HashSet<IFile>();
+ for(Element e : elements) {
+ EList<EObject> stereotypeApplications = e.getStereotypeApplications();
+ for(EObject stereotype : stereotypeApplications) {
+ affectedFiles.addAll(ControlCommandHelper.getAffecterFileByMoveToNewResouceCommand(stereotype));
+ }
+ }
+ getAffectedFiles().addAll(affectedFiles);
}
@Override
@@ -69,4 +87,4 @@ public final class MoveStereotypeApplicationToControlResource extends AbstractCo
return CommandResult.newOKCommandResult();
}
-} \ No newline at end of file
+}
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/participants/UMLProfileParticipant.java b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/participants/UMLProfileParticipant.java
index 0176e89..3ef7dd3 100644
--- a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/participants/UMLProfileParticipant.java
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/participants/UMLProfileParticipant.java
@@ -13,10 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrus.controlmode.umlprofiles.participants;
-import java.util.Collections;
-
import org.eclipse.core.commands.operations.IUndoableOperation;
-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.papyrus.controlmode.commands.AskUserCommand;
@@ -70,7 +67,7 @@ public class UMLProfileParticipant implements IControlCommandParticipant, IUncon
* @return
*/
protected IUndoableOperation getMoveStereotypeCommand(final ControlModeRequest request) {
- return new MoveStereotypeApplicationToControlResource(Collections.singletonList(WorkspaceSynchronizer.getFile(request.getTargetObject().eResource())), request);
+ return new MoveStereotypeApplicationToControlResource(request);
}
/*