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 225248 Details for
Bug 385592
Working Set "Window Working Set" not persisted across sessions
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]
Proposal for a bugfix.
Bug38559_proposal.patch (text/plain), 7.26 KB, created by
Christian Janz
on 2013-01-05 13:35:23 EST
(
hide
)
Description:
Proposal for a bugfix.
Filename:
MIME Type:
Creator:
Christian Janz
Created:
2013-01-05 13:35:23 EST
Size:
7.26 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java >index 41380c3..28ae0e5 100644 >--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java >+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java >@@ -12,6 +12,7 @@ > package org.eclipse.ui.internal; > > import java.io.IOException; >+import java.io.StringReader; > import java.io.StringWriter; > import java.util.ArrayList; > import java.util.Arrays; >@@ -27,12 +28,15 @@ > import java.util.Set; > import java.util.WeakHashMap; > import javax.annotation.PostConstruct; >+import javax.annotation.PreDestroy; > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.ListenerList; > import org.eclipse.core.runtime.SafeRunner; >+import org.eclipse.core.runtime.Status; > import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker; > import org.eclipse.e4.core.contexts.ContextInjectionFactory; > import org.eclipse.e4.core.contexts.IEclipseContext; >@@ -149,6 +153,7 @@ > import org.eclipse.ui.model.IWorkbenchAdapter; > import org.eclipse.ui.part.IShowInSource; > import org.eclipse.ui.part.ShowInContext; >+import org.eclipse.ui.statushandlers.StatusManager; > import org.eclipse.ui.views.IStickyViewDescriptor; > import org.eclipse.ui.views.IViewDescriptor; > import org.osgi.service.event.Event; >@@ -160,6 +165,8 @@ > public class WorkbenchPage extends CompatibleWorkbenchPage implements > IWorkbenchPage { > >+ private static final String ATT_AGGREGATE_WORKING_SET_ID = "aggregateWorkingSetId"; //$NON-NLS-1$ >+ > static final String SECONDARY_ID_HEADER = "3x-secondary:"; //$NON-NLS-1$ > > class E4PartListener implements org.eclipse.e4.ui.workbench.modeling.IPartListener { >@@ -2685,8 +2692,80 @@ > sortedPerspectives.add(desc); > } > } >+ >+ restoreWorkingSets(); > } > >+ public void restoreWorkingSets() { >+ String workingSetName = getWindowModel().getPersistedState().get( >+ IWorkbenchConstants.TAG_WORKING_SET); >+ if (workingSetName != null) { >+ AbstractWorkingSetManager workingSetManager = (AbstractWorkingSetManager) getWorkbenchWindow() >+ .getWorkbench().getWorkingSetManager(); >+ setWorkingSet(workingSetManager.getWorkingSet(workingSetName)); >+ } >+ >+ String workingSetMemString = getWindowModel().getPersistedState().get( >+ IWorkbenchConstants.TAG_WORKING_SETS); >+ if (workingSetMemString != null) { >+ IMemento workingSetMem; >+ try { >+ workingSetMem = XMLMemento.createReadRoot(new StringReader(workingSetMemString)); >+ IMemento[] workingSetChildren = workingSetMem >+ .getChildren(IWorkbenchConstants.TAG_WORKING_SET); >+ List workingSetList = new ArrayList(workingSetChildren.length); >+ for (int i = 0; i < workingSetChildren.length; i++) { >+ IWorkingSet set = getWorkbenchWindow().getWorkbench().getWorkingSetManager() >+ .getWorkingSet(workingSetChildren[i].getID()); >+ if (set != null) { >+ workingSetList.add(set); >+ } >+ } >+ >+ workingSets = (IWorkingSet[]) workingSetList.toArray(new IWorkingSet[workingSetList >+ .size()]); >+ } catch (WorkbenchException e) { >+ StatusManager.getManager().handle( >+ new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, >+ WorkbenchMessages.WorkbenchPage_problemRestoringTitle, e)); >+ } >+ } >+ >+ aggregateWorkingSetId = getWindowModel().getPersistedState().get( >+ ATT_AGGREGATE_WORKING_SET_ID); >+ } >+ >+ @PreDestroy >+ public void saveWorkingSets() { >+ // Save working set if set >+ if (workingSet != null) { >+ getWindowModel().getPersistedState().put(IWorkbenchConstants.TAG_WORKING_SET, >+ workingSet.getName()); >+ } else { >+ getWindowModel().getPersistedState().remove(IWorkbenchConstants.TAG_WORKING_SET); >+ } >+ >+ XMLMemento workingSetMem = XMLMemento.createWriteRoot(IWorkbenchConstants.TAG_WORKING_SETS); >+ for (int i = 0; i < workingSets.length; i++) { >+ workingSetMem >+ .createChild(IWorkbenchConstants.TAG_WORKING_SET, workingSets[i].getName()); >+ } >+ StringWriter writer = new StringWriter(); >+ try { >+ workingSetMem.save(writer); >+ getWindowModel().getPersistedState().put(IWorkbenchConstants.TAG_WORKING_SETS, >+ writer.getBuffer().toString()); >+ } catch (IOException e) { >+ // Simply don't store the settings >+ StatusManager.getManager().handle( >+ new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, >+ WorkbenchMessages.SavingProblem, e)); >+ } >+ >+ getWindowModel().getPersistedState().put(ATT_AGGREGATE_WORKING_SET_ID, >+ aggregateWorkingSetId); >+ } >+ > /** > * Extends the perspectives within the given stack with action set > * contributions from the <code>perspectiveExtensions</code> extension >diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPageTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPageTest.java >index 8c6dfeb..16b5a1a 100644 >--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPageTest.java >+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPageTest.java >@@ -263,6 +263,53 @@ > } > > /** >+ * Test if the WorkingSet related settings are persisted across sessions. >+ */ >+ public void testWorkingSetsPersisted_Bug385592() { >+ IWorkingSetManager manager = fActivePage.getWorkbenchWindow() >+ .getWorkbench().getWorkingSetManager(); >+ >+ // get initial state and save it >+ IWorkingSet[] workingSetsBeforeSave = fActivePage.getWorkingSets(); >+ String aggrWorkingSetIdBeforeSave = fActivePage >+ .getAggregateWorkingSet().getName(); >+ ((WorkbenchPage) fActivePage).saveWorkingSets(); >+ assertNotNull(workingSetsBeforeSave); >+ assertNotNull(aggrWorkingSetIdBeforeSave); >+ assertEquals(0, workingSetsBeforeSave.length); >+ >+ IWorkingSet set1 = null; >+ try { >+ set1 = manager.createWorkingSet("w1", new IAdaptable[0]); >+ manager.addWorkingSet(set1); >+ >+ // change the working sets >+ fActivePage.setWorkingSets(new IWorkingSet[] { set1 }); >+ assertNotNull(fActivePage.getWorkingSets()); >+ assertEquals(1, fActivePage.getWorkingSets().length); >+ >+ // restore the previous state >+ ((WorkbenchPage) fActivePage).restoreWorkingSets(); >+ assertEquals(aggrWorkingSetIdBeforeSave, fActivePage >+ .getAggregateWorkingSet().getName()); >+ assertNotNull(fActivePage.getWorkingSets()); >+ assertEquals(workingSetsBeforeSave.length, >+ fActivePage.getWorkingSets().length); >+ >+ // change again, save and restore the settings >+ fActivePage.setWorkingSets(new IWorkingSet[] { set1 }); >+ ((WorkbenchPage) fActivePage).saveWorkingSets(); >+ ((WorkbenchPage) fActivePage).restoreWorkingSets(); >+ assertEquals(aggrWorkingSetIdBeforeSave, fActivePage >+ .getAggregateWorkingSet().getName()); >+ assertEquals(1, fActivePage.getWorkingSets().length); >+ } finally { >+ if (set1 != null) >+ manager.removeWorkingSet(set1); >+ } >+ } >+ >+ /** > * Test the VIEW_VISIBLE parameter for showView, opening the view in the > * stack that does not contain the active view. Ensures that the created > * view is not the active part but is the top part in its stack.
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 385592
: 225248