Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2013-10-09 06:02:43 -0400
committerGerrit Code Review @ Eclipse.org2013-10-11 04:30:27 -0400
commit792e66bc29b83d8e2510dfd5c54ccde91892020f (patch)
tree184aeec9df4a6368c76dc32ab2582c966d2ed072 /plugins/org.eclipse.emf.compare.ide.ui/src
parent52b5d75d044ee51f6915412e642d7298f0049b1e (diff)
downloadorg.eclipse.emf.compare-792e66bc29b83d8e2510dfd5c54ccde91892020f.tar.gz
org.eclipse.emf.compare-792e66bc29b83d8e2510dfd5c54ccde91892020f.tar.xz
org.eclipse.emf.compare-792e66bc29b83d8e2510dfd5c54ccde91892020f.zip
[405273] - Fix UI does not detect invalid models
A message is logged, a pop-up is display with the error and the editor is closed. Bug: 405273 Change-Id: I4af6ea8c7dbff903d694ebe214323ee2bffe68bf
Diffstat (limited to 'plugins/org.eclipse.emf.compare.ide.ui/src')
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ProjectModelResolver.java3
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java10
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/util/ExceptionUtil.java52
3 files changed, 62 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ProjectModelResolver.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ProjectModelResolver.java
index 38ee7e6d4..3582a4a60 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ProjectModelResolver.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ProjectModelResolver.java
@@ -17,6 +17,7 @@ import static org.eclipse.emf.compare.ide.ui.internal.util.PlatformElementUtil.a
import static org.eclipse.emf.compare.ide.utils.ResourceUtil.createURIFor;
import static org.eclipse.emf.compare.ide.utils.ResourceUtil.hasContentType;
+import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
@@ -286,7 +287,7 @@ public class ProjectModelResolver extends LogicalModelResolver {
try {
project.accept(modelVisitor);
} catch (CoreException e) {
- EMFCompareIDEUIPlugin.getDefault().log(e);
+ Throwables.propagate(e);
}
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
index 83f60964b..0e0e7f63f 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
@@ -55,6 +55,7 @@ import org.eclipse.emf.compare.ide.ui.internal.logical.ComparisonScopeBuilder;
import org.eclipse.emf.compare.ide.ui.internal.logical.IdenticalResourceMinimizer;
import org.eclipse.emf.compare.ide.ui.internal.logical.StreamAccessorStorage;
import org.eclipse.emf.compare.ide.ui.internal.logical.SubscriberStorageAccessor;
+import org.eclipse.emf.compare.ide.ui.internal.util.ExceptionUtil;
import org.eclipse.emf.compare.ide.ui.internal.util.PlatformElementUtil;
import org.eclipse.emf.compare.ide.ui.internal.util.SWTUtil;
import org.eclipse.emf.compare.ide.ui.logical.IModelResolver;
@@ -459,8 +460,13 @@ public class EMFCompareStructureMergeViewer extends AbstractViewerWrapper implem
final ITypedElement right = input.getRight();
final ITypedElement origin = input.getAncestor();
- final IComparisonScope scope = buildComparisonScope(left, right, origin, subMonitor
- .newChild(85));
+ IComparisonScope scope = null;
+ try {
+ scope = buildComparisonScope(left, right, origin, subMonitor.newChild(85));
+ } catch (Exception e) {
+ ExceptionUtil.handleException(e, getCompareConfiguration(), true);
+ return;
+ }
final Comparison compareResult = EMFCompare
.builder()
.setMatchEngineFactoryRegistry(
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/util/ExceptionUtil.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/util/ExceptionUtil.java
new file mode 100644
index 000000000..be034400f
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/util/ExceptionUtil.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.ide.ui.internal.util;
+
+import com.google.common.base.Throwables;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIPlugin;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * This provides access to commonly used functions which need to handle exceptions.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+public class ExceptionUtil {
+
+ /**
+ * Log exception and close editor if asked.
+ *
+ * @param e
+ * the exception to log.
+ * @param configuration
+ * the compare configuration object.
+ * @param closeEditor
+ * true if you want to close editor.
+ */
+ public static void handleException(final Exception e, final CompareConfiguration configuration,
+ final boolean closeEditor) {
+ if (closeEditor) {
+ final IWorkbenchPart workbenchPart = configuration.getContainer().getWorkbenchPart();
+ if (workbenchPart != null) {
+ SWTUtil.safeAsyncExec(new Runnable() {
+ public void run() {
+ workbenchPart.getSite().getPage().closeEditor((IEditorPart)workbenchPart, false);
+ }
+ });
+ }
+ }
+ EMFCompareIDEUIPlugin.getDefault().log(e);
+ Throwables.propagate(e);
+ }
+}

Back to the top