|
Lines 17-27
Link Here
|
| 17 |
import java.util.Collection; |
17 |
import java.util.Collection; |
| 18 |
import java.util.Collections; |
18 |
import java.util.Collections; |
| 19 |
import java.util.Comparator; |
19 |
import java.util.Comparator; |
| 20 |
import java.util.HashMap; |
|
|
| 21 |
import java.util.HashSet; |
20 |
import java.util.HashSet; |
| 22 |
import java.util.Iterator; |
21 |
import java.util.Iterator; |
| 23 |
import java.util.List; |
22 |
import java.util.List; |
| 24 |
import java.util.Map; |
|
|
| 25 |
import java.util.Set; |
23 |
import java.util.Set; |
| 26 |
import java.util.StringTokenizer; |
24 |
import java.util.StringTokenizer; |
| 27 |
|
25 |
|
|
Lines 109-116
Link Here
|
| 109 |
import org.eclipse.ui.model.IWorkbenchAdapter; |
107 |
import org.eclipse.ui.model.IWorkbenchAdapter; |
| 110 |
import org.eclipse.ui.part.MultiEditor; |
108 |
import org.eclipse.ui.part.MultiEditor; |
| 111 |
import org.eclipse.ui.presentations.IStackPresentationSite; |
109 |
import org.eclipse.ui.presentations.IStackPresentationSite; |
| 112 |
import org.eclipse.ui.views.IStickyViewDescriptor; |
|
|
| 113 |
import org.eclipse.ui.views.IViewRegistry; |
| 114 |
|
110 |
|
| 115 |
/** |
111 |
/** |
| 116 |
* A collection of views and editors in a workbench. |
112 |
* A collection of views and editors in a workbench. |
|
Lines 155-160
Link Here
|
| 155 |
private PerspectiveDescriptor deferredActivePersp; |
151 |
private PerspectiveDescriptor deferredActivePersp; |
| 156 |
|
152 |
|
| 157 |
private NavigationHistory navigationHistory = new NavigationHistory(this); |
153 |
private NavigationHistory navigationHistory = new NavigationHistory(this); |
|
|
154 |
|
| 155 |
private IStickyViewManager stickyViewMan = StickyViewManager.getInstance(this); |
| 158 |
|
156 |
|
| 159 |
/** |
157 |
/** |
| 160 |
* If we're in the process of activating a part, this points to the new part. |
158 |
* If we're in the process of activating a part, this points to the new part. |
|
Lines 189-198
Link Here
|
| 189 |
} |
187 |
} |
| 190 |
}; |
188 |
}; |
| 191 |
|
189 |
|
| 192 |
// a mapping of perspectives to a set of stickyviews that have been activated in that perspective. |
|
|
| 193 |
// this map is persisted across sessions |
| 194 |
private Map stickyPerspectives = new HashMap(7); |
| 195 |
|
| 196 |
private ActionSwitcher actionSwitcher = new ActionSwitcher(); |
190 |
private ActionSwitcher actionSwitcher = new ActionSwitcher(); |
| 197 |
|
191 |
|
| 198 |
private IExtensionTracker tracker; |
192 |
private IExtensionTracker tracker; |
|
Lines 1657-1663
Link Here
|
| 1657 |
|
1651 |
|
| 1658 |
navigationHistory.dispose(); |
1652 |
navigationHistory.dispose(); |
| 1659 |
|
1653 |
|
| 1660 |
stickyPerspectives.clear(); |
1654 |
stickyViewMan.clear(); |
| 1661 |
|
1655 |
|
| 1662 |
if (tracker != null) { |
1656 |
if (tracker != null) { |
| 1663 |
tracker.close(); |
1657 |
tracker.close(); |
|
Lines 1686-1692
Link Here
|
| 1686 |
} |
1680 |
} |
| 1687 |
persp.dispose(); |
1681 |
persp.dispose(); |
| 1688 |
|
1682 |
|
| 1689 |
stickyPerspectives.remove(persp.getDesc().getId()); |
1683 |
stickyViewMan.remove(persp.getDesc().getId()); |
| 1690 |
} |
1684 |
} |
| 1691 |
|
1685 |
|
| 1692 |
/** |
1686 |
/** |
|
Lines 3027-3051
Link Here
|
| 3027 |
navigationHistory.markEditor(getActiveEditor()); |
3021 |
navigationHistory.markEditor(getActiveEditor()); |
| 3028 |
} |
3022 |
} |
| 3029 |
|
3023 |
|
| 3030 |
IMemento stickyState = memento |
3024 |
// restore sticky view state |
| 3031 |
.getChild(IWorkbenchConstants.TAG_STICKY_STATE); |
3025 |
stickyViewMan.restore(memento); |
| 3032 |
// restore the sticky activation state |
3026 |
|
| 3033 |
|
|
|
| 3034 |
if (stickyState != null) { |
| 3035 |
IMemento[] stickyPerspMems = stickyState |
| 3036 |
.getChildren(IWorkbenchConstants.TAG_PERSPECTIVE); |
| 3037 |
for (int i = 0; i < stickyPerspMems.length; i++) { |
| 3038 |
String perspectiveId = stickyPerspMems[i].getID(); |
| 3039 |
Set viewState = new HashSet(7); |
| 3040 |
stickyPerspectives.put(perspectiveId, viewState); |
| 3041 |
IMemento[] viewStateMementos = stickyPerspMems[i] |
| 3042 |
.getChildren(IWorkbenchConstants.TAG_VIEW); |
| 3043 |
for (int j = 0; j < viewStateMementos.length; j++) { |
| 3044 |
viewState.add(viewStateMementos[j].getID()); |
| 3045 |
} |
| 3046 |
} |
| 3047 |
|
| 3048 |
} |
| 3049 |
return result; |
3027 |
return result; |
| 3050 |
} finally { |
3028 |
} finally { |
| 3051 |
String blame = activeDescriptor == null ? pageName : activeDescriptor.getId(); |
3029 |
String blame = activeDescriptor == null ? pageName : activeDescriptor.getId(); |
|
Lines 3207-3228
Link Here
|
| 3207 |
navigationHistory.saveState(memento |
3185 |
navigationHistory.saveState(memento |
| 3208 |
.createChild(IWorkbenchConstants.TAG_NAVIGATION_HISTORY)); |
3186 |
.createChild(IWorkbenchConstants.TAG_NAVIGATION_HISTORY)); |
| 3209 |
|
3187 |
|
| 3210 |
IMemento stickyState = memento |
3188 |
|
| 3211 |
.createChild(IWorkbenchConstants.TAG_STICKY_STATE); |
3189 |
// save the sticky activation state |
| 3212 |
// save the sticky activation state |
3190 |
stickyViewMan.save(memento); |
| 3213 |
itr = stickyPerspectives.entrySet().iterator(); |
3191 |
|
| 3214 |
while (itr.hasNext()) { |
|
|
| 3215 |
Map.Entry entry = (Map.Entry) itr.next(); |
| 3216 |
String perspectiveId = (String) entry.getKey(); |
| 3217 |
Set activatedViewIds = (Set) entry.getValue(); |
| 3218 |
IMemento perspectiveState = stickyState.createChild( |
| 3219 |
IWorkbenchConstants.TAG_PERSPECTIVE, perspectiveId); |
| 3220 |
for (Iterator i = activatedViewIds.iterator(); i.hasNext();) { |
| 3221 |
String viewId = (String) i.next(); |
| 3222 |
perspectiveState.createChild(IWorkbenchConstants.TAG_VIEW, |
| 3223 |
viewId); |
| 3224 |
} |
| 3225 |
} |
| 3226 |
return result; |
3192 |
return result; |
| 3227 |
} |
3193 |
} |
| 3228 |
|
3194 |
|
|
Lines 3385-3418
Link Here
|
| 3385 |
// Update the window |
3351 |
// Update the window |
| 3386 |
window.updateActionSets(); |
3352 |
window.updateActionSets(); |
| 3387 |
|
3353 |
|
| 3388 |
if (newPersp != null && oldPersp != null) { |
3354 |
// Update sticky views |
| 3389 |
Set activatedStickyViewsInThisPerspective = (Set) stickyPerspectives.get(newPersp.getDesc().getId()); |
3355 |
stickyViewMan.update(oldPersp, newPersp); |
| 3390 |
if (activatedStickyViewsInThisPerspective == null) { |
3356 |
|
| 3391 |
activatedStickyViewsInThisPerspective = new HashSet(7); |
|
|
| 3392 |
stickyPerspectives.put(newPersp.getDesc().getId(), activatedStickyViewsInThisPerspective); |
| 3393 |
} |
| 3394 |
|
| 3395 |
IViewRegistry viewReg = WorkbenchPlugin.getDefault() |
| 3396 |
.getViewRegistry(); |
| 3397 |
IStickyViewDescriptor[] stickyDescs = viewReg.getStickyViews(); |
| 3398 |
for (int i = 0; i < stickyDescs.length; i++) { |
| 3399 |
final String viewId = stickyDescs[i].getId(); |
| 3400 |
try { |
| 3401 |
// show a sticky view if it was in the last perspective and hasn't already been activated in this one |
| 3402 |
if (oldPersp.findView(viewId) != null |
| 3403 |
&& !activatedStickyViewsInThisPerspective |
| 3404 |
.contains(viewId)) { |
| 3405 |
showView(viewId, null, |
| 3406 |
IWorkbenchPage.VIEW_CREATE); |
| 3407 |
activatedStickyViewsInThisPerspective.add(viewId); |
| 3408 |
} |
| 3409 |
} catch (PartInitException e) { |
| 3410 |
WorkbenchPlugin |
| 3411 |
.log( |
| 3412 |
"Could not open view :" + viewId, new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, IStatus.ERROR, "Could not open view :" + viewId, e)); //$NON-NLS-1$ //$NON-NLS-2$ |
| 3413 |
} |
| 3414 |
} |
| 3415 |
} |
| 3416 |
} finally { |
3357 |
} finally { |
| 3417 |
window.largeUpdateEnd(); |
3358 |
window.largeUpdateEnd(); |
| 3418 |
if (newPersp == null) { |
3359 |
if (newPersp == null) { |