Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-11-14 17:05:36 +0000
committerChristian W. Damus2014-11-14 17:05:36 +0000
commite8ecf4753926f7755f7902e25690030ee1a36704 (patch)
treec6308e89fac50a36b814188b5e49ff9719de6150 /plugins/uml
parent14be55490adc7e7b1325fd033600ed912917aad6 (diff)
downloadorg.eclipse.papyrus-e8ecf4753926f7755f7902e25690030ee1a36704.tar.gz
org.eclipse.papyrus-e8ecf4753926f7755f7902e25690030ee1a36704.tar.xz
org.eclipse.papyrus-e8ecf4753926f7755f7902e25690030ee1a36704.zip
451557: Stereotype repair dialog buttons still enabled during long repair operation
https://bugs.eclipse.org/bugs/show_bug.cgi?id=451557 Disable the repair dialog buttons while the repair is in progress and provide a cancel button to stop and rewind the repair operation.
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/participants/StereotypeApplicationRepairParticipant.java18
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ApplyProfileAction.java8
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/DeleteAction.java8
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java33
4 files changed, 57 insertions, 10 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/participants/StereotypeApplicationRepairParticipant.java b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/participants/StereotypeApplicationRepairParticipant.java
index 80d2bd42644..f0a25cb721a 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/participants/StereotypeApplicationRepairParticipant.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/participants/StereotypeApplicationRepairParticipant.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 CEA and others.
+ * Copyright (c) 2014 CEA, 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,6 +8,7 @@
*
* Contributors:
* Christian W. Damus (CEA) - Initial API and implementation
+ * Christian W. Damus - bug 451557
*
*/
package org.eclipse.papyrus.uml.modelrepair.internal.participants;
@@ -20,6 +21,7 @@ import java.util.Queue;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
@@ -219,6 +221,10 @@ public class StereotypeApplicationRepairParticipant extends PackageOperations im
SubMonitor sub = SubMonitor.convert(monitor, (2 * stereotypeApplications.size()) + 2);
for (EObject next : stereotypeApplications) {
+ if (sub.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
EObject newInstance = copier.copy(next);
if ((newInstance != null) && (newInstance != next)) {
// Depends how we copied the stereotype instance (by applying again or not),
@@ -239,6 +245,10 @@ public class StereotypeApplicationRepairParticipant extends PackageOperations im
// Preserve the identities of stereotype applications and their contents and update references not accounted for by the copier
// (for example, references from Notation views/styles in the diagrams)
for (Map.Entry<EObject, EObject> next : copier.entrySet()) {
+ if (sub.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
EObject original = next.getKey();
EObject copy = next.getValue();
@@ -273,10 +283,16 @@ public class StereotypeApplicationRepairParticipant extends PackageOperations im
}
sub2.done();
+ if (sub.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
UML2Util.destroyAll(stereotypeApplications);
sub.worked(1);
copier.clear();
+
+ sub.done();
}
}
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 82ce8181436..b7cb38edeee 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 CEA and others.
+ * Copyright (c) 2014 CEA, 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,6 +8,7 @@
*
* Contributors:
* Christian W. Damus (CEA) - Initial API and implementation
+ * Christian W. Damus - bug 451557
*
*/
package org.eclipse.papyrus.uml.modelrepair.internal.stereotypes;
@@ -16,6 +17,7 @@ import java.util.Collection;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.ecore.EObject;
@@ -84,6 +86,10 @@ public class ApplyProfileAction extends AbstractRepairAction {
// Apply the profile
StereotypeApplicationRepairParticipant.createStereotypeApplicationMigrator(profile, diagnostics).migrate(stereotypeApplications, sub.newChild(stereotypeApplications.size()));
for (Package next : packages) {
+ if (sub.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
next.applyProfile(profile);
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/DeleteAction.java b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/DeleteAction.java
index 8c9f7692425..ab10cee87cc 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/DeleteAction.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/DeleteAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 CEA and others.
+ * Copyright (c) 2014 CEA, 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,6 +8,7 @@
*
* Contributors:
* Christian W. Damus (CEA) - Initial API and implementation
+ * Christian W. Damus - bug 451557
*
*/
package org.eclipse.papyrus.uml.modelrepair.internal.stereotypes;
@@ -15,6 +16,7 @@ package org.eclipse.papyrus.uml.modelrepair.internal.stereotypes;
import java.util.Collection;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.ecore.EObject;
@@ -37,6 +39,10 @@ public class DeleteAction extends AbstractRepairAction {
monitor = SubMonitor.convert(monitor, "Deleting stereotype applications...", stereotypeApplications.size());
for (EObject next : stereotypeApplications) {
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
destroy(next);
monitor.worked(1);
}
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 609cfbb0df2..ba476c48916 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014 CEA and others.
+ * Copyright (c) 2013, 2014 CEA, 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
@@ -10,6 +10,7 @@
* CEA - Initial API and implementation
* Christian W. Damus (CEA) - bug 431953 (adapted from SwitchProfileDialog)
* Christian W. Damus - bug 451338
+ * Christian W. Damus - bug 451557
*
*/
package org.eclipse.papyrus.uml.modelrepair.ui;
@@ -61,6 +62,7 @@ import org.eclipse.papyrus.infra.core.utils.TransactionHelper;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceSet;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.services.markerlistener.dialogs.DiagnosticDialog;
+import org.eclipse.papyrus.infra.tools.util.UIUtil;
import org.eclipse.papyrus.uml.modelrepair.Activator;
import org.eclipse.papyrus.uml.modelrepair.internal.stereotypes.IRepairAction;
import org.eclipse.papyrus.uml.modelrepair.internal.stereotypes.ZombieStereotypesDescriptor;
@@ -68,6 +70,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
@@ -194,7 +197,7 @@ public class ZombieStereotypesDialog extends TrayDialog {
table.setLabelProvider(new ZombiesLabelProvider());
table.setInput(getMissingSchemas());
- progress = new ProgressMonitorPart(self, null);
+ progress = new ProgressMonitorPart(self, null, true);
progress.setLayoutData(new GridData(SWT.FILL, SWT.LEAD, true, false));
progress.setVisible(false);
@@ -256,21 +259,26 @@ public class ZombieStereotypesDialog extends TrayDialog {
}
});
- Cursor waitCursor = new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT);
+ final Cursor previousCursor = getShell().getCursor();
+ Cursor waitCursor = getShell().getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
try {
getShell().setCursor(waitCursor);
progress.setVisible(true);
+ progress.attachToCancelComponent(null); // Enable the stop button
+ enableButtons(false);
ModalContext.run(runnable, true, progress, getShell().getDisplay());
+ } catch (InterruptedException e) {
+ // User cancelled. That's normal
} catch (Exception e) {
- getShell().setCursor(null);
+ getShell().setCursor(previousCursor);
Throwable t = e;
if (e instanceof InvocationTargetException) {
t = ((InvocationTargetException) e).getTargetException();
}
StatusManager.getManager().handle(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to repair stereotypes.", t), StatusManager.BLOCK | StatusManager.LOG);
} finally {
- getShell().setCursor(null);
- waitCursor.dispose();
+ enableButtons(true);
+ getShell().setCursor(previousCursor);
progress.setVisible(false);
}
@@ -318,6 +326,12 @@ public class ZombieStereotypesDialog extends TrayDialog {
super.buttonPressed(buttonId);
}
+ void enableButtons(boolean enable) {
+ for (Iterator<Button> iter = UIUtil.allChildren(getButtonBar(), Button.class); iter.hasNext();) {
+ iter.next().setEnabled(enable);
+ }
+ }
+
@Override
public void create() {
super.create();
@@ -343,7 +357,12 @@ public class ZombieStereotypesDialog extends TrayDialog {
protected void okPressed() {
applyPressed();
- super.okPressed();
+ updateControls();
+
+ // Maybe the user cancelled the work
+ if (!getButton(APPLY_ID).isEnabled()) {
+ super.okPressed();
+ }
}
@Override

Back to the top