Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrik Suzzi2016-01-21 00:16:30 +0000
committerPatrik Suzzi2016-01-21 11:04:03 +0000
commitfed29d30e755af1480939dc62a117c13073ab4c8 (patch)
tree29a7b588bd97c8c22882bc98269ad5bb4c556117
parent5a3552b15cf70c8146faeef521591c33b02376e3 (diff)
downloadeclipse.platform.ui-fed29d30e755af1480939dc62a117c13073ab4c8.tar.gz
eclipse.platform.ui-fed29d30e755af1480939dc62a117c13073ab4c8.tar.xz
eclipse.platform.ui-fed29d30e755af1480939dc62a117c13073ab4c8.zip
Bug 485201 - Cancel button in "Ask via popup" strategy opens the select
Document that the IUnknownEditorStrategy can throw OperationCanceledException or CoreException while performing an editor descriptor lookup. Throw OperationCanceledException if user cancels the editor selection dialog in AskUserViaPopupUnknownEditorStrategy and ignore this exception in the caller to avoid superfluous error popup. Change-Id: Ia43f44b1fb593692bd8f23aec01322df8f17db81 Signed-off-by: Patrik Suzzi <psuzzi@gmail.com> Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IDE.java10
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IUnknownEditorStrategy.java12
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/AskUserViaPopupUnknownEditorStrategy.java11
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java4
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties4
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/OpenAndLinkWithEditorHelper.java10
6 files changed, 41 insertions, 10 deletions
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IDE.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IDE.java
index db24ab26094..67b40b8a262 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IDE.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IDE.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2015 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 IBM Corporation 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Jan-Ove Weichel <janove.weichel@vogella.com> - Bug 411578
+ * Andrey Loskutov <loskutov@gmx.de> - Bug 485201
*******************************************************************************/
package org.eclipse.ui.ide;
@@ -1010,7 +1011,12 @@ public final class IDE {
}
IUnknownEditorStrategy strategy = getUnknowEditorStrategy();
- IEditorDescriptor editorDesc = strategy.getEditorDescriptor(name, editorReg);
+ IEditorDescriptor editorDesc;
+ try {
+ editorDesc = strategy.getEditorDescriptor(name, editorReg);
+ } catch (CoreException e) {
+ throw new PartInitException(IDEWorkbenchMessages.IDE_noFileEditorFound, e);
+ }
// if no valid editor found, bail out
if (editorDesc == null) {
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IUnknownEditorStrategy.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IUnknownEditorStrategy.java
index 934919ae1ce..bd1ee270ece 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IUnknownEditorStrategy.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IUnknownEditorStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Red Hat Inc.
+ * Copyright (c) 2015, 2016 Red Hat Inc. 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
@@ -7,9 +7,12 @@
*
* Contributors:
* Mickael Istria (Red Hat Inc.) - initial API and implementation
+ * Andrey Loskutov <loskutov@gmx.de> - Bug 485201
*******************************************************************************/
package org.eclipse.ui.ide;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorRegistry;
@@ -29,7 +32,12 @@ public interface IUnknownEditorStrategy {
* the IDE editor registry
* @return an {@link IEditorDescriptor} for editor to use to open this file,
* or null if no editor was resolved for that file name.
+ * @throws CoreException
+ * in case descriptor lookup fails with an error
+ * @throws OperationCanceledException
+ * in case descriptor lookup was cancelled by the user
*/
- IEditorDescriptor getEditorDescriptor(String fileName, IEditorRegistry editorRegistry);
+ IEditorDescriptor getEditorDescriptor(String fileName, IEditorRegistry editorRegistry)
+ throws CoreException, OperationCanceledException;
}
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/AskUserViaPopupUnknownEditorStrategy.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/AskUserViaPopupUnknownEditorStrategy.java
index 20e91343af4..cb20d675227 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/AskUserViaPopupUnknownEditorStrategy.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/AskUserViaPopupUnknownEditorStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Red Hat Inc.
+ * Copyright (c) 2015, 2016 Red Hat Inc. 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
@@ -7,9 +7,12 @@
*
* Contributors:
* Mickael Istria (Red Hat Inc.) - initial API and implementation
+ * Patrik Suzzi <psuzzi@gmail.com> - Bug 485201
*******************************************************************************/
package org.eclipse.ui.internal.ide;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.PlatformUI;
@@ -28,7 +31,11 @@ public class AskUserViaPopupUnknownEditorStrategy implements IUnknownEditorStrat
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
dialog.setFileName(fileName);
dialog.setBlockOnOpen(true);
- dialog.open();
+
+ if (IDialogConstants.CANCEL_ID == dialog.open()) {
+ throw new OperationCanceledException(IDEWorkbenchMessages.IDE_noFileEditorSelectedUserCanceled);
+ }
+
return dialog.getSelectedEditor();
}
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java
index ad8f8333397..471a40f332b 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 IBM Corporation 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
@@ -18,6 +18,7 @@
* Lars Vogel <Lars.Vogel@vogella.com> - Bug 431862
* Christian Georgi (SAP SE) - bug 432480, bug 458811
* Jan-Ove Weichel <janove.weichel@vogella.com> - Bug 411578
+ * Patrik Suzzi <psuzzi@gmail.com> - Bug 485201
*******************************************************************************/
package org.eclipse.ui.internal.ide;
@@ -32,6 +33,7 @@ public class IDEWorkbenchMessages extends NLS {
public static String IDEWorkbenchAdvisor_preHistoryCompaction;
public static String IDEWorkbenchAdvisor_postHistoryCompaction;
+ public static String IDE_noFileEditorSelectedUserCanceled;
public static String IDE_noFileEditorFound;
public static String IDE_coreExceptionFileStore;
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties
index defd772001c..87f4de910b4 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2015 IBM Corporation and others.
+# Copyright (c) 2000, 2016 IBM Corporation 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
@@ -25,6 +25,7 @@
# - Bug 90292: Customizable strategy for unassociated files
# Robert Roth <robert.roth.off@gmail.com> - bug 310483, duplicate mnemonic
# Jan-Ove Weichel <janove.weichel@vogella.com> - Bug 411578
+# Patrik Suzzi <psuzzi@gmail.com> - Bug 485201
###############################################################################
# package: org.eclipse.ui.ide
@@ -34,6 +35,7 @@ IDEWorkbenchAdvisor_cancelHistoryPruning=Cancel to skip compacting local history
IDEWorkbenchAdvisor_preHistoryCompaction=Saving workbench state.
IDEWorkbenchAdvisor_postHistoryCompaction=Disconnecting from workspace.
+IDE_noFileEditorSelectedUserCanceled = No editor selected, operation canceled by user.
IDE_noFileEditorFound = No editor found to edit the file resource.
IDE_sideEffectWarning=Potential side effects have been identified.
IDE_coreExceptionFileStore = CoreException opening the file store on the URI.
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/OpenAndLinkWithEditorHelper.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/OpenAndLinkWithEditorHelper.java
index 4d5e5a9c645..3589e544619 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/OpenAndLinkWithEditorHelper.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/OpenAndLinkWithEditorHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 IBM Corporation 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
@@ -7,10 +7,12 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Andrey Loskutov <loskutov@gmx.de> - Bug 485201
*******************************************************************************/
package org.eclipse.ui;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -45,7 +47,11 @@ public abstract class OpenAndLinkWithEditorHelper {
@Override
public final void open(OpenEvent event) {
lastOpenSelection = event.getSelection();
- OpenAndLinkWithEditorHelper.this.open(lastOpenSelection, OpenStrategy.activateOnOpen());
+ try {
+ OpenAndLinkWithEditorHelper.this.open(lastOpenSelection, OpenStrategy.activateOnOpen());
+ } catch (OperationCanceledException e) {
+ // ignore: user cancel, see bug 485201.
+ }
}
/*

Back to the top