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/infra
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/infra')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/TransactionHelper.java8
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Iterators2.java59
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/UIUtil.java42
3 files changed, 107 insertions, 2 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/TransactionHelper.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/TransactionHelper.java
index 5a0168f200e..0e9fc6ececc 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/TransactionHelper.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/TransactionHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
+ * Copyright (c) 2014 CEA LIST, 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
@@ -11,6 +11,7 @@
* Christian W. Damus (CEA) - bug 429826
* Christian W. Damus (CEA) - bug 408491
* Christian W. Damus (CEA) - bug 433320
+ * Christian W. Damus - bug 451557
*
*****************************************************************************/
package org.eclipse.papyrus.infra.core.utils;
@@ -21,6 +22,7 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.emf.common.util.WrappedException;
import org.eclipse.emf.transaction.Transaction;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -231,6 +233,8 @@ public class TransactionHelper extends org.eclipse.papyrus.infra.core.sasheditor
public void run() {
try {
runnable.run(monitorHolder[0]);
+ } catch (RuntimeException e) {
+ throw e;
} catch (Exception e) {
throw new WrappedException(e);
}
@@ -245,6 +249,8 @@ public class TransactionHelper extends org.eclipse.papyrus.infra.core.sasheditor
try {
privileged.run();
+ } catch (OperationCanceledException e) {
+ throw new InterruptedException(e.getLocalizedMessage());
} catch (WrappedException e) {
Exception unwrapped = e.exception();
if (unwrapped instanceof InvocationTargetException) {
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Iterators2.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Iterators2.java
new file mode 100644
index 00000000000..bd10ef4e9d7
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Iterators2.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.tools.util;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.common.util.TreeIterator;
+
+import com.google.common.collect.AbstractIterator;
+import com.google.common.collect.Iterators;
+
+/**
+ * Utilities for working with iterators that are not provided by {@linkplain Iterators Guava}.
+ */
+public class Iterators2 {
+ /**
+ * Not instantiable by clients.
+ */
+ private Iterators2() {
+ super();
+ }
+
+ /**
+ * Filters an EMF tree iterator for elements of a particular {@code type}.
+ *
+ * @param treeIterator
+ * the tree iterator to filter
+ * @param type
+ * the type of elements to include in the filtered tree iterator
+ * @return the filtered tree iterator
+ */
+ public static <T> TreeIterator<T> filter(final TreeIterator<?> treeIterator, final Class<T> type) {
+ class FilteredTreeIterator extends AbstractIterator<T> implements TreeIterator<T> {
+ final Iterator<T> delegate = Iterators.filter(treeIterator, type);
+
+ @Override
+ protected T computeNext() {
+ return delegate.hasNext() ? delegate.next() : endOfData();
+ }
+
+ public void prune() {
+ treeIterator.prune();
+ }
+ }
+
+ return new FilteredTreeIterator();
+ }
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/UIUtil.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/UIUtil.java
index a6ea02ed31e..410e78c2aa5 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/UIUtil.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/UIUtil.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,12 +8,14 @@
*
* Contributors:
* Christian W. Damus (CEA) - Initial API and implementation
+ * Christian W. Damus - bug 451557
*
*/
package org.eclipse.papyrus.infra.tools.util;
import java.util.ArrayList;
import java.util.Date;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
@@ -28,9 +30,15 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import org.eclipse.emf.common.util.AbstractTreeIterator;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IMemento;
+import com.google.common.collect.Iterators;
+
/**
* Miscellaneous general-purpose UI utilities.
@@ -132,6 +140,38 @@ public class UIUtil {
return asyncCall(Display.getDefault(), callable);
}
+ /**
+ * Obtains a tree iterator over all of the controls contained within a given {@code root} control, not including that {@code root}.
+ *
+ * @param root
+ * a control to iterate
+ * @return an unmodifiable iterator over all of its nested controls, which naturally will be empty if the {@code root} is not a {@link Composite}
+ */
+ public static TreeIterator<Control> allChildren(Control root) {
+ return new AbstractTreeIterator<Control>(root, false) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected Iterator<? extends Control> getChildren(Object object) {
+ return (object instanceof Composite) ? Iterators.forArray(((Composite) object).getChildren()) : Iterators.<Control> emptyIterator();
+ }
+ };
+ }
+
+ /**
+ * Obtains a tree iterator over all of the controls of a particular type contained within a given {@code root} control, not including that {@code root}.
+ *
+ * @param root
+ * a control to iterate
+ * @param type
+ * the type of children to include in the iteration
+ *
+ * @return an unmodifiable iterator over all of its nested controls, which naturally will be empty if the {@code root} is not a {@link Composite}
+ */
+ public static <C extends Control> TreeIterator<C> allChildren(Control root, final Class<C> type) {
+ return Iterators2.filter(allChildren(root), type);
+ }
+
//
// Nested types
//

Back to the top