Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-01-19 08:52:48 -0500
committerGerrit Code Review @ Eclipse.org2015-01-19 08:52:48 -0500
commit6a7adafaeaae89b50dae6eeb311ddcf8df9dd14f (patch)
treebc90d4599f24f6d8165ea6d993acf0af13999110 /plugins
parentc8d8102d32dd0cda21fae2a44ea9a0d358b05dc1 (diff)
parentbcd616e7cf3fe780ea0e408827c0f080e8ccb9fc (diff)
downloadorg.eclipse.papyrus-6a7adafaeaae89b50dae6eeb311ddcf8df9dd14f.tar.gz
org.eclipse.papyrus-6a7adafaeaae89b50dae6eeb311ddcf8df9dd14f.tar.xz
org.eclipse.papyrus-6a7adafaeaae89b50dae6eeb311ddcf8df9dd14f.zip
Merge "454997: [Stereotypes Repair] The Stereotypes Repair dialog should ask for a user-action only once for each Profile https://bugs.eclipse.org/bugs/show_bug.cgi?id=454997"
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java8
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ApplyProfileAction.java64
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/IRepairAction.java12
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java33
4 files changed, 99 insertions, 18 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java
index 40e1d1ebd95..27f73eb02fd 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java
@@ -156,12 +156,14 @@ public class MaskManagedFloatingLabelEditPolicy extends AbstractMaskManagedEditP
// - the stereotype application list has changed
Object object = notification.getNotifier();
NamedElement property = getUMLElement();
- if (object == null || property == null) {
+ Object feature = notification.getFeature();
+ if (object == null || property == null || feature == null) {
return;
}
- if (notification.getFeature().equals(UMLPackage.eINSTANCE.getLiteralInteger_Value())) {
+
+ if (feature == UMLPackage.eINSTANCE.getLiteralInteger_Value()) {
refreshDisplay();
- } else if (notification.getFeature().equals(UMLPackage.eINSTANCE.getLiteralUnlimitedNatural_Value())) {
+ } else if (feature == UMLPackage.eINSTANCE.getLiteralUnlimitedNatural_Value()) {
refreshDisplay();
}
if (object.equals(property)) {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ApplyProfileAction.java b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ApplyProfileAction.java
index 94c5929a69b..e92fec6870c 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ApplyProfileAction.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ApplyProfileAction.java
@@ -10,6 +10,7 @@
* Christian W. Damus (CEA) - Initial API and implementation
* Christian W. Damus - bug 399859
* Christian W. Damus - bug 451557
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - bug 454997
*
*/
package org.eclipse.papyrus.uml.modelrepair.internal.stereotypes;
@@ -27,6 +28,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.uml.modelrepair.internal.participants.StereotypeApplicationRepairParticipant;
+import org.eclipse.papyrus.uml.modelrepair.internal.stereotypes.IRepairAction.IApplyProfileAction;
import org.eclipse.papyrus.uml.tools.helper.IProfileApplicationDelegate;
import org.eclipse.papyrus.uml.tools.helper.ProfileApplicationDelegateRegistry;
import org.eclipse.uml2.uml.Package;
@@ -42,7 +44,7 @@ import com.google.common.collect.Sets;
/**
* This is the ApplyProfileAction type. Enjoy.
*/
-public class ApplyProfileAction extends AbstractRepairAction {
+public class ApplyProfileAction extends AbstractRepairAction implements IApplyProfileAction {
private final Resource resourceUnderRepair;
private final Set<Package> packages;
@@ -51,6 +53,10 @@ public class ApplyProfileAction extends AbstractRepairAction {
private String label;
+ private Profile appliedProfile;
+
+ private Profile previousProfile;
+
public ApplyProfileAction(Resource resourceUnderRepair, Iterable<? extends Package> packages, Profile profile, LabelProviderService labelProviderService) {
this(resourceUnderRepair, packages, Suppliers.ofInstance(profile));
@@ -81,29 +87,47 @@ public class ApplyProfileAction extends AbstractRepairAction {
}
public boolean repair(Resource resource, EPackage profileDefinition, Collection<? extends EObject> stereotypeApplications, DiagnosticChain diagnostics, IProgressMonitor monitor) {
+
// We can be assured that there is at least one stereotype application, otherwise we wouldn't be here
boolean result = false;
+ SubMonitor repairMonitor = SubMonitor.convert(monitor, 2);
+
+ // First, try to apply previous profile
+ if (previousProfile != null) {
+ result = applySelectedProfile(resource, stereotypeApplications, diagnostics, repairMonitor.newChild(1, SubMonitor.SUPPRESS_NONE), previousProfile);
+ }
+
+ // Then, if no Profile could be already applied, ask to user where find the Profile
+ if (!result) {
+ appliedProfile = profileSupplier.get();
+ if (appliedProfile != null) {
+ result = applySelectedProfile(resource, stereotypeApplications, diagnostics, repairMonitor.newChild(1, SubMonitor.SUPPRESS_NONE), appliedProfile);
+
+ }
+ }
+ repairMonitor.done();
+
+ return result;
+ }
- Profile profile = profileSupplier.get();
- if (profile != null) {
- String taskName = NLS.bind("Migrating stereotypes to current version of profile \"{0}\"...", profile.getName());
- SubMonitor sub = SubMonitor.convert(monitor, taskName, stereotypeApplications.size() * 3 / 2);
- // Apply the profile
- StereotypeApplicationRepairParticipant.createStereotypeApplicationMigrator(resource, profile, diagnostics).migrate(stereotypeApplications, sub.newChild(stereotypeApplications.size()));
- for (Package next : packages) {
- if (sub.isCanceled()) {
- throw new OperationCanceledException();
- }
+ private boolean applySelectedProfile(Resource resource, Collection<? extends EObject> stereotypeApplications, DiagnosticChain diagnostics, IProgressMonitor monitor, Profile profile) {
+ String taskName = NLS.bind("Migrating stereotypes to current version of profile \"{0}\"...", profile.getName());
+ SubMonitor sub = SubMonitor.convert(monitor, taskName, stereotypeApplications.size() * 3 / 2);
+ boolean result = false;
- applyProfile(next, profile, sub.newChild(stereotypeApplications.size() / 2));
+ // Apply the profile
+ StereotypeApplicationRepairParticipant.createStereotypeApplicationMigrator(resource, profile, diagnostics).migrate(stereotypeApplications, sub.newChild(stereotypeApplications.size()));
+ for (Package next : packages) {
+ if (sub.isCanceled()) {
+ throw new OperationCanceledException();
}
- result = true;
+ ProfileApplication profileApplication = applyProfile(next, profile, sub.newChild(stereotypeApplications.size() / 2));
+ result = profileApplication != null;
sub.done();
}
-
return result;
}
@@ -137,4 +161,16 @@ public class ApplyProfileAction extends AbstractRepairAction {
return result;
}
+
+
+
+ public Profile getAppliedProfile() {
+ return appliedProfile;
+ }
+
+
+ public void setPreviousAppliedProfile(Profile previousProfile) {
+ this.previousProfile = previousProfile;
+
+ }
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/IRepairAction.java b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/IRepairAction.java
index 45f0f2be965..5aa125c1d05 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/IRepairAction.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/IRepairAction.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Christian W. Damus (CEA) - Initial API and implementation
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - bug 454997
*
*/
package org.eclipse.papyrus.uml.modelrepair.internal.stereotypes;
@@ -19,6 +20,7 @@ import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.uml2.uml.Profile;
import com.google.common.base.Predicate;
@@ -85,6 +87,16 @@ public interface IRepairAction {
// Nested types
//
+ /*
+ * The interface for Apply Profile repair action.
+ */
+ interface IApplyProfileAction {
+
+ Profile getAppliedProfile();
+
+ void setPreviousAppliedProfile(Profile previousProfile);
+ }
+
enum Kind {
/** The lazy option. */
NO_OP("Postpone"),
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java
index ba476c48916..df95dbcb284 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java
@@ -11,6 +11,7 @@
* Christian W. Damus (CEA) - bug 431953 (adapted from SwitchProfileDialog)
* Christian W. Damus - bug 451338
* Christian W. Damus - bug 451557
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - bug 454997
*
*/
package org.eclipse.papyrus.uml.modelrepair.ui;
@@ -19,8 +20,10 @@ import java.lang.reflect.InvocationTargetException;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -78,6 +81,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.statushandlers.StatusManager;
+import org.eclipse.uml2.uml.Profile;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
@@ -106,6 +110,8 @@ public class ZombieStereotypesDialog extends TrayDialog {
private ProgressMonitorPart progress;
+ private Map<String, Profile> brokenNamespaceProfileMap;
+
/**
* @param shell
*/
@@ -123,8 +129,10 @@ public class ZombieStereotypesDialog extends TrayDialog {
this.zombieDescriptors = Lists.newArrayList(zombies);
this.labelProviderService = ServiceUtilsForResourceSet.getInstance().getService(LabelProviderService.class, modelSet);
this.actionsToApply = createActionsToApply();
+ this.brokenNamespaceProfileMap = new HashMap<String, Profile>();
}
+
private Collection<MissingSchema> createActionsToApply() {
return new AbstractCollection<ZombieStereotypesDialog.MissingSchema>() {
@@ -249,9 +257,14 @@ public class ZombieStereotypesDialog extends TrayDialog {
SubMonitor subMonitor = SubMonitor.convert(monitor, actionsToApply.size());
for (Iterator<MissingSchema> iter = repairActions.iterator(); iter.hasNext();) {
- if (!iter.next().apply(diagnostics, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE))) {
+ MissingSchema missingSchema = iter.next();
+
+ missingSchema.initialiseRepairAction(brokenNamespaceProfileMap);
+ if (!missingSchema.apply(diagnostics, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE))) {
// Leave this one to try it again
iter.remove();
+ } else {
+ saveRepairAction(missingSchema);
}
}
@@ -375,6 +388,17 @@ public class ZombieStereotypesDialog extends TrayDialog {
return super.close();
}
+ protected void saveRepairAction(MissingSchema missingSchema) {
+ IRepairAction repairAction = missingSchema.getSelectedRepairAction();
+
+ if (repairAction instanceof IRepairAction.IApplyProfileAction) {
+ Profile appliedProfile = ((IRepairAction.IApplyProfileAction) repairAction).getAppliedProfile();
+ if (appliedProfile != null) {
+ brokenNamespaceProfileMap.put(missingSchema.getSchema().getNsURI(), appliedProfile);
+ }
+ }
+ }
+
//
// Nested types
//
@@ -441,6 +465,13 @@ public class ZombieStereotypesDialog extends TrayDialog {
this.selectedAction = descriptor.getSuggestedRepairAction(ePackage);
}
+ void initialiseRepairAction(Map<String, Profile> brokenNsProfileMap) {
+ if (selectedAction instanceof IRepairAction.IApplyProfileAction) {
+ ((IRepairAction.IApplyProfileAction) selectedAction).setPreviousAppliedProfile(brokenNsProfileMap.get(getSchema().getNsURI()));
+ }
+
+ }
+
Resource getResource() {
return descriptor.getResource();
}

Back to the top