Community
Participate
Working Groups
Editors / views throw the PartInitException during their init method to indicate they can't display. In the case of editors, the exception text usually indicates why the input wasn't acceptable. Actions like ShowInNavigatorAction and GotoTaskAction correctly catch this exception and display a message to the user to inform them what's wrong. The OpenExternalFileAction correctly catches the PartInitException but then fails to inform the user. So if you use this menu choice for an editor that can't accept files from outside the workspace, the user gets no feedback why (even if the associated editor says the input is invalid). OpenExternalFileAction should inform the user using the message text provided in the exception. See the code from OpenExternalFileAction below: public void run() { File file= queryFile(); if (file != null && file.exists()) { IEditorInput input= createEditorInput(file); String editorId= getEditorId(file); IWorkbenchPage page= fWindow.getActivePage(); try { page.openEditor(input, editorId); } catch (PartInitException e) { // ------------------------ inform user with MessageDialog ---- e.printStackTrace(); } } else if (file != null) { String msgFmt = TextEditorMessages.getString(...); String msg = MessageFormat.format(...); MessageDialog.openWarning(...), msg); } }
*** This bug has been marked as a duplicate of 58179 ***
The exception is now shown inside the editor.