diff options
author | Benoit Maggi | 2017-11-13 15:18:28 +0000 |
---|---|---|
committer | Benoit Maggi | 2017-11-21 15:20:41 +0000 |
commit | 2e2b87268635683d3d68b2d777b3cbcea8f47ef9 (patch) | |
tree | ceb034d9caceb1788f5d154b47c49ad388daf85e /plugins/uml/org.eclipse.papyrus.uml.service.types | |
parent | 8eca02ee0e11692796d583e3b86df24540f34100 (diff) | |
download | org.eclipse.papyrus-2e2b87268635683d3d68b2d777b3cbcea8f47ef9.tar.gz org.eclipse.papyrus-2e2b87268635683d3d68b2d777b3cbcea8f47ef9.tar.xz org.eclipse.papyrus-2e2b87268635683d3d68b2d777b3cbcea8f47ef9.zip |
Bug 518406 - [Stereotype] Stereotype definition is not moved when the
element is moved from resources
- also move stereotype application when moving an UML element
- add a preference to configure this option (default is set to keep
stereotype with element)
- remove README referencing a closed bug
- fix a warning in Activator
Change-Id: Ibb1bbdb93c4a6c911bc5deea1c9fc2832843335f
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.service.types')
8 files changed, 159 insertions, 13 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.service.types/META-INF/MANIFEST.MF index 2c8cd711679..61f71ec2631 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/META-INF/MANIFEST.MF +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/META-INF/MANIFEST.MF @@ -6,6 +6,9 @@ Export-Package: org.eclipse.papyrus.uml.service.types, org.eclipse.papyrus.uml.service.types.helper, org.eclipse.papyrus.uml.service.types.helper.advice, org.eclipse.papyrus.uml.service.types.matcher, + org.eclipse.papyrus.uml.service.types.messages, + org.eclipse.papyrus.uml.service.types.preferences, + org.eclipse.papyrus.uml.service.types.request, org.eclipse.papyrus.uml.service.types.utils Require-Bundle: org.eclipse.papyrus.uml.diagram.common;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, org.eclipse.papyrus.uml.tools;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/README b/plugins/uml/org.eclipse.papyrus.uml.service.types/README deleted file mode 100644 index 26708a33c93..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/README +++ /dev/null @@ -1,7 +0,0 @@ -bug 492522: [All Diagrams] Delete from model on comment links does not work (does a delete from diagram) -https://bugs.eclipse.org/bugs/show_bug.cgi?id=492522 - -1. Delete from model for a link representing a feature (like the comment link mapped on Comment#annotatedElement, the contraint link mapped on Contraints#contrainedElements and others) -must remove the referenced element of the feature -2. To do that we need to map the type of the link (visual id) to a feature and we need to use the same id for all diagrams -3. if these conditions are respected, the uml service type is able to remove all representations of a given link doing Delete From Model for a link
\ No newline at end of file diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/build.properties b/plugins/uml/org.eclipse.papyrus.uml.service.types/build.properties index 638dbea60ce..9b877be1bd8 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/build.properties +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/build.properties @@ -3,7 +3,8 @@ bin.includes = META-INF/,\ about.html,\ plugin.properties,\ icons/,\ - model/ + model/,\ + plugin.xml output.. = bin/ src.includes = about.html source.. = src/,src-gen/ diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/plugin.xml b/plugins/uml/org.eclipse.papyrus.uml.service.types/plugin.xml new file mode 100644 index 00000000000..e4ce2fcc8af --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/plugin.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.core.runtime.preferences"> + <initializer + class="org.eclipse.papyrus.uml.service.types.preferences.UMLElementTypePreferenceInitializer"> + </initializer> + </extension> +</plugin> diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/Activator.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/Activator.java index 3c7cf5dbd7b..808e7669c19 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/Activator.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/Activator.java @@ -61,7 +61,7 @@ public class Activator extends Plugin { public IPreferenceStore getPreferenceStore() {
// Create the preference store lazily.
if (preferenceStore == null) {
- preferenceStore = new ScopedPreferenceStore(new InstanceScope(), getBundle().getSymbolicName());
+ preferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, getBundle().getSymbolicName());
}
return preferenceStore;
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/StereotypeApplicationMoveCommand.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/StereotypeApplicationMoveCommand.java new file mode 100644 index 00000000000..8679a9ff3b3 --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/StereotypeApplicationMoveCommand.java @@ -0,0 +1,72 @@ +/***************************************************************************** + * Copyright (c) 2017 CEA LIST and others. + * + * 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: + * Benoit Maggi (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.service.types.command; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.uml2.uml.Element; + +/** + * A Command to move all stereotype applications applied to an UML Element + * from a Resource to an other Resource + */ +public class StereotypeApplicationMoveCommand extends AbstractTransactionalCommand { + + Element element; + Resource source; + Resource target; + + /** + * Constructor. + * + * @param request + */ + public StereotypeApplicationMoveCommand(TransactionalEditingDomain domain,Element element, Resource source, Resource target) { + super(domain, "Move stereotype application", null); + this.element = element; + this.source = source; + this.target = target; + } + + /** + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + * + * @param monitor + * @param info + * @return + * @throws ExecutionException + */ + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + if (element != null && target != null) { + EList<EObject> stereotypeApplications = element.getStereotypeApplications(); + EList<EObject> targetList = target.getContents(); + for (EObject next : stereotypeApplications) { + if (next.eResource() == source) { + targetList.add(next); + } + } + } + return CommandResult.newOKCommandResult(); + } + + +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ElementEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ElementEditHelper.java index affec397818..2cbe5aed988 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ElementEditHelper.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ElementEditHelper.java @@ -12,23 +12,23 @@ * Christian W. Damus - bug 467016 * Christian W. Damus - bug 459701 * Sebastien Bordes (Esterel Technologies SAS) - bug 497800 - * Benoit Maggi (CEA LIST) - bug 516513 + * Benoit Maggi (CEA LIST) - bug 516513, 518406 *****************************************************************************/ package org.eclipse.papyrus.uml.service.types.helper; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand; import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; @@ -42,6 +42,9 @@ import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; import org.eclipse.papyrus.uml.diagram.common.util.CrossReferencerUtil; +import org.eclipse.papyrus.uml.service.types.Activator; +import org.eclipse.papyrus.uml.service.types.command.StereotypeApplicationMoveCommand; +import org.eclipse.papyrus.uml.service.types.preferences.UMLElementTypePreferenceInitializer; import org.eclipse.papyrus.uml.tools.model.UmlUtils; import org.eclipse.papyrus.uml.types.core.edithelper.DefaultUMLEditHelper; import org.eclipse.uml2.uml.Element; @@ -149,10 +152,18 @@ public class ElementEditHelper extends DefaultUMLEditHelper { if (elementsToMove != null) { for (Object object : elementsToMove.keySet()) { if (object instanceof Element) { - ICommand deleteContainmentLinks = getDeleteContainmentLinkCommand(req.getEditingDomain(), (Element) object, (Element) targetContainer); + Element element = (Element) object; + ICommand deleteContainmentLinks = getDeleteContainmentLinkCommand(req.getEditingDomain(), element, (Element) targetContainer); if (deleteContainmentLinks.canExecute()) { moveCommand = CompositeCommand.compose(moveCommand, deleteContainmentLinks); } + boolean alsoMoveStereotypeApplication = Activator.getDefault().getPreferenceStore().getBoolean(UMLElementTypePreferenceInitializer.MOVE_STEREOTYPEAPPLICATION_ELEMENT_IN_SAME_RESOURCE); + if (alsoMoveStereotypeApplication) { + ICommand moveStereotypeCommand = getMoveStereotypeCommand(req, element, element.eResource(), targetContainer.eResource()); + if (moveStereotypeCommand.canExecute()) { + moveCommand = CompositeCommand.compose(moveCommand, moveStereotypeCommand); + } + } } } } @@ -215,4 +226,20 @@ public class ElementEditHelper extends DefaultUMLEditHelper { } return cc; } + + /** + * Construct a command to move stereotype application if required + * @param request + * @param element + * @param source + * @param target + * @return + */ + private ICommand getMoveStereotypeCommand(MoveRequest request, Element element, Resource source, Resource target) { + if (target != null && !target.equals(source)) { + return new StereotypeApplicationMoveCommand(request.getEditingDomain(), element, source, target); + } + return UnexecutableCommand.INSTANCE; + } + } diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/preferences/UMLElementTypePreferenceInitializer.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/preferences/UMLElementTypePreferenceInitializer.java new file mode 100644 index 00000000000..8cf666a9b34 --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/preferences/UMLElementTypePreferenceInitializer.java @@ -0,0 +1,40 @@ +/***************************************************************************** + * Copyright (c) 2017 CEA LIST and others. + * + * 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: + * Benoit Maggi (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.service.types.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.uml.service.types.Activator; + +public class UMLElementTypePreferenceInitializer extends AbstractPreferenceInitializer { + + + /** + * Preference key for allowing move of stereotype application in the same resource as + * their base element + */ + public static final String MOVE_STEREOTYPEAPPLICATION_ELEMENT_IN_SAME_RESOURCE = "MOVE_STEREOTYPEAPPLICATION_ELEMENT_IN_SAME_RESOURCE"; //$NON-NLS-1$ + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + @Override + public void initializeDefaultPreferences() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + store.setDefault(MOVE_STEREOTYPEAPPLICATION_ELEMENT_IN_SAME_RESOURCE, true); + } + +}
\ No newline at end of file |