Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 174213 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/IWorkbenchPreferenceConstants.java (+12 lines)
Lines 451-454 Link Here
451
	 * @since 3.3
451
	 * @since 3.3
452
	 */
452
	 */
453
	public static final String DISABLE_NEW_FAST_VIEW = "disableNewFastView"; //$NON-NLS-1$
453
	public static final String DISABLE_NEW_FAST_VIEW = "disableNewFastView"; //$NON-NLS-1$
454
	
455
	/**
456
     * A named preference for enabling the 3.2 behavior for closing sticky views.
457
     * When not enabled a sticky view is closed in all perspectives when the view is closed.
458
     * <p>
459
     * The default value for this preference is: <code>false</code>; use the 3.2
460
     * behaviour.
461
     * </p>
462
     * 
463
     * @since 3.3
464
     */
465
	public static final String ENABLE_32_STICKY_CLOSE_BEHAVIOR = "ENABLE_32_STICKY_CLOSE_BEHAVIOR"; //$NON-NLS-1$
454
}
466
}
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java (-73 / +14 lines)
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) {
(-)Eclipse (+130 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.internal;
13
14
import java.util.Set;
15
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Status;
18
import org.eclipse.jface.preference.IPreferenceStore;
19
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IWorkbenchPage;
21
import org.eclipse.ui.IWorkbenchPreferenceConstants;
22
import org.eclipse.ui.PartInitException;
23
import org.eclipse.ui.internal.util.PrefUtil;
24
import org.eclipse.ui.views.IStickyViewDescriptor;
25
import org.eclipse.ui.views.IViewRegistry;
26
27
/**
28
 * @since 3.3
29
 * 
30
 */
31
public class StickyViewManager implements IStickyViewManager {
32
	
33
	private IWorkbenchPage page;
34
	
35
	public StickyViewManager(IWorkbenchPage page) {
36
		this.page = page;
37
	}
38
39
	
40
	public static IStickyViewManager getInstance(IWorkbenchPage page) {
41
		IStickyViewManager stickyViewMan;
42
		IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
43
		boolean enable32Behavior = preferenceStore
44
				.getBoolean(IWorkbenchPreferenceConstants.ENABLE_32_STICKY_CLOSE_BEHAVIOR);
45
		if (enable32Behavior)
46
			stickyViewMan = new StickyViewManager32(page);
47
		else 
48
			stickyViewMan = new StickyViewManager(page);
49
		
50
		return stickyViewMan;
51
	}
52
	
53
	/*
54
	 * (non-Javadoc)
55
	 * 
56
	 * @see org.eclipse.ui.internal.IStickyViewManager#add(java.lang.String,
57
	 *      java.util.Set)
58
	 */
59
	public void add(String perspectiveId, Set stickyViewSet) {
60
		// do nothing
61
	}
62
63
	/*
64
	 * (non-Javadoc)
65
	 * 
66
	 * @see org.eclipse.ui.internal.IStickyViewManager#clear()
67
	 */
68
	public void clear() {
69
		// do nothing
70
	}
71
72
	/*
73
	 * (non-Javadoc)
74
	 * 
75
	 * @see org.eclipse.ui.internal.IStickyViewManager#remove(java.lang.String)
76
	 */
77
	public void remove(String perspectiveId) {
78
		// do nothing
79
	}
80
81
	/*
82
	 * (non-Javadoc)
83
	 * 
84
	 * @see org.eclipse.ui.internal.IStickyViewManager#restore(org.eclipse.ui.IMemento)
85
	 */
86
	public void restore(IMemento memento) {
87
		// do nothing
88
	}
89
90
	/*
91
	 * (non-Javadoc)
92
	 * 
93
	 * @see org.eclipse.ui.internal.IStickyViewManager#save(org.eclipse.ui.IMemento)
94
	 */
95
	public void save(IMemento memento) {
96
		// do nothing
97
	}
98
99
	/*
100
	 * (non-Javadoc)
101
	 * 
102
	 * @see org.eclipse.ui.internal.IStickyViewManager#update(org.eclipse.ui.internal.Perspective,
103
	 *      org.eclipse.ui.internal.Perspective)
104
	 */
105
	public void update(Perspective oldPersp, Perspective newPersp) {
106
		IViewRegistry viewReg = WorkbenchPlugin.getDefault().getViewRegistry();
107
		IStickyViewDescriptor[] stickyDescs = viewReg.getStickyViews();
108
		for (int i = 0; i < stickyDescs.length; i++) {
109
			final String viewId = stickyDescs[i].getId();
110
			try {
111
				// show a sticky view if it was in the last perspective and
112
				// hasn't already been activated in this one
113
				if (oldPersp.findView(viewId) != null) {
114
					page.showView(viewId, null, IWorkbenchPage.VIEW_CREATE);
115
				}
116
				// remove a view if it's sticky and its not visible in the old
117
				// perspective
118
				else if (newPersp.findView(viewId) != null
119
						&& oldPersp.findView(viewId) == null) {
120
					page.hideView(newPersp.findView(viewId));
121
				}
122
			} catch (PartInitException e) {
123
				WorkbenchPlugin
124
						.log(
125
								"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$
126
			}
127
		}
128
	}
129
130
}
(-)Eclipse (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.internal;
13
14
import java.util.Set;
15
16
import org.eclipse.ui.IMemento;
17
18
/**
19
 * @since 3.3
20
 *
21
 */
22
interface IStickyViewManager {
23
	
24
	void remove(String perspectiveId);
25
	
26
	void add(String perspectiveId, Set stickyViewSet);
27
	
28
	void clear();
29
	
30
	void update(Perspective oldPersp, Perspective newPersp);
31
	
32
	void save(IMemento memento);
33
	 
34
	void restore(IMemento memento);
35
36
}
(-)Eclipse (+142 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.internal;
13
14
import java.util.HashMap;
15
import java.util.HashSet;
16
import java.util.Iterator;
17
import java.util.Map;
18
import java.util.Set;
19
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.Status;
22
import org.eclipse.ui.IMemento;
23
import org.eclipse.ui.IWorkbenchPage;
24
import org.eclipse.ui.PartInitException;
25
import org.eclipse.ui.views.IStickyViewDescriptor;
26
import org.eclipse.ui.views.IViewRegistry;
27
28
/**
29
 * @since 3.3
30
 *
31
 */
32
class StickyViewManager32 implements IStickyViewManager {
33
34
	// a mapping of perspectives to a set of stickyviews that have been activated in that perspective.
35
	// this map is persisted across sessions
36
	private Map stickyPerspectives = new HashMap(7);
37
	
38
	private IWorkbenchPage page;
39
	
40
	public StickyViewManager32(IWorkbenchPage page) {
41
		this.page = page;
42
	}
43
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.ui.internal.IStickyViewManager#remove(java.lang.String)
46
	 */
47
	public void remove(String pespectiveId) {
48
		stickyPerspectives.remove(pespectiveId);
49
	}
50
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.ui.internal.IStickyViewManager#add(java.lang.String, java.util.Set)
53
	 */
54
	public void add(String pespectiveId, Set stickyViewList) {
55
		stickyPerspectives.put(pespectiveId, stickyViewList);
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.ui.internal.IStickyViewManager#clear()
60
	 */
61
	public void clear() {
62
		stickyPerspectives.clear();
63
	}
64
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.ui.internal.IStickyViewManager#update(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.internal.Perspective, org.eclipse.ui.internal.Perspective)
67
	 */
68
	public void update(Perspective oldPersp, Perspective newPersp) {
69
		if (newPersp != null && oldPersp != null) {
70
			Set activatedStickyViewsInThisPerspective = (Set) stickyPerspectives
71
					.get(newPersp.getDesc().getId());
72
			if (activatedStickyViewsInThisPerspective == null) {
73
				activatedStickyViewsInThisPerspective = new HashSet(7);
74
				stickyPerspectives.put(newPersp.getDesc().getId(),
75
						activatedStickyViewsInThisPerspective);
76
			}
77
			IViewRegistry viewReg = WorkbenchPlugin.getDefault()
78
					.getViewRegistry();
79
			IStickyViewDescriptor[] stickyDescs = viewReg.getStickyViews();
80
			for (int i = 0; i < stickyDescs.length; i++) {
81
				final String viewId = stickyDescs[i].getId();
82
				try {
83
					// show a sticky view if it was in the last perspective and hasn't already been activated in this one
84
					if (oldPersp.findView(viewId) != null
85
							&& !activatedStickyViewsInThisPerspective
86
									.contains(viewId)) {
87
						page.showView(viewId, null, IWorkbenchPage.VIEW_CREATE);
88
						activatedStickyViewsInThisPerspective.add(viewId);
89
					}
90
				} catch (PartInitException e) {
91
					WorkbenchPlugin
92
							.log(
93
									"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$
94
				}
95
			}
96
		}
97
	}
98
	
99
	/* (non-Javadoc)
100
	 * @see org.eclipse.ui.internal.IStickyViewManager#save(org.eclipse.ui.IMemento)
101
	 */
102
	public void save(IMemento memento) {
103
		IMemento stickyState = memento.createChild(IWorkbenchConstants.TAG_STICKY_STATE);
104
		Iterator itr = stickyPerspectives.entrySet().iterator();
105
		while (itr.hasNext()) {
106
			Map.Entry entry = (Map.Entry) itr.next();
107
			String perspectiveId = (String) entry.getKey();
108
			Set activatedViewIds = (Set) entry.getValue();
109
			IMemento perspectiveState = stickyState.createChild(
110
					IWorkbenchConstants.TAG_PERSPECTIVE, perspectiveId);
111
			for (Iterator i = activatedViewIds.iterator(); i.hasNext();) {
112
				String viewId = (String) i.next();
113
				perspectiveState.createChild(IWorkbenchConstants.TAG_VIEW,
114
						viewId);
115
			}
116
		}
117
	}
118
119
	/* (non-Javadoc)
120
	 * @see org.eclipse.ui.internal.IStickyViewManager#restore(org.eclipse.ui.IMemento)
121
	 */
122
	public void restore(IMemento memento) {
123
		// restore the sticky activation state
124
		IMemento stickyState = memento
125
				.getChild(IWorkbenchConstants.TAG_STICKY_STATE);
126
127
		if (stickyState != null) {
128
			IMemento[] stickyPerspMems = stickyState
129
					.getChildren(IWorkbenchConstants.TAG_PERSPECTIVE);
130
			for (int i = 0; i < stickyPerspMems.length; i++) {
131
				String perspectiveId = stickyPerspMems[i].getID();
132
				Set viewState = new HashSet(7);
133
				stickyPerspectives.put(perspectiveId, viewState);
134
				IMemento[] viewStateMementos = stickyPerspMems[i]
135
						.getChildren(IWorkbenchConstants.TAG_VIEW);
136
				for (int j = 0; j < viewStateMementos.length; j++) {
137
					viewState.add(viewStateMementos[j].getID());
138
				}
139
			}
140
		}
141
	}
142
}
(-)src/org/eclipse/ui/internal/UIPreferenceInitializer.java (+3 lines)
Lines 150-155 Link Here
150
		
150
		
151
		// By default the Fast View Bar allows to select a new fast view from the view list
151
		// By default the Fast View Bar allows to select a new fast view from the view list
152
		node.putBoolean(IWorkbenchPreferenceConstants.DISABLE_NEW_FAST_VIEW, false);
152
		node.putBoolean(IWorkbenchPreferenceConstants.DISABLE_NEW_FAST_VIEW, false);
153
		
154
		// Default the sticky view close behaviour to the new style
155
		node.putBoolean(IWorkbenchPreferenceConstants.ENABLE_32_STICKY_CLOSE_BEHAVIOR, false);
153
156
154
		IEclipsePreferences rootNode = (IEclipsePreferences) Platform
157
		IEclipsePreferences rootNode = (IEclipsePreferences) Platform
155
				.getPreferencesService().getRootNode()
158
				.getPreferencesService().getRootNode()
(-)Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroTest.java (+71 lines)
Lines 10-25 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.intro;
11
package org.eclipse.ui.tests.intro;
12
12
13
import org.eclipse.jface.preference.IPreferenceStore;
13
import org.eclipse.ui.IPerspectiveDescriptor;
14
import org.eclipse.ui.IPerspectiveDescriptor;
14
import org.eclipse.ui.IViewPart;
15
import org.eclipse.ui.IViewPart;
15
import org.eclipse.ui.IWorkbench;
16
import org.eclipse.ui.IWorkbench;
16
import org.eclipse.ui.IWorkbenchPage;
17
import org.eclipse.ui.IWorkbenchPage;
18
import org.eclipse.ui.IWorkbenchPreferenceConstants;
17
import org.eclipse.ui.IWorkbenchWindow;
19
import org.eclipse.ui.IWorkbenchWindow;
18
import org.eclipse.ui.internal.Workbench;
20
import org.eclipse.ui.internal.Workbench;
19
import org.eclipse.ui.internal.WorkbenchPlugin;
21
import org.eclipse.ui.internal.WorkbenchPlugin;
20
import org.eclipse.ui.internal.WorkbenchWindow;
22
import org.eclipse.ui.internal.WorkbenchWindow;
21
import org.eclipse.ui.internal.intro.IIntroConstants;
23
import org.eclipse.ui.internal.intro.IIntroConstants;
22
import org.eclipse.ui.internal.intro.IntroDescriptor;
24
import org.eclipse.ui.internal.intro.IntroDescriptor;
25
import org.eclipse.ui.internal.util.PrefUtil;
23
import org.eclipse.ui.intro.IIntroManager;
26
import org.eclipse.ui.intro.IIntroManager;
24
import org.eclipse.ui.intro.IIntroPart;
27
import org.eclipse.ui.intro.IIntroPart;
25
import org.eclipse.ui.tests.api.PerspectiveWithFastView;
28
import org.eclipse.ui.tests.api.PerspectiveWithFastView;
Lines 115-120 Link Here
115
        assertTrue(workbench.getIntroManager().closeIntro(part));
118
        assertTrue(workbench.getIntroManager().closeIntro(part));
116
        assertNull(workbench.getIntroManager().getIntro());
119
        assertNull(workbench.getIntroManager().getIntro());
117
    }
120
    }
121
    
122
    /**
123
     * Open the intro, change perspective, close the intro 
124
     * and ensure that the intro has not been closed in the 
125
     * other perspective.
126
     * See bug 174213
127
     */
128
    public void testPerspectiveChangeWithCloseAllPrefFalse() {
129
    	IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
130
    	preferenceStore.putValue(IWorkbenchPreferenceConstants.ENABLE_32_STICKY_CLOSE_BEHAVIOR, "true");
131
        
132
    	IWorkbench workbench = window.getWorkbench();
133
        IIntroPart part = workbench.getIntroManager().showIntro(window, false);
134
        assertNotNull(part);
135
        IWorkbenchPage activePage = window.getActivePage();
136
        IPerspectiveDescriptor oldDesc = activePage.getPerspective();
137
        activePage.setPerspective(WorkbenchPlugin.getDefault()
138
                .getPerspectiveRegistry().findPerspectiveWithId(
139
                        "org.eclipse.ui.tests.api.SessionPerspective"));
140
       
141
        IViewPart viewPart = window.getActivePage().findView(
142
				IIntroConstants.INTRO_VIEW_ID);
143
        assertNotNull(viewPart);
144
        
145
        window.getActivePage().hideView(viewPart);
146
        viewPart = window.getActivePage().findView(
147
				IIntroConstants.INTRO_VIEW_ID);
148
        assertNull(viewPart);
149
        
150
        activePage.setPerspective(oldDesc);
151
        viewPart = window.getActivePage().findView(
152
				IIntroConstants.INTRO_VIEW_ID);
153
        assertNotNull(viewPart);
154
        
155
        preferenceStore.putValue(IWorkbenchPreferenceConstants.ENABLE_32_STICKY_CLOSE_BEHAVIOR, "false");
156
    }
157
    
158
    /**
159
     * Open the intro, change perspective, close the intro 
160
     * and ensure that the intro has been closed in the 
161
     * other perspective.
162
     * See bug 174213
163
     */
164
    public void testPerspectiveChangeWithCloseAllPrefTrue() {
165
    	IWorkbench workbench = window.getWorkbench();
166
        IIntroPart part = workbench.getIntroManager().showIntro(window, false);
167
        assertNotNull(part);
168
        IWorkbenchPage activePage = window.getActivePage();
169
        IPerspectiveDescriptor oldDesc = activePage.getPerspective();
170
        activePage.setPerspective(WorkbenchPlugin.getDefault()
171
                .getPerspectiveRegistry().findPerspectiveWithId(
172
                        "org.eclipse.ui.tests.api.SessionPerspective"));
173
       
174
        IViewPart viewPart = window.getActivePage().findView(
175
				IIntroConstants.INTRO_VIEW_ID);
176
        assertNotNull(viewPart);
177
        
178
        window.getActivePage().hideView(viewPart);
179
        viewPart = window.getActivePage().findView(
180
				IIntroConstants.INTRO_VIEW_ID);
181
        assertNull(viewPart);
182
        
183
        activePage.setPerspective(oldDesc);
184
        viewPart = window.getActivePage().findView(
185
				IIntroConstants.INTRO_VIEW_ID);
186
        assertNull(viewPart);
187
        
188
    }
118
189
119
    public void testPerspectiveReset() {
190
    public void testPerspectiveReset() {
120
        IWorkbench workbench = window.getWorkbench();
191
        IWorkbench workbench = window.getWorkbench();

Return to bug 174213