From 438f54e700026b102ca8524a3718faa111f89f17 Mon Sep 17 00:00:00 2001
From: mvelten
Date: Thu, 25 Apr 2013 13:49:26 +0000
Subject: 402905: [Control Mode] Refactoring of the control command to be more
stable https://bugs.eclipse.org/bugs/show_bug.cgi?id=402905
add ProfileFacetSet control participant, based on the previous one.
NOT TESTED since I don't know the functionality, but it should at least fix the build.
---
.../META-INF/MANIFEST.MF | 3 +-
.../plugin.xml | 15 ++---
.../controlmode/ProfileFacetSetControlCommand.java | 72 ----------------------
.../ProfileFacetSetControlParticipant.java | 57 +++++++++++++++++
.../ProfileFacetSetUncontrolCommand.java | 61 ------------------
.../utils/ProfileFacetSetMoveHelper.java | 60 +++++++++---------
6 files changed, 94 insertions(+), 174 deletions(-)
delete mode 100644 plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetControlCommand.java
create mode 100644 plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetControlParticipant.java
delete mode 100644 plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetUncontrolCommand.java
(limited to 'plugins/uml')
diff --git a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/META-INF/MANIFEST.MF
index bfcd7dbe8f0..62f49832b27 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/META-INF/MANIFEST.MF
+++ b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/META-INF/MANIFEST.MF
@@ -25,5 +25,6 @@ Require-Bundle: org.eclipse.core.commands,
org.eclipse.papyrus.infra.gmfdiag.commands,
org.eclipse.papyrus.infra.emf,
org.eclipse.papyrus.infra.core.log,
- org.eclipse.papyrus.infra.services.resourceloading.preferences;bundle-version="0.10.0"
+ org.eclipse.papyrus.infra.services.resourceloading.preferences;bundle-version="0.10.0",
+ org.eclipse.emf.validation.ui;bundle-version="1.7.0"
diff --git a/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/plugin.xml b/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/plugin.xml
index 7782fcc7291..b8b515f2c62 100644
--- a/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/plugin.xml
+++ b/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/plugin.xml
@@ -10,15 +10,6 @@
-
-
-
-
-
-
@@ -41,4 +32,10 @@
+
+
+
+
diff --git a/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetControlCommand.java b/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetControlCommand.java
deleted file mode 100644
index 16b9f5b24db..00000000000
--- a/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetControlCommand.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 Atos.
- *
- *
- * 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:
- * Olivier Melois (ATOS) olivier.melois@atos.net - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profilefacet.controlmode;
-
-import java.util.Iterator;
-
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
-import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
-import org.eclipse.papyrus.infra.services.controlmode.commands.IControlCommand;
-import org.eclipse.papyrus.uml.profilefacet.utils.ProfileFacetSetMoveHelper;
-
-
-
-/**
- * ControlCommand in charge of moving the tables when controlling a package.
- *
- */
-public class ProfileFacetSetControlCommand implements IControlCommand {
-
- /**
- * {@inheritDoc}
- */
- public void control(EditingDomain domain, EObject selection, STATE_CONTROL state, Resource source, Resource target, CompoundCommand commandToModify) {
- switch(state) {
- case POST_NOTATION:
- ProfileFacetSetMoveHelper.addAllFacetSetMoveCommands(domain, selection, source, target, commandToModify);
- break;
-// case POST_DI:
-// TableMoveHelper.addAllTableMoveCommands(domain, selection, source, target, commandToModify);
-// //FIXME : it should exist a best way to get the SashWindowsMngr
-// SashWindowsMngr windowsMngr = null;
-// final Iterator iter = selection.eAdapters().iterator();
-// while(iter.hasNext() && windowsMngr == null) {
-// final Adapter current = iter.next();
-// if(current.isAdapterForType(SashWindowsMngr.class)) {
-// windowsMngr = (SashWindowsMngr)current.getTarget();
-// }
-// }
-// if(windowsMngr != null) {
-// TableMoveHelper.addAllPageRefTableMoveCommands((TransactionalEditingDomain)domain, selection, source, target, windowsMngr, commandToModify);
-// }
-// break;
- default:
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean provides(EObject selection, STATE_CONTROL state, Resource source, Resource target) {
- return /*DiModel.DI_FILE_EXTENSION.equals(target.getURI().fileExtension()) ||*/ state == STATE_CONTROL.POST_NOTATION;
- }
-
-
-}
diff --git a/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetControlParticipant.java b/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetControlParticipant.java
new file mode 100644
index 00000000000..bec00a68b7b
--- /dev/null
+++ b/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetControlParticipant.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos.
+ * 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:
+ * Mathieu Velten - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.papyrus.uml.profilefacet.controlmode;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.SashModel;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant;
+import org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant;
+import org.eclipse.papyrus.uml.profilefacet.utils.ProfileFacetSetMoveHelper;
+
+
+public class ProfileFacetSetControlParticipant implements IControlCommandParticipant, IUncontrolCommandParticipant {
+
+ public String getID() {
+ return "org.eclipse.papyrus.uml.profilefacet.controlmode.ProfileFacetSetControlParticipant";
+ }
+
+ public int getPriority() {
+ return 20;
+ }
+
+ public boolean provideUnControlCommand(ControlModeRequest request) {
+ return request.getTargetObject() instanceof EObject;
+ }
+
+ public boolean provideControlCommand(ControlModeRequest request) {
+ return request.getTargetObject() instanceof EObject;
+ }
+
+ public ICommand getPreUncontrolCommand(ControlModeRequest request) {
+ return ProfileFacetSetMoveHelper.getMoveAllFacetSetsCommand(request.getEditingDomain(), request.getTargetObject(), request.getSourceResource(SashModel.MODEL_FILE_EXTENSION), request.getTargetResource(SashModel.MODEL_FILE_EXTENSION));
+
+ }
+
+ public ICommand getPostUncontrolCommand(ControlModeRequest request) {
+ return null;
+ }
+
+ public ICommand getPreControlCommand(ControlModeRequest request) {
+ return null;
+ }
+
+ public ICommand getPostControlCommand(ControlModeRequest request) {
+ return ProfileFacetSetMoveHelper.getMoveAllFacetSetsCommand(request.getEditingDomain(), request.getTargetObject(), request.getSourceResource(SashModel.MODEL_FILE_EXTENSION), request.getTargetResource(SashModel.MODEL_FILE_EXTENSION));
+ }
+
+}
diff --git a/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetUncontrolCommand.java b/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetUncontrolCommand.java
deleted file mode 100644
index 5c83824b3fc..00000000000
--- a/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/controlmode/ProfileFacetSetUncontrolCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 Atos.
- *
- *
- * 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:
- * Olivier Melois (ATOS) olivier.melois@atos.net - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profilefacet.controlmode;
-
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
-import org.eclipse.papyrus.infra.services.controlmode.commands.IUncontrolCommand;
-import org.eclipse.papyrus.uml.profilefacet.utils.ProfileFacetSetMoveHelper;
-
-
-/**
- * Does the exact same thing as PapyrusTableControlCommand, but moves the tables back
- * to the resource they were initially created in.
- *
- */
-public class ProfileFacetSetUncontrolCommand implements IUncontrolCommand {
-
- /**
- * {@inheritDoc}
- */
- public void uncontrol(EditingDomain domain, EObject selection, STATE_CONTROL state, Resource source, Resource target, CompoundCommand commandToModify) {
- switch(state) {
- case POST_NOTATION:
- ProfileFacetSetMoveHelper.addAllFacetSetMoveCommands(domain, selection, source, target, commandToModify);
- //FIXME : the control mode should provides POST_DI for uncontrol action
-// final ModelSet set = (ModelSet)source.getResourceSet();
-// final Resource sourceDi = set.getAssociatedResource(source, DiModel.MODEL_FILE_EXTENSION);
-// final Resource targetDi = set.getAssociatedResource(target, DiModel.MODEL_FILE_EXTENSION);
-// TableMoveHelper.addAllTableMoveCommands(domain, selection, sourceDi, targetDi, commandToModify);
- break;
- default:
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean provides(EObject selection, STATE_CONTROL state, Resource source, Resource target) {
- if(state == STATE_CONTROL.POST_NOTATION) {//FIXME : the control mode should allow to uncontrol di file
- return true;
- }
- return false;
-// return DiModel.DI_FILE_EXTENSION.equals(target.getURI().fileExtension());
- }
-
-}
diff --git a/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/utils/ProfileFacetSetMoveHelper.java b/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/utils/ProfileFacetSetMoveHelper.java
index c66029b2a3e..d6fc2362924 100644
--- a/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/utils/ProfileFacetSetMoveHelper.java
+++ b/plugins/uml/profilefacet/org.eclipse.papyrus.uml.profilefacet/src/org/eclipse/papyrus/uml/profilefacet/utils/ProfileFacetSetMoveHelper.java
@@ -25,8 +25,6 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
@@ -35,7 +33,6 @@ import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.facet.infra.facet.Facet;
import org.eclipse.emf.facet.infra.facet.FacetSet;
import org.eclipse.emf.facet.infra.query.ModelQuerySet;
@@ -47,9 +44,9 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.table.controlmode.helpers.TableMoveHelper;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.papyrus.infra.table.instance.util.TableContentsUtils;
import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypePropertyElement;
/**
@@ -232,8 +229,9 @@ public final class ProfileFacetSetMoveHelper {
// return result;
// }
- public static void addAllFacetSetMoveCommands(EditingDomain domain, EObject selection, Resource source, final Resource target, CompoundCommand commandToModify) {
- final Collection pTables = TableMoveHelper.getPapyrusTableInstances(selection);
+ public static ICommand getMoveAllFacetSetsCommand(TransactionalEditingDomain domain, EObject selection, Resource source, final Resource target) {
+ CompositeTransactionalCommand cc = new CompositeTransactionalCommand(domain, "Move facet sets");
+ final Collection pTables = TableContentsUtils.getPapyrusTableInstances(selection);
if(!pTables.isEmpty()) {
final Set facetsUsed = new HashSet();
for(PapyrusTableInstance papyrusTableInstance : pTables) {
@@ -263,9 +261,9 @@ public final class ProfileFacetSetMoveHelper {
} else if(additionalEPackageSource != null) {
if(moveAdditionalFacetSet) {
if(additionalEPackageTarget != null) {
- Command tmp = getMergeAdditionalContentsEPackageCommand((TransactionalEditingDomain)domain, (XMIResource)source, (XMIResource)target, pTables, facetsets, facetsets, additionalEPackageSource, additionalEPackageTarget);
+ ICommand tmp = getMergeAdditionalContentsEPackageCommand((TransactionalEditingDomain)domain, (XMIResource)source, (XMIResource)target, pTables, facetsets, facetsets, additionalEPackageSource, additionalEPackageTarget);
if(tmp != null) {
- commandToModify.append(tmp);
+ cc.add(tmp);
}
} else {
//we should copy the AdditionalContentsEPackage
@@ -297,19 +295,20 @@ public final class ProfileFacetSetMoveHelper {
return CommandResult.newOKCommandResult();
}
};
- commandToModify.append(new GMFtoEMFCommandWrapper(addToResource));
+ cc.add(addToResource);
- Command tmp2 = getUpdateFacetElementReferencesCommand((TransactionalEditingDomain)domain, pTables, copier);
+ ICommand tmp2 = getUpdateFacetElementReferencesCommand((TransactionalEditingDomain)domain, pTables, copier);
if(tmp2 != null) {
- commandToModify.append(tmp2);
+ cc.add(tmp2);
}
- commandToModify.append(getCopyXMI_IDCommand((TransactionalEditingDomain)domain, copier));
+ cc.add(getCopyXMI_IDCommand((TransactionalEditingDomain)domain, copier));
}
}
}
}
}
+ return cc;
}
/**
@@ -334,8 +333,8 @@ public final class ProfileFacetSetMoveHelper {
* the command to merge the contents of the Epakche source into the EPackage target AND duplicating the required ModelQuerySet referenced
* by the source FacetSets
*/
- private static Command getMergeAdditionalContentsEPackageCommand(final TransactionalEditingDomain domain, final XMIResource sourceResource, final XMIResource targetResource, final Collection tables, final Collection sourceFacetSets, Collection targetFacetSets, EPackage source, final EPackage target) {
- final CompoundCommand compoundCommand = new CompoundCommand("Merge additional epackage contents"); //$NON-NLS-1$
+ private static ICommand getMergeAdditionalContentsEPackageCommand(final TransactionalEditingDomain domain, final XMIResource sourceResource, final XMIResource targetResource, final Collection tables, final Collection sourceFacetSets, Collection targetFacetSets, EPackage source, final EPackage target) {
+ CompositeTransactionalCommand cc = new CompositeTransactionalCommand(domain, "Merge additional epackage contents");
//1. we init the maps
final Map sourceVSTargetModelQuerySet = new HashMap();
final Map sourceMap = new HashMap();
@@ -369,7 +368,7 @@ public final class ProfileFacetSetMoveHelper {
return CommandResult.newOKCommandResult();
}
};
- compoundCommand.append(new GMFtoEMFCommandWrapper(addModelQuerySetToResource));
+ cc.add(addModelQuerySetToResource);
}
copier.copyReferences();
@@ -382,18 +381,18 @@ public final class ProfileFacetSetMoveHelper {
return CommandResult.newOKCommandResult();
}
};
- compoundCommand.append(new GMFtoEMFCommandWrapper(addFacetSetToAdditionalContentsFacetSet));
- compoundCommand.append(getCopyXMI_IDCommand(domain, copier));
- final Command tmp = getUpdateFacetElementReferencesCommand(domain, tables, copier);
+ cc.add(addFacetSetToAdditionalContentsFacetSet);
+ cc.add(getCopyXMI_IDCommand(domain, copier));
+ ICommand tmp = getUpdateFacetElementReferencesCommand(domain, tables, copier);
if(tmp != null) {
- compoundCommand.append(tmp);
+ cc.add(tmp);
}
}
}
- if(compoundCommand.isEmpty()) {
+ if(cc.isEmpty()) {
return null;
} else {
- return compoundCommand;
+ return cc;
}
}
@@ -424,8 +423,8 @@ public final class ProfileFacetSetMoveHelper {
* @return the copy xm i_ id command
* the command set the XMI_ID of the source eobject to the target eobject
*/
- private static Command getCopyXMI_IDCommand(final TransactionalEditingDomain domain, final Map map) {
- final ICommand copyXMI_ID_Command = new AbstractTransactionalCommand(domain, "Copy XMI_ID Command", null) { //$NON-NLS-1$
+ private static ICommand getCopyXMI_IDCommand(final TransactionalEditingDomain domain, final Map map) {
+ return new AbstractTransactionalCommand(domain, "Copy XMI_ID Command", null) { //$NON-NLS-1$
@Override
protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
@@ -443,7 +442,6 @@ public final class ProfileFacetSetMoveHelper {
return CommandResult.newOKCommandResult();
}
};
- return new GMFtoEMFCommandWrapper(copyXMI_ID_Command);
}
/**
@@ -459,8 +457,8 @@ public final class ProfileFacetSetMoveHelper {
* the command to replace each call to source element by a call to target element in the managed tables or null
if there is
* nothing to do
*/
- private static Command getUpdateFacetElementReferencesCommand(final TransactionalEditingDomain domain, final Collection papyrusTables, final Map sourceToTarget) {
- final CompoundCommand updateCommand = new CompoundCommand("Update References To facet Element Command"); //$NON-NLS-1$
+ private static ICommand getUpdateFacetElementReferencesCommand(final TransactionalEditingDomain domain, final Collection papyrusTables, final Map sourceToTarget) {
+ CompositeTransactionalCommand cc = new CompositeTransactionalCommand(domain, "Update References To facet Element Command");
final Collection tableInstances = new ArrayList();
for(final PapyrusTableInstance pTable : papyrusTables) {
tableInstances.add(pTable.getTable());
@@ -483,7 +481,7 @@ public final class ProfileFacetSetMoveHelper {
return CommandResult.newOKCommandResult();
}
};
- updateCommand.append(new GMFtoEMFCommandWrapper(cmd));
+ cc.add(cmd);
}
}
}
@@ -500,16 +498,16 @@ public final class ProfileFacetSetMoveHelper {
return CommandResult.newOKCommandResult();
}
};
- updateCommand.append(new GMFtoEMFCommandWrapper(cmd));
+ cc.add(cmd);
}
}
}
}
}
- if(updateCommand.isEmpty()) {
+ if(cc.isEmpty()) {
return null;
}
- return updateCommand;
+ return cc;
}
--
cgit v1.2.3