Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-08-23 21:07:27 +0000
committerChristian W. Damus2016-08-23 21:07:27 +0000
commitae293862c718921e47a62e456d48f3c19cfbe78e (patch)
treefe95bc4745b4db378f7caecebf754c62454df2da /plugins/uml/org.eclipse.papyrus.uml.controlmode.profile
parent7e0c2b842c458bd621914b68da67ce97ee6fed21 (diff)
downloadorg.eclipse.papyrus-ae293862c718921e47a62e456d48f3c19cfbe78e.tar.gz
org.eclipse.papyrus-ae293862c718921e47a62e456d48f3c19cfbe78e.tar.xz
org.eclipse.papyrus-ae293862c718921e47a62e456d48f3c19cfbe78e.zip
Bug 497865: [Control Mode] UI for dependent controlled units
https://bugs.eclipse.org/bugs/show_bug.cgi?id=497865 Add an option to the standard control (create fragment) dialog for option to create sub-model unit (independently openable) or not (in which case it's a 'shard'). Add an approver interface to the participant protocols for validation of control/uncontrol requests and also to determine whether an object supports the sub-model unit form of controlled resource. Use this to let the UML participant disable the sub-model unit option for non-packages. Add a label decorator for controlled unit resources in the Project Explorer, with different presentation for 'shards' as for sub-model units that are independently openable. Add a context menu on model elements to toggle their independent sub-model status when they are currently controlled units. This is supported by another optional participant protocol for changing sub-unit mode so that for UML we can add/remove redundant profile applications on packages as necessary. (cherry-picked from streams/2.0-maintenance) Change-Id: I08ac9cc64d70432851f8e7e815f352f4b00d50f2
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.controlmode.profile')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/.classpath14
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/META-INF/MANIFEST.MF6
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/pom.xml2
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/UMLProfileControlParticipant.java75
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/commands/MoveStereotypeApplicationToControlResource.java8
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/helpers/ProfileApplicationHelper.java10
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/helpers/SafeDialogOpenerDuringValidation.java12
8 files changed, 98 insertions, 35 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/.classpath b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/.classpath
index 2d1a4302f04..eca7bdba8f0 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/.classpath
+++ b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/.classpath
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/.settings/org.eclipse.jdt.core.prefs b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/.settings/org.eclipse.jdt.core.prefs
index 4759947300a..62a08f4494d 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
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 8ce1e4b0c7a..5773a564a7a 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
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.eclipse.papyrus.infra.services.controlmode;bundle-version="[1.2.0,2.0.0)",
+Require-Bundle: org.eclipse.papyrus.infra.services.controlmode;bundle-version="[1.3.0,2.0.0)",
org.eclipse.papyrus.uml.tools;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.emf.readonly;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="[1.2.0,2.0.0)",
@@ -8,10 +8,10 @@ Require-Bundle: org.eclipse.papyrus.infra.services.controlmode;bundle-version="[
org.eclipse.emf.validation.ui;bundle-version="[1.7.0,2.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.2.100.qualifier
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-Activator: org.eclipse.papyrus.uml.controlmode.profile.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.uml.controlmode.profile;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/pom.xml b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/pom.xml
index 4e002f4c961..c5283c2bb35 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/pom.xml
+++ b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.controlmode.profile</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/UMLProfileControlParticipant.java b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/UMLProfileControlParticipant.java
index 60575193484..2bc81a0140d 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/UMLProfileControlParticipant.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/UMLProfileControlParticipant.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2014 Atos, CEA LIST and etc..
+ * Copyright (c) 2013, 2016 Atos, CEA LIST and etc., Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,6 +10,7 @@
* Contributors:
* Arthur Daussy (Atos) arthur.daussy@atos.net - Initial API and implementation
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436947
+ * Christian W. Damus - bug 497865
*
*****************************************************************************/
package org.eclipse.papyrus.uml.controlmode.profile;
@@ -17,17 +18,22 @@ package org.eclipse.papyrus.uml.controlmode.profile;
import java.util.Collections;
import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.emf.ecore.EObject;
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.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequestParameters;
import org.eclipse.papyrus.infra.services.controlmode.commands.AskUserCommand;
+import org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandApprover;
import org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant;
+import org.eclipse.papyrus.infra.services.controlmode.participants.IShardModeCommandParticipant;
import org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant;
import org.eclipse.papyrus.uml.controlmode.profile.commands.CopyProfileApplicationCommand;
import org.eclipse.papyrus.uml.controlmode.profile.commands.MoveProfileApplicationCommand;
import org.eclipse.papyrus.uml.controlmode.profile.commands.MoveStereotypeApplicationToControlResource;
import org.eclipse.papyrus.uml.controlmode.profile.commands.RemoveDuplicationProfileApplicationCommand;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Package;
@@ -39,8 +45,8 @@ import org.eclipse.uml2.uml.Package;
* @author adaussy
*
*/
-public class UMLProfileControlParticipant implements IControlCommandParticipant, IUncontrolCommandParticipant {
-
+public class UMLProfileControlParticipant implements IControlCommandParticipant,
+ IUncontrolCommandParticipant, IShardModeCommandParticipant, IControlCommandApprover {
/** The Constant PRE_UNCONTROL_COMMAND_LABEL. */
private static final String PRE_UNCONTROL_COMMAND_LABEL = Messages.UMLProfileControlParticipant_Pre_Uncontrol_Command_Label;
@@ -61,6 +67,7 @@ public class UMLProfileControlParticipant implements IControlCommandParticipant,
return new CopyProfileApplicationCommand(request);
}
+ @Override
public String getID() {
return "org.eclipse.papyrus.uml.controlmode.profile.UMLProfileControlParticipant"; //$NON-NLS-1$
}
@@ -79,21 +86,32 @@ public class UMLProfileControlParticipant implements IControlCommandParticipant,
return new MoveStereotypeApplicationToControlResource(Collections.singletonList(WorkspaceSynchronizer.getFile(request.getTargetObject().eResource())), request);
}
+ @Override
public ICommand getPostControlCommand(ControlModeRequest request) {
CompositeCommand cc = new CompositeCommand(POST_CONTROL_COMMAND_LABEL);
- // Move stereotype application
- if (request.getTargetObject() instanceof Package) {
+
+ // Do we need to manipulate profile applications? Only if it's a package
+ // that is intended to be an independently openable sub-model unit
+ boolean handleProfileApplications = !ControlModeRequestParameters.isCreateShard(request)
+ && (request.getTargetObject() instanceof Package);
+
+ // Move profile applications if necessary and possible
+ if (handleProfileApplications) {
cc.compose(getMoveProfileAppliationCommand(request));
}
+
// Move stereotype application
cc.compose(getMoveStereotypeCommand(request));
- // Copy profile application
- if (request.getTargetObject() instanceof Package) {
+
+ // Copy profile applications if necessary and possible
+ if (handleProfileApplications) {
cc.compose(getCopyProfileApplication(request));
}
+
return cc;
}
+ @Override
public ICommand getPostUncontrolCommand(ControlModeRequest request) {
CompositeCommand cc = new CompositeCommand(POST_UNCONTROL_COMMAND_LABEL);
@@ -123,15 +141,28 @@ public class UMLProfileControlParticipant implements IControlCommandParticipant,
return new RemoveDuplicationProfileApplicationCommand(request);
}
+ @Override
public ICommand getPreControlCommand(ControlModeRequest request) {
Element elem = (Element) request.getTargetObject();
- if (request.isUIAction() && !(elem instanceof org.eclipse.uml2.uml.Package)) {
+
+ // Populate the source resource
+ request.setSourceResource(elem.eResource(), UmlModel.UML_FILE_EXTENSION);
+
+ // Don't need to worry about this if we're creating a 'shard' resource, because
+ // it cannot be opened independently (that's the whole point of shards)
+ if (!ControlModeRequestParameters.isCreateShard(request) && request.isUIAction()
+ && !(elem instanceof org.eclipse.uml2.uml.Package)) {
+
return new AskUserCommand(request.getEditingDomain(), getPreControlCommandMessage(elem), getPreControlCommandDialogTitle(elem), true, "org.eclipse.papyrus.controlmode.umlprofiles.participants.UMLProfileParticipant.openstandalonemodeldialog"); //$NON-NLS-1$
}
return null;
}
+ @Override
public ICommand getPreUncontrolCommand(ControlModeRequest request) {
+ // Populate the source resource
+ request.setSourceResource(request.getTargetObject().eResource(), UmlModel.UML_FILE_EXTENSION);
+
CompositeCommand cc = new CompositeCommand(PRE_UNCONTROL_COMMAND_LABEL);
// Copy profile application
if (request.getTargetObject() instanceof Package) {
@@ -141,6 +172,22 @@ public class UMLProfileControlParticipant implements IControlCommandParticipant,
return cc;
}
+ @Override
+ public ICommand getPostShardModeCommand(ControlModeRequest request) {
+ ICommand result;
+
+ if (ControlModeRequestParameters.isCreateShard(request)) {
+ // A shard will inherit these
+ result = getRemoveProfileApplication(request);
+ } else {
+ // A sub-model needs redundant profile applications
+ result = (ICommand) getCopyProfileApplication(request);
+ }
+
+ return result;
+ }
+
+ @Override
public int getPriority() {
return 100;
}
@@ -149,11 +196,23 @@ public class UMLProfileControlParticipant implements IControlCommandParticipant,
return Messages.UMLProfileControlParticipant_controlmode_dialog_title;
}
+ @Override
public boolean provideControlCommand(ControlModeRequest request) {
return request.getTargetObject() instanceof Element;
}
+ @Override
public boolean provideUnControlCommand(ControlModeRequest request) {
return request.getTargetObject() instanceof Element;
}
+
+ @Override
+ public boolean providesShardModeCommand(ControlModeRequest request) {
+ return request.getTargetObject() instanceof org.eclipse.uml2.uml.Package;
+ }
+
+ @Override
+ public boolean canCreateSubModel(EObject objectToControl) {
+ return objectToControl instanceof org.eclipse.uml2.uml.Package;
+ }
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/commands/MoveStereotypeApplicationToControlResource.java b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/commands/MoveStereotypeApplicationToControlResource.java
index c8d0b136d57..595354538a6 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/commands/MoveStereotypeApplicationToControlResource.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/commands/MoveStereotypeApplicationToControlResource.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2014 Atos, Christian W. Damus, and others.
+ * Copyright (c) 2013, 2016 Atos, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,7 +8,7 @@
*
* Contributors:
* Arthur Daussy (Atos) arthur.daussy@atos.net - Initial API and implementation
- * Christian W. Damus - bug 399859
+ * Christian W. Damus - bugs 399859, 497865
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - bug 460435
*
*****************************************************************************/
@@ -85,7 +85,7 @@ public final class MoveStereotypeApplicationToControlResource extends AbstractCo
}
// Retrieve related resources by control command
- Resource sourceResource = getRequest().getModelSet().getAssociatedResource(targetElement, UmlModel.UML_FILE_EXTENSION, false);
+ Resource sourceResource = getRequest().getSourceResource(UmlModel.UML_FILE_EXTENSION);
Resource targetResource = getRequest().getTargetResource(UmlModel.UML_FILE_EXTENSION);
if (targetResource == null) {
@@ -100,4 +100,4 @@ public final class MoveStereotypeApplicationToControlResource extends AbstractCo
return CommandResult.newOKCommandResult();
}
-} \ No newline at end of file
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/helpers/ProfileApplicationHelper.java b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/helpers/ProfileApplicationHelper.java
index 6e6242a86ce..193231acdfc 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/helpers/ProfileApplicationHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/helpers/ProfileApplicationHelper.java
@@ -49,11 +49,11 @@ public class ProfileApplicationHelper {
ProfileApplication toCopy = _package.getProfileApplication(profile, true);
// Is it inherited from a parent package and intrinsic to the model?
if (_package.allOwningPackages().contains(toCopy.getApplyingPackage())) {
- _package.applyProfile(profile);
- ProfileApplication profileAppl = _package.getProfileApplication(profile);
- if (profileAppl != null) {
- markAsDuplicate(profileAppl);
- }
+ // Don't apply the profile because this needlessly destroys and
+ // reconstitutes all stereotype applications by a "migration"
+ ProfileApplication profileAppl = EcoreUtil.copy(toCopy);
+ _package.getProfileApplications().add(profileAppl);
+ markAsDuplicate(profileAppl);
}
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/helpers/SafeDialogOpenerDuringValidation.java b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/helpers/SafeDialogOpenerDuringValidation.java
index 91a333f8d74..7bc79a91aab 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/helpers/SafeDialogOpenerDuringValidation.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/helpers/SafeDialogOpenerDuringValidation.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 Atos Origin.
+ * Copyright (c) 2011, 2016 Atos Origin, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Atos Origin - Initial API and implementation
+ * Christian W. Damus - bug 497865
*
*****************************************************************************/
package org.eclipse.papyrus.uml.controlmode.profile.helpers;
@@ -65,8 +66,11 @@ public abstract class SafeDialogOpenerDuringValidation<ReturnType> {
*/
IOperationHistory history = CheckedOperationHistory.getInstance();
history.addOperationApprover(operationDisapprover);
- ReturnType result = openDialog();
- history.removeOperationApprover(operationDisapprover);
- return result;
+ try {
+ ReturnType result = openDialog();
+ return result;
+ } finally {
+ history.removeOperationApprover(operationDisapprover);
+ }
}
}

Back to the top