|
Lines 12-17
Link Here
|
| 12 |
package org.eclipse.ui.internal; |
12 |
package org.eclipse.ui.internal; |
| 13 |
|
13 |
|
| 14 |
import java.io.IOException; |
14 |
import java.io.IOException; |
|
|
15 |
import java.io.StringReader; |
| 15 |
import java.io.StringWriter; |
16 |
import java.io.StringWriter; |
| 16 |
import java.util.ArrayList; |
17 |
import java.util.ArrayList; |
| 17 |
import java.util.Arrays; |
18 |
import java.util.Arrays; |
|
Lines 27-38
Link Here
|
| 27 |
import java.util.Set; |
28 |
import java.util.Set; |
| 28 |
import java.util.WeakHashMap; |
29 |
import java.util.WeakHashMap; |
| 29 |
import javax.annotation.PostConstruct; |
30 |
import javax.annotation.PostConstruct; |
|
|
31 |
import javax.annotation.PreDestroy; |
| 30 |
import org.eclipse.core.runtime.Assert; |
32 |
import org.eclipse.core.runtime.Assert; |
| 31 |
import org.eclipse.core.runtime.CoreException; |
33 |
import org.eclipse.core.runtime.CoreException; |
| 32 |
import org.eclipse.core.runtime.IAdaptable; |
34 |
import org.eclipse.core.runtime.IAdaptable; |
| 33 |
import org.eclipse.core.runtime.IConfigurationElement; |
35 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
|
36 |
import org.eclipse.core.runtime.IStatus; |
| 34 |
import org.eclipse.core.runtime.ListenerList; |
37 |
import org.eclipse.core.runtime.ListenerList; |
| 35 |
import org.eclipse.core.runtime.SafeRunner; |
38 |
import org.eclipse.core.runtime.SafeRunner; |
|
|
39 |
import org.eclipse.core.runtime.Status; |
| 36 |
import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker; |
40 |
import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker; |
| 37 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
41 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
| 38 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
42 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
|
Lines 149-154
Link Here
|
| 149 |
import org.eclipse.ui.model.IWorkbenchAdapter; |
153 |
import org.eclipse.ui.model.IWorkbenchAdapter; |
| 150 |
import org.eclipse.ui.part.IShowInSource; |
154 |
import org.eclipse.ui.part.IShowInSource; |
| 151 |
import org.eclipse.ui.part.ShowInContext; |
155 |
import org.eclipse.ui.part.ShowInContext; |
|
|
156 |
import org.eclipse.ui.statushandlers.StatusManager; |
| 152 |
import org.eclipse.ui.views.IStickyViewDescriptor; |
157 |
import org.eclipse.ui.views.IStickyViewDescriptor; |
| 153 |
import org.eclipse.ui.views.IViewDescriptor; |
158 |
import org.eclipse.ui.views.IViewDescriptor; |
| 154 |
import org.osgi.service.event.Event; |
159 |
import org.osgi.service.event.Event; |
|
Lines 160-165
Link Here
|
| 160 |
public class WorkbenchPage extends CompatibleWorkbenchPage implements |
165 |
public class WorkbenchPage extends CompatibleWorkbenchPage implements |
| 161 |
IWorkbenchPage { |
166 |
IWorkbenchPage { |
| 162 |
|
167 |
|
|
|
168 |
private static final String ATT_AGGREGATE_WORKING_SET_ID = "aggregateWorkingSetId"; //$NON-NLS-1$ |
| 169 |
|
| 163 |
static final String SECONDARY_ID_HEADER = "3x-secondary:"; //$NON-NLS-1$ |
170 |
static final String SECONDARY_ID_HEADER = "3x-secondary:"; //$NON-NLS-1$ |
| 164 |
|
171 |
|
| 165 |
class E4PartListener implements org.eclipse.e4.ui.workbench.modeling.IPartListener { |
172 |
class E4PartListener implements org.eclipse.e4.ui.workbench.modeling.IPartListener { |
|
Lines 2685-2692
Link Here
|
| 2685 |
sortedPerspectives.add(desc); |
2692 |
sortedPerspectives.add(desc); |
| 2686 |
} |
2693 |
} |
| 2687 |
} |
2694 |
} |
|
|
2695 |
|
| 2696 |
restoreWorkingSets(); |
| 2688 |
} |
2697 |
} |
| 2689 |
|
2698 |
|
|
|
2699 |
public void restoreWorkingSets() { |
| 2700 |
String workingSetName = getWindowModel().getPersistedState().get( |
| 2701 |
IWorkbenchConstants.TAG_WORKING_SET); |
| 2702 |
if (workingSetName != null) { |
| 2703 |
AbstractWorkingSetManager workingSetManager = (AbstractWorkingSetManager) getWorkbenchWindow() |
| 2704 |
.getWorkbench().getWorkingSetManager(); |
| 2705 |
setWorkingSet(workingSetManager.getWorkingSet(workingSetName)); |
| 2706 |
} |
| 2707 |
|
| 2708 |
String workingSetMemString = getWindowModel().getPersistedState().get( |
| 2709 |
IWorkbenchConstants.TAG_WORKING_SETS); |
| 2710 |
if (workingSetMemString != null) { |
| 2711 |
IMemento workingSetMem; |
| 2712 |
try { |
| 2713 |
workingSetMem = XMLMemento.createReadRoot(new StringReader(workingSetMemString)); |
| 2714 |
IMemento[] workingSetChildren = workingSetMem |
| 2715 |
.getChildren(IWorkbenchConstants.TAG_WORKING_SET); |
| 2716 |
List workingSetList = new ArrayList(workingSetChildren.length); |
| 2717 |
for (int i = 0; i < workingSetChildren.length; i++) { |
| 2718 |
IWorkingSet set = getWorkbenchWindow().getWorkbench().getWorkingSetManager() |
| 2719 |
.getWorkingSet(workingSetChildren[i].getID()); |
| 2720 |
if (set != null) { |
| 2721 |
workingSetList.add(set); |
| 2722 |
} |
| 2723 |
} |
| 2724 |
|
| 2725 |
workingSets = (IWorkingSet[]) workingSetList.toArray(new IWorkingSet[workingSetList |
| 2726 |
.size()]); |
| 2727 |
} catch (WorkbenchException e) { |
| 2728 |
StatusManager.getManager().handle( |
| 2729 |
new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, |
| 2730 |
WorkbenchMessages.WorkbenchPage_problemRestoringTitle, e)); |
| 2731 |
} |
| 2732 |
} |
| 2733 |
|
| 2734 |
aggregateWorkingSetId = getWindowModel().getPersistedState().get( |
| 2735 |
ATT_AGGREGATE_WORKING_SET_ID); |
| 2736 |
} |
| 2737 |
|
| 2738 |
@PreDestroy |
| 2739 |
public void saveWorkingSets() { |
| 2740 |
// Save working set if set |
| 2741 |
if (workingSet != null) { |
| 2742 |
getWindowModel().getPersistedState().put(IWorkbenchConstants.TAG_WORKING_SET, |
| 2743 |
workingSet.getName()); |
| 2744 |
} else { |
| 2745 |
getWindowModel().getPersistedState().remove(IWorkbenchConstants.TAG_WORKING_SET); |
| 2746 |
} |
| 2747 |
|
| 2748 |
XMLMemento workingSetMem = XMLMemento.createWriteRoot(IWorkbenchConstants.TAG_WORKING_SETS); |
| 2749 |
for (int i = 0; i < workingSets.length; i++) { |
| 2750 |
workingSetMem |
| 2751 |
.createChild(IWorkbenchConstants.TAG_WORKING_SET, workingSets[i].getName()); |
| 2752 |
} |
| 2753 |
StringWriter writer = new StringWriter(); |
| 2754 |
try { |
| 2755 |
workingSetMem.save(writer); |
| 2756 |
getWindowModel().getPersistedState().put(IWorkbenchConstants.TAG_WORKING_SETS, |
| 2757 |
writer.getBuffer().toString()); |
| 2758 |
} catch (IOException e) { |
| 2759 |
// Simply don't store the settings |
| 2760 |
StatusManager.getManager().handle( |
| 2761 |
new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, |
| 2762 |
WorkbenchMessages.SavingProblem, e)); |
| 2763 |
} |
| 2764 |
|
| 2765 |
getWindowModel().getPersistedState().put(ATT_AGGREGATE_WORKING_SET_ID, |
| 2766 |
aggregateWorkingSetId); |
| 2767 |
} |
| 2768 |
|
| 2690 |
/** |
2769 |
/** |
| 2691 |
* Extends the perspectives within the given stack with action set |
2770 |
* Extends the perspectives within the given stack with action set |
| 2692 |
* contributions from the <code>perspectiveExtensions</code> extension |
2771 |
* contributions from the <code>perspectiveExtensions</code> extension |