diff options
| author | Dani Megert | 2016-01-27 16:32:09 +0000 |
|---|---|---|
| committer | Dani Megert | 2016-01-27 16:32:09 +0000 |
| commit | b5b43711fef1645eb643ddffc40b851b6325750f (patch) | |
| tree | 1959c68faa5e423b98297244a7941b720ac9eaba | |
| parent | 70f3c41e1686e64ee1b8d8bf5568f530e65f2487 (diff) | |
| download | eclipse.platform.ui-b5b43711fef1645eb643ddffc40b851b6325750f.tar.gz eclipse.platform.ui-b5b43711fef1645eb643ddffc40b851b6325750f.tar.xz eclipse.platform.ui-b5b43711fef1645eb643ddffc40b851b6325750f.zip | |
Fixed bug 486635: Exception logged after cancelling Editor Selection dialogI20160127-2000
3 files changed, 64 insertions, 38 deletions
diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenWithMenu.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenWithMenu.java index 5ef78e4b498..5118088e1fb 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenWithMenu.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenWithMenu.java @@ -23,6 +23,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.jface.action.ContributionItem; import org.eclipse.jface.resource.ImageDescriptor; @@ -343,6 +344,7 @@ public class OpenWithMenu extends ContributionItem { menuItem.setSelection(markAsSelected); menuItem.setText(IDEWorkbenchMessages.DefaultEditorDescription_name); + Listener listener = event -> { switch (event.type) { case SWT.Selection: @@ -354,6 +356,8 @@ public class OpenWithMenu extends ContributionItem { DialogUtil.openError(page.getWorkbenchWindow() .getShell(), IDEWorkbenchMessages.OpenWithMenu_dialogTitle, e.getMessage(), e); + } catch (OperationCanceledException ex) { + } } break; 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 67b40b8a262..cfbc6058b5b 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 @@ -43,6 +43,7 @@ import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.core.runtime.IAdapterManager; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.SafeRunner; @@ -364,6 +365,7 @@ public final class IDE { * @param activate * if <code>true</code> the editor will be activated opened * @return an open editor or <code>null</code> if an external editor was + * opened * @exception PartInitException * if the editor could not be initialized * @@ -504,7 +506,7 @@ public final class IDE { * @param activate * if <code>true</code> the editor will be activated * @return an open editor or <code>null</code> if an external editor was - * opened + * opened or if opening was canceled * @exception PartInitException * if the editor could not be initialized * @see org.eclipse.ui.IWorkbenchPage#openEditor(org.eclipse.ui.IEditorInput, @@ -535,7 +537,7 @@ public final class IDE { * @param determineContentType * attempt to resolve the content type for this file * @return an open editor or <code>null</code> if an external editor was - * opened + * opened or if opening was canceled * @exception PartInitException * if the editor could not be initialized * @see org.eclipse.ui.IWorkbenchPage#openEditor(org.eclipse.ui.IEditorInput, @@ -551,8 +553,12 @@ public final class IDE { } // open the editor on the file - IEditorDescriptor editorDesc = getEditorDescriptor(input, - determineContentType); + IEditorDescriptor editorDesc; + try { + editorDesc = getEditorDescriptor(input, determineContentType); + } catch (OperationCanceledException ex) { + return null; + } return page.openEditor(new FileEditorInput(input), editorDesc.getId(), activate); } @@ -571,7 +577,7 @@ public final class IDE { * @param input * the editor input * @return an open editor or <code>null</code> if an external editor was - * opened + * opened or if opening was canceled * @exception PartInitException * if the editor could not be initialized * @see org.eclipse.ui.IWorkbenchPage#openEditor(IEditorInput, String) @@ -584,7 +590,12 @@ public final class IDE { } // open the editor on the file - IEditorDescriptor editorDesc = getEditorDescriptor(input); + IEditorDescriptor editorDesc; + try { + editorDesc = getEditorDescriptor(input); + } catch (OperationCanceledException ex) { + return null; + } return page.openEditor(new FileEditorInput(input), editorDesc.getId()); } @@ -682,9 +693,11 @@ public final class IDE { * @return an editor descriptor, appropriate for opening the file * @throws PartInitException * if no editor can be found + * @throws OperationCanceledException + * in case descriptor lookup was canceled by the user */ public static IEditorDescriptor getEditorDescriptor(IFile file) - throws PartInitException { + throws PartInitException, OperationCanceledException { return getEditorDescriptor(file, true); } @@ -721,10 +734,12 @@ public final class IDE { * @return an editor descriptor, appropriate for opening the file * @throws PartInitException * if no editor can be found + * @throws OperationCanceledException + * in case descriptor lookup was canceled by the user * @since 3.1 */ public static IEditorDescriptor getEditorDescriptor(IFile file, - boolean determineContentType) throws PartInitException { + boolean determineContentType) throws PartInitException, OperationCanceledException { if (file == null) { throw new IllegalArgumentException(); @@ -930,10 +945,12 @@ public final class IDE { * @return an editor descriptor, appropriate for opening the file * @throws PartInitException * if no editor can be found + * @throws OperationCanceledException + * in case descriptor lookup was canceled by the user * @since 3.1 */ public static IEditorDescriptor getEditorDescriptor(String name) - throws PartInitException { + throws PartInitException, OperationCanceledException { return getEditorDescriptor(name, true); } @@ -967,10 +984,12 @@ public final class IDE { * @return an editor descriptor, appropriate for opening the file * @throws PartInitException * if no editor can be found + * @throws OperationCanceledException + * in case descriptor lookup was canceled by the user * @since 3.1 */ public static IEditorDescriptor getEditorDescriptor(String name, - boolean inferContentType) throws PartInitException { + boolean inferContentType) throws PartInitException, OperationCanceledException { if (name == null) { throw new IllegalArgumentException(); @@ -999,12 +1018,14 @@ public final class IDE { * @return IEditorDescriptor * @throws PartInitException * if no valid editor can be found + * @throws OperationCanceledException + * in case descriptor lookup was canceled by the user * * @since 3.1 */ private static IEditorDescriptor getEditorDescriptor(String name, IEditorRegistry editorReg, IEditorDescriptor defaultDescriptor) - throws PartInitException { + throws PartInitException, OperationCanceledException { if (defaultDescriptor != null) { return defaultDescriptor; @@ -1092,7 +1113,8 @@ public final class IDE { * the marker to open * @param activate * if <code>true</code> the editor will be activated - * @return an open editor or <code>null</code> not possible + * @return an open editor or <code>null</code> if not possible or if opening + * was canceled * @exception PartInitException * if the editor could not be initialized */ @@ -1142,27 +1164,28 @@ public final class IDE { } /** - * Opens an editor on the given IFileStore object. - * <p> + * Opens an editor on the given IFileStore object. + * <p> * Unlike the other <code>openEditor</code> methods, this one * can be used to open files that reside outside the workspace * resource set. - * </p> - * <p> - * If the page already has an editor open on the target object then that - * editor is brought to front; otherwise, a new editor is opened. - * </p> - * - * @param page - * the page in which the editor will be opened - * @param fileStore - * the IFileStore representing the file to open - * @return an open editor or <code>null</code> if an external editor was opened - * @exception PartInitException - * if the editor could not be initialized - * @see org.eclipse.ui.IWorkbenchPage#openEditor(IEditorInput, String) - * @since 3.3 - */ + * </p> + * <p> + * If the page already has an editor open on the target object then that + * editor is brought to front; otherwise, a new editor is opened. + * </p> + * + * @param page + * the page in which the editor will be opened + * @param fileStore + * the IFileStore representing the file to open + * @return an open editor or <code>null</code> if an external editor was + * opened or if opening was canceled + * @exception PartInitException + * if the editor could not be initialized + * @see org.eclipse.ui.IWorkbenchPage#openEditor(IEditorInput, String) + * @since 3.3 + */ public static IEditorPart openEditorOnFileStore(IWorkbenchPage page, IFileStore fileStore) throws PartInitException { //sanity checks if (page == null) { @@ -1170,7 +1193,12 @@ public final class IDE { } IEditorInput input = getEditorInput(fileStore); - String editorId = getEditorId(fileStore); + String editorId; + try { + editorId = getEditorId(fileStore); + } catch (OperationCanceledException ex) { + return null; + } // open the editor on the file return page.openEditor(input, editorId); 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 3589e544619..b41036cbd38 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 @@ -7,12 +7,10 @@ * * 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; @@ -47,11 +45,7 @@ public abstract class OpenAndLinkWithEditorHelper { @Override public final void open(OpenEvent event) { lastOpenSelection = event.getSelection(); - try { - OpenAndLinkWithEditorHelper.this.open(lastOpenSelection, OpenStrategy.activateOnOpen()); - } catch (OperationCanceledException e) { - // ignore: user cancel, see bug 485201. - } + OpenAndLinkWithEditorHelper.this.open(lastOpenSelection, OpenStrategy.activateOnOpen()); } /* |
