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

(-)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 old (3.2) style
155
		node.putBoolean(IWorkbenchPreferenceConstants.ENABLE_STICKY_VIEW_CLOSE_IN_ALL, false);
153
156
154
		IEclipsePreferences rootNode = (IEclipsePreferences) Platform
157
		IEclipsePreferences rootNode = (IEclipsePreferences) Platform
155
				.getPreferencesService().getRootNode()
158
				.getPreferencesService().getRootNode()
(-)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 an alternative behavior for closing sticky views.
457
     * When 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_STICKY_VIEW_CLOSE_IN_ALL = "ENABLE_STICKY_VIEW_CLOSE_IN_ALL"; //$NON-NLS-1$
454
}
466
}
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java (-6 / +25 lines)
Lines 2219-2224 Link Here
2219
2219
2220
        // Notify interested listeners after the hide
2220
        // Notify interested listeners after the hide
2221
        window.firePerspectiveChanged(this, getPerspective(), CHANGE_VIEW_HIDE);
2221
        window.firePerspectiveChanged(this, getPerspective(), CHANGE_VIEW_HIDE);
2222
        
2223
        // Clean the sticky list, if new sticky close behavior enabled
2224
		IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
2225
        boolean closeAllStickyViews = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_STICKY_VIEW_CLOSE_IN_ALL);
2226
        if (closeAllStickyViews) {
2227
	        Set activatedStickyViewsInThisPerspective = (Set) stickyPerspectives.get(persp.getDesc().getId());
2228
			if (activatedStickyViewsInThisPerspective != null) {
2229
				activatedStickyViewsInThisPerspective.remove(ref.getId());
2230
			}
2231
        }
2222
    }
2232
    }
2223
2233
2224
    /* package */void refreshActiveView() {
2234
    /* package */void refreshActiveView() {
Lines 3386-3397 Link Here
3386
            window.updateActionSets();
3396
            window.updateActionSets();
3387
3397
3388
	        if (newPersp != null && oldPersp != null) {
3398
	        if (newPersp != null && oldPersp != null) {
3389
	        		Set activatedStickyViewsInThisPerspective = (Set) stickyPerspectives.get(newPersp.getDesc().getId());
3399
        		Set activatedStickyViewsInThisPerspective = (Set) stickyPerspectives.get(newPersp.getDesc().getId());
3390
	        		if (activatedStickyViewsInThisPerspective == null) {
3400
        		if (activatedStickyViewsInThisPerspective == null) {
3391
	        			activatedStickyViewsInThisPerspective = new HashSet(7);
3401
        			activatedStickyViewsInThisPerspective = new HashSet(7);
3392
	        			stickyPerspectives.put(newPersp.getDesc().getId(), activatedStickyViewsInThisPerspective);
3402
        			stickyPerspectives.put(newPersp.getDesc().getId(), activatedStickyViewsInThisPerspective);
3393
	        		}
3403
        		}
3394
	            
3404
        		
3405
        		// See if we should close sticky views in all perspectives
3406
        		IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
3407
                boolean closeAllStickyViews = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_STICKY_VIEW_CLOSE_IN_ALL);
3395
                IViewRegistry viewReg = WorkbenchPlugin.getDefault()
3408
                IViewRegistry viewReg = WorkbenchPlugin.getDefault()
3396
                        .getViewRegistry();
3409
                        .getViewRegistry();
3397
                IStickyViewDescriptor[] stickyDescs = viewReg.getStickyViews();
3410
                IStickyViewDescriptor[] stickyDescs = viewReg.getStickyViews();
Lines 3406-3411 Link Here
3406
									IWorkbenchPage.VIEW_CREATE);
3419
									IWorkbenchPage.VIEW_CREATE);
3407
							activatedStickyViewsInThisPerspective.add(viewId);
3420
							activatedStickyViewsInThisPerspective.add(viewId);
3408
						}
3421
						}
3422
                        // remove a view if it's sticky and its not visible in the old perspective
3423
                        else if (closeAllStickyViews && newPersp.findView(viewId) != null
3424
                        		&& oldPersp.findView(viewId) == null) {
3425
                        	hideView(newPersp.findView(viewId));
3426
                        	activatedStickyViewsInThisPerspective.remove(viewId);
3427
                        }
3409
                    } catch (PartInitException e) {
3428
                    } catch (PartInitException e) {
3410
                        WorkbenchPlugin
3429
                        WorkbenchPlugin
3411
                                .log(
3430
                                .log(
(-)Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroTest.java (+75 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_STICKY_VIEW_CLOSE_IN_ALL, "false");
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_STICKY_VIEW_CLOSE_IN_ALL, "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
    	IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
166
    	preferenceStore.putValue(IWorkbenchPreferenceConstants.ENABLE_STICKY_VIEW_CLOSE_IN_ALL, "true");
167
        
168
    	IWorkbench workbench = window.getWorkbench();
169
        IIntroPart part = workbench.getIntroManager().showIntro(window, false);
170
        assertNotNull(part);
171
        IWorkbenchPage activePage = window.getActivePage();
172
        IPerspectiveDescriptor oldDesc = activePage.getPerspective();
173
        activePage.setPerspective(WorkbenchPlugin.getDefault()
174
                .getPerspectiveRegistry().findPerspectiveWithId(
175
                        "org.eclipse.ui.tests.api.SessionPerspective"));
176
       
177
        IViewPart viewPart = window.getActivePage().findView(
178
				IIntroConstants.INTRO_VIEW_ID);
179
        assertNotNull(viewPart);
180
        
181
        window.getActivePage().hideView(viewPart);
182
        viewPart = window.getActivePage().findView(
183
				IIntroConstants.INTRO_VIEW_ID);
184
        assertNull(viewPart);
185
        
186
        activePage.setPerspective(oldDesc);
187
        viewPart = window.getActivePage().findView(
188
				IIntroConstants.INTRO_VIEW_ID);
189
        assertNull(viewPart);
190
        
191
        preferenceStore.putValue(IWorkbenchPreferenceConstants.ENABLE_STICKY_VIEW_CLOSE_IN_ALL, "false");
192
    }
118
193
119
    public void testPerspectiveReset() {
194
    public void testPerspectiveReset() {
120
        IWorkbench workbench = window.getWorkbench();
195
        IWorkbench workbench = window.getWorkbench();

Return to bug 174213