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 55588 Details for
Bug 44295
[WorkbenchParts] Workbench-Shutdown/Startup: Saving/Restoring Cursor Positions in Texteditor-Windows
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]
NewEditorAction v02
persistableEditor-v02.txt (text/plain), 9.69 KB, created by
Paul Webster
on 2006-12-13 10:04:16 EST
(
hide
)
Description:
NewEditorAction v02
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2006-12-13 10:04:16 EST
Size:
9.69 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/actions/NewEditorAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/actions/NewEditorAction.java,v >retrieving revision 1.4 >diff -u -r1.4 NewEditorAction.java >--- Eclipse UI/org/eclipse/ui/internal/actions/NewEditorAction.java 29 Nov 2005 21:36:20 -0000 1.4 >+++ Eclipse UI/org/eclipse/ui/internal/actions/NewEditorAction.java 13 Dec 2006 15:00:53 -0000 >@@ -12,11 +12,15 @@ > package org.eclipse.ui.internal.actions; > > import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IPersistableEditor; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.XMLMemento; > import org.eclipse.ui.internal.ActiveEditorAction; >+import org.eclipse.ui.internal.IWorkbenchConstants; > import org.eclipse.ui.internal.WorkbenchMessages; >+import org.eclipse.ui.internal.WorkbenchPage; > import org.eclipse.ui.internal.dialogs.DialogUtil; > > /** >@@ -52,8 +56,17 @@ > return; > } > try { >- page.openEditor(editor.getEditorInput(), editorId, true, IWorkbenchPage.MATCH_NONE); >- } catch (PartInitException e) { >+ if (editor instanceof IPersistableEditor) { >+ XMLMemento editorState = XMLMemento >+ .createWriteRoot(IWorkbenchConstants.TAG_EDITOR_STATE); >+ ((IPersistableEditor) editor).saveState(editorState); >+ ((WorkbenchPage) page).openEditor(editor.getEditorInput(), >+ editorId, true, IWorkbenchPage.MATCH_NONE, editorState); >+ } else { >+ page.openEditor(editor.getEditorInput(), editorId, true, >+ IWorkbenchPage.MATCH_NONE); >+ } >+ } catch (PartInitException e) { > DialogUtil.openError(page.getWorkbenchWindow().getShell(), > WorkbenchMessages.Error, > e.getMessage(), e); >Index: Eclipse UI/org/eclipse/ui/internal/EditorManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorManager.java,v >retrieving revision 1.117 >diff -u -r1.117 EditorManager.java >--- Eclipse UI/org/eclipse/ui/internal/EditorManager.java 13 Dec 2006 14:55:58 -0000 1.117 >+++ Eclipse UI/org/eclipse/ui/internal/EditorManager.java 13 Dec 2006 15:00:53 -0000 >@@ -665,6 +665,24 @@ > */ > public IEditorReference openEditor(String editorId, IEditorInput input, > boolean setVisible) throws PartInitException { >+ return openEditor(editorId, input, setVisible, null); >+ } >+ >+ /** >+ * @param editorId >+ * the editor part id >+ * @param input >+ * the input >+ * @param setVisible >+ * if this is to be created visible ... not used >+ * @param editorState >+ * an {@link IMemento} <editorState> for persistable >+ * editors. Can be <code>null</code>. >+ * @return a created editor reference >+ * @throws PartInitException >+ */ >+ public IEditorReference openEditor(String editorId, IEditorInput input, >+ boolean setVisible, IMemento editorState) throws PartInitException { > if (editorId == null || input == null) { > throw new IllegalArgumentException(); > } >@@ -677,7 +695,7 @@ > editorId)); > } > >- IEditorReference result = openEditorFromDescriptor(desc, input); >+ IEditorReference result = openEditorFromDescriptor(desc, input, editorState); > return result; > } > >@@ -685,12 +703,12 @@ > * Open a new editor > */ > private IEditorReference openEditorFromDescriptor(EditorDescriptor desc, >- IEditorInput input) throws PartInitException { >+ IEditorInput input, IMemento editorState) throws PartInitException { > IEditorReference result = null; > if (desc.isInternal()) { > result = reuseInternalEditor(desc, input); > if (result == null) { >- result = new EditorReference(this, input, desc); >+ result = new EditorReference(this, input, desc, editorState); > } > } else if (desc.getId() > .equals(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID)) { >Index: Eclipse UI/org/eclipse/ui/internal/EditorReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorReference.java,v >retrieving revision 1.18 >diff -u -r1.18 EditorReference.java >--- Eclipse UI/org/eclipse/ui/internal/EditorReference.java 13 Dec 2006 14:55:58 -0000 1.18 >+++ Eclipse UI/org/eclipse/ui/internal/EditorReference.java 13 Dec 2006 15:00:53 -0000 >@@ -57,7 +57,7 @@ > > private IMemento editorMemento; > >- private IMemento editorState; >+ private IMemento editorState = null; > > /** > * Flag that lets us detect malfunctioning editors that don't fire PROP_INPUT events. >@@ -90,16 +90,43 @@ > private IEditorReference[] multiEditorChildren = null; > > >- public EditorReference(EditorManager manager, IEditorInput input, EditorDescriptor desc) { >- this.manager = manager; >- initListenersAndHandlers(); >- restoredInput = input; >- init(desc.getId(), desc.getLabel(), "", desc.getImageDescriptor(), desc.getLabel(), ""); //$NON-NLS-1$//$NON-NLS-2$ >- } >+ /** >+ * @param manager >+ * The editor manager for this reference >+ * @param input >+ * our input >+ * @param desc >+ * the descriptor from the declaration >+ */ >+ public EditorReference(EditorManager manager, IEditorInput input, >+ EditorDescriptor desc) { >+ this(manager, input, desc, null); >+ } > > /** >- * Constructs a new editor reference for use by editors being restored from a memento. >- */ >+ * @param manager >+ * The editor manager for this reference >+ * @param input >+ * our input >+ * @param desc >+ * the descriptor from the declaration >+ * @param editorState >+ * propogate state from another editor. Can be <code>null</code>. >+ */ >+ public EditorReference(EditorManager manager, IEditorInput input, >+ EditorDescriptor desc, IMemento editorState) { >+ this.manager = manager; >+ initListenersAndHandlers(); >+ restoredInput = input; >+ this.editorState = editorState; >+ init(desc.getId(), desc.getLabel(), >+ "", desc.getImageDescriptor(), desc.getLabel(), ""); //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ >+ /** >+ * Constructs a new editor reference for use by editors being restored from >+ * a memento. >+ */ > EditorReference(EditorManager manager, IMemento memento) { > this.manager = manager; > initListenersAndHandlers(); >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java,v >retrieving revision 1.273 >diff -u -r1.273 WorkbenchPage.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 24 Nov 2006 16:41:35 -0000 1.273 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 13 Dec 2006 15:00:53 -0000 >@@ -2467,6 +2467,16 @@ > public IEditorPart openEditor(final IEditorInput input, > final String editorID, final boolean activate, final int matchFlags) > throws PartInitException { >+ return openEditor(input, editorID, activate, matchFlags, null); >+ } >+ >+ /** >+ * This is not public API but for use internally. editorState can be <code>null</code>. >+ */ >+ public IEditorPart openEditor(final IEditorInput input, >+ final String editorID, final boolean activate, final int matchFlags, >+ final IMemento editorState) >+ throws PartInitException { > if (input == null || editorID == null) { > throw new IllegalArgumentException(); > } >@@ -2478,7 +2488,7 @@ > public void run() { > try { > result[0] = busyOpenEditor(input, editorID, >- activate, matchFlags); >+ activate, matchFlags, editorState); > } catch (PartInitException e) { > ex[0] = e; > } >@@ -2494,14 +2504,14 @@ > * @see #openEditor(IEditorInput, String, boolean, int) > */ > private IEditorPart busyOpenEditor(IEditorInput input, String editorID, >- boolean activate, int matchFlags) throws PartInitException { >+ boolean activate, int matchFlags, IMemento editorState) throws PartInitException { > > final Workbench workbench = (Workbench) getWorkbenchWindow() > .getWorkbench(); > workbench.largeUpdateStart(); > > try { >- return busyOpenEditorBatched(input, editorID, activate, matchFlags); >+ return busyOpenEditorBatched(input, editorID, activate, matchFlags, editorState); > > } finally { > workbench.largeUpdateEnd(); >@@ -2514,7 +2524,7 @@ > * @see IWorkbenchPage#openEditor(IEditorInput, String, boolean) > */ > private IEditorPart busyOpenEditorBatched(IEditorInput input, >- String editorID, boolean activate, int matchFlags) throws PartInitException { >+ String editorID, boolean activate, int matchFlags, IMemento editorState) throws PartInitException { > > // If an editor already exists for the input, use it. > IEditorPart editor = getEditorManager().findEditor(editorID, input, matchFlags); >@@ -2566,7 +2576,7 @@ > // Otherwise, create a new one. This may cause the new editor to > // become the visible (i.e top) editor. > IEditorReference ref = null; >- ref = getEditorManager().openEditor(editorID, input, true); >+ ref = getEditorManager().openEditor(editorID, input, true, editorState); > if (ref != null) { > editor = ref.getEditor(true); > }
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 44295
:
53564
|
53629
| 55588 |
62948