Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 22576 Details for
Bug 90582
[EditorMgmt] (regression) openEditor does not throw PartInitException anymore
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix for this PR
90582_workbench_patch.txt (text/plain), 21.17 KB, created by
Stefan Xenos
on 2005-06-07 19:15:54 EDT
(
hide
)
Description:
Fix for this PR
Filename:
MIME Type:
Creator:
Stefan Xenos
Created:
2005-06-07 19:15:54 EDT
Size:
21.17 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/internal/EditorManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorManager.java,v >retrieving revision 1.87 >diff -u -r1.87 EditorManager.java >--- Eclipse UI/org/eclipse/ui/internal/EditorManager.java 16 May 2005 21:16:50 -0000 1.87 >+++ Eclipse UI/org/eclipse/ui/internal/EditorManager.java 7 Jun 2005 23:09:49 -0000 >@@ -759,7 +759,7 @@ > */ > EditorSite createSite(final IEditorReference ref, final IEditorPart part, > final EditorDescriptor desc, final IEditorInput input) >- throws PartInitException { >+ throws PartInitException, PartCreationException { > EditorSite site = new EditorSite(ref, part, page, desc); > if (desc != null) > site.setActionBars(createEditorActionBars(desc)); >@@ -777,7 +777,7 @@ > > // Sanity-check the site > if (part.getSite() != site || part.getEditorSite() != site) >- throw new PartInitException( >+ throw new PartCreationException( > NLS.bind(WorkbenchMessages.EditorManager_siteIncorrect, desc.getId() )); > > } catch (Exception e) { >@@ -785,8 +785,10 @@ > site.dispose(); > if (e instanceof PartInitException) > throw (PartInitException) e; >- >- throw new PartInitException(WorkbenchMessages.EditorManager_errorInInit, e); >+ if (e instanceof PartCreationException) >+ throw (PartCreationException) e; >+ >+ throw new PartCreationException(WorkbenchMessages.EditorManager_errorInInit, e); > } > > return site; >Index: Eclipse UI/org/eclipse/ui/internal/EditorReference.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorReference.java,v >retrieving revision 1.5 >diff -u -r1.5 EditorReference.java >--- Eclipse UI/org/eclipse/ui/internal/EditorReference.java 16 May 2005 21:16:50 -0000 1.5 >+++ Eclipse UI/org/eclipse/ui/internal/EditorReference.java 7 Jun 2005 23:09:50 -0000 >@@ -353,73 +353,58 @@ > * @param manager TODO > * @return > */ >- protected IWorkbenchPart createPart() { >- >- PartInitException exception = null; >+ protected IWorkbenchPart createErrorPart(Exception exception) { > > IWorkbenchPart result = null; >+ >+ IStatus originalStatus = WorkbenchPlugin.getStatus(exception); >+ IStatus logStatus = StatusUtil.newStatus(originalStatus, >+ NLS.bind("Unable to create editor ID {0}: {1}", //$NON-NLS-1$ >+ getId(), originalStatus.getMessage())); >+ WorkbenchPlugin.log(logStatus); >+ >+ IStatus displayStatus = StatusUtil.newStatus(originalStatus, >+ NLS.bind(WorkbenchMessages.EditorManager_unableToCreateEditor, >+ originalStatus.getMessage())); >+ >+ ErrorEditorPart part = new ErrorEditorPart(displayStatus); >+ >+ IEditorInput input; >+ try { >+ input = getEditorInput(); >+ } catch (PartInitException e1) { >+ input = new NullEditorInput(); >+ } >+ >+ EditorPane pane = (EditorPane)getPane(); >+ >+ pane.createControl((Composite) manager.page.getEditorPresentation().getLayoutPart().getControl()); >+ >+ EditorDescriptor descr = getDescriptor(); > >- // Try to restore the editor -- this does the real work of restoring the editor >- // >+ EditorSite site = new EditorSite(this, part, manager.page, descr); >+ >+ site.setActionBars(new EditorActionBars(new NullActionBars(), getId())); > try { >- result = createPartHelper(); >+ part.init(site, input); > } catch (PartInitException e) { >- exception = e; >+ WorkbenchPlugin.log(e); >+ return null; > } > >+ Composite parent = (Composite)pane.getControl(); >+ Composite content = new Composite(parent, SWT.NONE); >+ content.setLayout(new FillLayout()); > >- // If unable to create the part, create an error part instead >- if (exception != null) { >- >- IStatus originalStatus = exception.getStatus(); >- IStatus logStatus = StatusUtil.newStatus(originalStatus, >- NLS.bind("Unable to create editor ID {0}: {1}", //$NON-NLS-1$ >- getId(), originalStatus.getMessage())); >- WorkbenchPlugin.log(logStatus); >- >- IStatus displayStatus = StatusUtil.newStatus(originalStatus, >- NLS.bind(WorkbenchMessages.EditorManager_unableToCreateEditor, >- originalStatus.getMessage())); >- >- ErrorEditorPart part = new ErrorEditorPart(displayStatus); >- >- IEditorInput input; >- try { >- input = getEditorInput(); >- } catch (PartInitException e1) { >- input = new NullEditorInput(); >- } >- >- EditorPane pane = (EditorPane)getPane(); >- >- pane.createControl((Composite) manager.page.getEditorPresentation().getLayoutPart().getControl()); >- >- EditorDescriptor descr = getDescriptor(); >- >- EditorSite site = new EditorSite(this, part, manager.page, descr); >- >- site.setActionBars(new EditorActionBars(new NullActionBars(), getId())); >- try { >- part.init(site, input); >- } catch (PartInitException e) { >- WorkbenchPlugin.log(e); >- return null; >- } >- >- Composite parent = (Composite)pane.getControl(); >- Composite content = new Composite(parent, SWT.NONE); >- content.setLayout(new FillLayout()); >- >- try { >- part.createPartControl(content); >- } catch (Exception e) { >- content.dispose(); >- WorkbenchPlugin.log(e); >- return null; >- } >- >- result = part; >+ try { >+ part.createPartControl(content); >+ } catch (Exception e) { >+ content.dispose(); >+ WorkbenchPlugin.log(e); >+ return null; > } >+ >+ result = part; > > return result; > } >@@ -514,7 +499,16 @@ > } > } > >- private IEditorPart createPartHelper() throws PartInitException { >+ /** >+ * Creates the real part. Returns the newly created part or throws an exception on failure. >+ * This method will not create an error part. >+ * >+ * @return the newly created part >+ * @throws PartInitException if part creation was aborted due to a PartInitException thrown >+ * from IEditorPart.init >+ * @throws PartCreationException if part creation was aborted due to an unanticipated error >+ */ >+ protected IWorkbenchPart createPart() throws PartInitException, PartCreationException { > > // Things that will need to be disposed if an exception occurs (listed in the order they > // need to be disposed, and set to null if they haven't been created yet) >@@ -531,7 +525,7 @@ > EditorDescriptor desc = getDescriptor(); > > if (desc == null) { >- throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_missing_editor_descriptor, editorID)); //$NON-NLS-1$ >+ throw new PartCreationException(NLS.bind(WorkbenchMessages.EditorManager_missing_editor_descriptor, editorID)); //$NON-NLS-1$ > } > > IEditorPart part; >@@ -551,10 +545,10 @@ > part = ComponentSupport.getSystemInPlaceEditor(); > > if (part == null) { >- throw new PartInitException(WorkbenchMessages.EditorManager_no_in_place_support); //$NON-NLS-1$ >+ throw new PartCreationException(WorkbenchMessages.EditorManager_no_in_place_support); //$NON-NLS-1$ > } > } else { >- throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_invalid_editor_descriptor, editorID)); //$NON-NLS-1$ >+ throw new PartCreationException(NLS.bind(WorkbenchMessages.EditorManager_invalid_editor_descriptor, editorID)); //$NON-NLS-1$ > } > // Create a pane for this part > PartPane pane = getPane(); >@@ -630,7 +624,11 @@ > } > } > >- throw new PartInitException(StatusUtil.getLocalizedMessage(e), StatusUtil.getCause(e)); >+ if (e instanceof PartInitException) { >+ throw (PartInitException)e; >+ } >+ >+ throw new PartCreationException(StatusUtil.getLocalizedMessage(e), StatusUtil.getCause(e)); > } > > } >Index: Eclipse UI/org/eclipse/ui/internal/ViewReference.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewReference.java,v >retrieving revision 1.5 >diff -u -r1.5 ViewReference.java >--- Eclipse UI/org/eclipse/ui/internal/ViewReference.java 16 May 2005 21:16:50 -0000 1.5 >+++ Eclipse UI/org/eclipse/ui/internal/ViewReference.java 7 Jun 2005 23:09:50 -0000 >@@ -167,70 +167,51 @@ > * @param factory TODO > * @return > */ >- protected IWorkbenchPart createPart() { >+ protected IWorkbenchPart createErrorPart(Exception exception) { > >- // Check the status of this part >- >- IWorkbenchPart result = null; >- PartInitException exception = null; >+ IStatus partStatus = WorkbenchPlugin.getStatus(exception); >+ IStatus displayStatus = StatusUtil.newStatus(partStatus, >+ NLS.bind(WorkbenchMessages.ViewFactory_initException, partStatus.getMessage())); >+ >+ IStatus logStatus = StatusUtil.newStatus(partStatus, >+ NLS.bind("Unable to create view ID {0}: {1}", getId(), partStatus.getMessage())); //$NON-NLS-1$ >+ WorkbenchPlugin.log(logStatus); >+ >+ IViewDescriptor desc = factory.viewReg.find(getId()); >+ String label = getId(); >+ if (desc != null) { >+ label = desc.getLabel(); >+ } > >- // Try to restore the view -- this does the real work of restoring the view >- // >+ ErrorViewPart part = new ErrorViewPart(displayStatus); >+ >+ PartPane pane = getPane(); >+ ViewSite site = new ViewSite(this, part, factory.page, getId(), PlatformUI.PLUGIN_ID, label); >+ site.setActionBars(new ViewActionBars(factory.page.getActionBars(), >+ (ViewPane) pane)); > try { >- result = createPartHelper(); >+ part.init(site); > } catch (PartInitException e) { >- exception = e; >+ WorkbenchPlugin.log(e); >+ return null; > } >- >- // If unable to create the part, create an error part instead >- if (exception != null) { >- IStatus partStatus = exception.getStatus(); >- IStatus displayStatus = StatusUtil.newStatus(partStatus, >- NLS.bind(WorkbenchMessages.ViewFactory_initException, partStatus.getMessage())); >- >- IStatus logStatus = StatusUtil.newStatus(partStatus, >- NLS.bind("Unable to create view ID {0}: {1}", getId(), partStatus.getMessage())); //$NON-NLS-1$ >- WorkbenchPlugin.log(logStatus); >- >- IViewDescriptor desc = factory.viewReg.find(getId()); >- String label = getId(); >- if (desc != null) { >- label = desc.getLabel(); >- } >- >- ErrorViewPart part = new ErrorViewPart(displayStatus); >+ part.setPartName(label); > >- PartPane pane = getPane(); >- ViewSite site = new ViewSite(this, part, factory.page, getId(), PlatformUI.PLUGIN_ID, label); >- site.setActionBars(new ViewActionBars(factory.page.getActionBars(), >- (ViewPane) pane)); >- try { >- part.init(site); >- } catch (PartInitException e) { >- WorkbenchPlugin.log(e); >- return null; >- } >- part.setPartName(label); >- >- Composite parent = (Composite)pane.getControl(); >- Composite content = new Composite(parent, SWT.NONE); >- content.setLayout(new FillLayout()); >- >- try { >- part.createPartControl(content); >- } catch (Exception e) { >- content.dispose(); >- WorkbenchPlugin.log(e); >- return null; >- } >- >- result = part; >+ Composite parent = (Composite)pane.getControl(); >+ Composite content = new Composite(parent, SWT.NONE); >+ content.setLayout(new FillLayout()); >+ >+ try { >+ part.createPartControl(content); >+ } catch (Exception e) { >+ content.dispose(); >+ WorkbenchPlugin.log(e); >+ return null; > } >- >- return result; >+ return part; > } > >- private IWorkbenchPart createPartHelper() throws PartInitException { >+ protected IWorkbenchPart createPart() throws PartInitException, PartCreationException { > > IWorkbenchPart result = null; > >@@ -241,7 +222,7 @@ > > IViewDescriptor desc = factory.viewReg.find(getId()); > if (desc == null) { >- throw new PartInitException(WorkbenchMessages.ViewFactory_couldNotCreate); >+ throw new PartCreationException(WorkbenchMessages.ViewFactory_couldNotCreate); > } > > // Create the part pane >@@ -287,7 +268,7 @@ > } > > if (view.getSite() != site) { >- throw new PartInitException(WorkbenchMessages.ViewFactory_siteException, null); >+ throw new PartCreationException(WorkbenchMessages.ViewFactory_siteException, null); > } > int style = SWT.NONE; > if(view instanceof IWorkbenchPartOrientation) { >@@ -385,7 +366,11 @@ > } > } > >- throw new PartInitException(WorkbenchPlugin.getStatus(e)); >+ if (e instanceof PartInitException) { >+ throw (PartInitException)e; >+ } >+ >+ throw new PartCreationException(StatusUtil.getLocalizedMessage(e), StatusUtil.getCause(e)); > } > > return result; >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java,v >retrieving revision 1.220 >diff -u -r1.220 WorkbenchPage.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 24 May 2005 17:37:45 -0000 1.220 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 7 Jun 2005 23:09:50 -0000 >@@ -2310,7 +2310,17 @@ > IEditorReference ref = null; > ref = getEditorManager().openEditor(editorID, input, true); > if (ref != null) { >- editor = ref.getEditor(true); >+ try { >+ // Special-case code. If the part throws a PartInitException >+ // during creation, we propogate the exception and remove the >+ // part rather than create an error part. For this reason, >+ // we need to call restorePart rather than getPart(), since >+ // getPart would create an error part. >+ editor = (IEditorPart) ((EditorReference)ref).restorePart(); >+ } catch (PartInitException e) { >+ closeEditor(ref, false); >+ throw e; >+ } > } > > if (editor != null) { >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java,v >retrieving revision 1.30 >diff -u -r1.30 WorkbenchPartReference.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java 7 Jun 2005 17:41:53 -0000 1.30 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java 7 Jun 2005 23:09:50 -0000 >@@ -536,10 +536,45 @@ > } > > if (part == null && restore) { >- >+ try { >+ return restorePart(); >+ } catch (PartInitException e) { >+ setPart(createErrorPart(e)); >+ } >+ } >+ >+ return part; >+ } >+ >+ private void setPart(IWorkbenchPart part2) { >+ part = part2; >+ >+ // Add a dispose listener to the part. This dispose listener does nothing but log an exception >+ // if the part's widgets get disposed unexpectedly. The workbench part reference is the only >+ // object that should dispose this control, and it will remove the listener before it does so. >+ getPane().getControl().addDisposeListener(prematureDisposeListener); >+ part.addPropertyListener(propertyChangeListener); >+ >+ refreshFromPart(); >+ releaseReferences(); >+ >+ fireInternalPropertyChange(INTERNAL_PROPERTY_OPENED); >+ } >+ >+ /** >+ * Returns the part associated with this reference, restoring it if necessary. >+ * Throws PartInitException if the part aborted its own creation by throwing >+ * a PartInitException. Returns an existing part if one >+ * already exists. >+ * >+ * @return >+ * @throws PartInitException >+ */ >+ public final IWorkbenchPart restorePart() throws PartInitException { >+ if (part == null) { > if (state == STATE_CREATION_IN_PROGRESS) { > IStatus result = WorkbenchPlugin.getStatus( >- new PartInitException(NLS.bind("Warning: Detected recursive attempt by part {0} to create itself (this is probably, but not necessarily, a bug)", //$NON-NLS-1$ >+ new PartCreationException(NLS.bind("Warning: Detected recursive attempt by part {0} to create itself (this is probably, but not necessarily, a bug)", //$NON-NLS-1$ > getId()))); > WorkbenchPlugin.log(result); > return null; >@@ -548,30 +583,25 @@ > try { > state = STATE_CREATION_IN_PROGRESS; > >- IWorkbenchPart newPart = createPart(); >- if (newPart != null) { >- part = newPart; >- // Add a dispose listener to the part. This dispose listener does nothing but log an exception >- // if the part's widgets get disposed unexpectedly. The workbench part reference is the only >- // object that should dispose this control, and it will remove the listener before it does so. >- getPane().getControl().addDisposeListener(prematureDisposeListener); >- part.addPropertyListener(propertyChangeListener); >- >- refreshFromPart(); >- releaseReferences(); >- >- fireInternalPropertyChange(INTERNAL_PROPERTY_OPENED); >+ IWorkbenchPart newPart; >+ try { >+ newPart = createPart(); >+ } catch (PartCreationException e) { >+ newPart = createErrorPart(e); > } >+ setPart(newPart); > } finally { > state = STATE_CREATED; > } >- } >+ } > > return part; > } > >- protected abstract IWorkbenchPart createPart(); >- >+ protected abstract IWorkbenchPart createPart() throws PartInitException, PartCreationException; >+ >+ protected abstract IWorkbenchPart createErrorPart(Exception toReport); >+ > protected abstract PartPane createPane(); > > /** >Index: Eclipse UI/org/eclipse/ui/internal/PartCreationException.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/PartCreationException.java >diff -N Eclipse UI/org/eclipse/ui/internal/PartCreationException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/PartCreationException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,18 @@ >+package org.eclipse.ui.internal; >+ >+public class PartCreationException extends Exception { >+ >+ /** >+ * >+ */ >+ private static final long serialVersionUID = -7574515750301940790L; >+ >+ PartCreationException(String message) { >+ super(message); >+ } >+ >+ PartCreationException(String message, Throwable cause) { >+ super(message, cause); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 90582
: 22576