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 153957 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/messages.properties (+1 lines)
Lines 564-569 Link Here
564
StandardSystemToolbar_Maximize = Maximize
564
StandardSystemToolbar_Maximize = Maximize
565
StandardSystemToolbar_Restore = Restore
565
StandardSystemToolbar_Restore = Restore
566
566
567
ViewPane_moveToTrim = &Move to Trim
567
ViewPane_fastView = &Fast View
568
ViewPane_fastView = &Fast View
568
ViewPane_minimizeView= Mi&nimize
569
ViewPane_minimizeView= Mi&nimize
569
ViewPane_moveView=&View
570
ViewPane_moveView=&View
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java (+1 lines)
Lines 568-573 Link Here
568
	public static String StandardSystemToolbar_Maximize;
568
	public static String StandardSystemToolbar_Maximize;
569
	public static String StandardSystemToolbar_Restore;
569
	public static String StandardSystemToolbar_Restore;
570
570
571
	public static String ViewPane_moveToTrim;
571
	public static String ViewPane_fastView;
572
	public static String ViewPane_fastView;
572
	public static String ViewPane_minimizeView;
573
	public static String ViewPane_minimizeView;
573
	public static String ViewPane_moveView;
574
	public static String ViewPane_moveView;
(-)Eclipse UI/org/eclipse/ui/internal/ViewStack.java (+6 lines)
Lines 17-22 Link Here
17
import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
17
import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
18
import org.eclipse.ui.internal.presentations.SystemMenuDetach;
18
import org.eclipse.ui.internal.presentations.SystemMenuDetach;
19
import org.eclipse.ui.internal.presentations.SystemMenuFastView;
19
import org.eclipse.ui.internal.presentations.SystemMenuFastView;
20
import org.eclipse.ui.internal.presentations.SystemMenuMoveToTrim;
20
import org.eclipse.ui.internal.presentations.SystemMenuSize;
21
import org.eclipse.ui.internal.presentations.SystemMenuSize;
21
import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
22
import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
22
import org.eclipse.ui.presentations.AbstractPresentationFactory;
23
import org.eclipse.ui.presentations.AbstractPresentationFactory;
Lines 45-55 Link Here
45
    private SystemMenuSize sizeItem = new SystemMenuSize(null);
46
    private SystemMenuSize sizeItem = new SystemMenuSize(null);
46
47
47
    private SystemMenuFastView fastViewAction;
48
    private SystemMenuFastView fastViewAction;
49
    private SystemMenuMoveToTrim moveToTrimAction;
48
50
49
    private SystemMenuDetach detachViewAction;
51
    private SystemMenuDetach detachViewAction;
50
    
52
    
51
    public void addSystemActions(IMenuManager menuManager) {
53
    public void addSystemActions(IMenuManager menuManager) {
52
        appendToGroupIfPossible(menuManager,
54
        appendToGroupIfPossible(menuManager,
55
                "misc", new UpdatingActionContributionItem(moveToTrimAction)); //$NON-NLS-1$
56
        appendToGroupIfPossible(menuManager,
53
                "misc", new UpdatingActionContributionItem(fastViewAction)); //$NON-NLS-1$
57
                "misc", new UpdatingActionContributionItem(fastViewAction)); //$NON-NLS-1$
54
        appendToGroupIfPossible(menuManager,
58
        appendToGroupIfPossible(menuManager,
55
        		"misc", new UpdatingActionContributionItem(detachViewAction)); //$NON-NLS-1$
59
        		"misc", new UpdatingActionContributionItem(detachViewAction)); //$NON-NLS-1$
Lines 75-80 Link Here
75
79
76
        this.allowStateChanges = allowsStateChanges;
80
        this.allowStateChanges = allowsStateChanges;
77
        fastViewAction = new SystemMenuFastView(getPresentationSite());
81
        fastViewAction = new SystemMenuFastView(getPresentationSite());
82
        moveToTrimAction = new SystemMenuMoveToTrim(getPresentationSite());
78
        detachViewAction = new SystemMenuDetach(getPresentationSite());
83
        detachViewAction = new SystemMenuDetach(getPresentationSite());
79
    }
84
    }
80
85
Lines 102-107 Link Here
102
        }
107
        }
103
108
104
        fastViewAction.setPane(current);
109
        fastViewAction.setPane(current);
110
        moveToTrimAction.setPane(current);
105
        detachViewAction.setPane(pane);
111
        detachViewAction.setPane(pane);
106
        sizeItem.setPane(pane);
112
        sizeItem.setPane(pane);
107
    }
113
    }
(-)Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java (+4 lines)
Lines 210-215 Link Here
210
210
211
    public static final String TAG_FAST_VIEWS = "fastViews"; //$NON-NLS-1$
211
    public static final String TAG_FAST_VIEWS = "fastViews"; //$NON-NLS-1$
212
212
213
    public static final String TAG_GLOBAL_FAST_VIEWS = "globalFastViews"; //$NON-NLS-1$
214
215
    public static final String TAG_FAST_GROUPS = "fastGroups"; //$NON-NLS-1$
216
213
    public static final String TAG_FIXED = "fixed";//$NON-NLS-1$
217
    public static final String TAG_FIXED = "fixed";//$NON-NLS-1$
214
218
215
    public static final String TAG_CLOSEABLE = "closeable";//$NON-NLS-1$
219
    public static final String TAG_CLOSEABLE = "closeable";//$NON-NLS-1$
(-)Eclipse UI/org/eclipse/ui/internal/FastViewPane.java (+7 lines)
Lines 37-42 Link Here
37
import org.eclipse.ui.internal.presentations.PresentablePart;
37
import org.eclipse.ui.internal.presentations.PresentablePart;
38
import org.eclipse.ui.internal.presentations.SystemMenuFastView;
38
import org.eclipse.ui.internal.presentations.SystemMenuFastView;
39
import org.eclipse.ui.internal.presentations.SystemMenuFastViewOrientation;
39
import org.eclipse.ui.internal.presentations.SystemMenuFastViewOrientation;
40
import org.eclipse.ui.internal.presentations.SystemMenuMoveToTrim;
40
import org.eclipse.ui.internal.presentations.SystemMenuSizeFastView;
41
import org.eclipse.ui.internal.presentations.SystemMenuSizeFastView;
41
import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
42
import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
42
import org.eclipse.ui.presentations.AbstractPresentationFactory;
43
import org.eclipse.ui.presentations.AbstractPresentationFactory;
Lines 169-174 Link Here
169
            appendToGroupIfPossible(menuManager,
170
            appendToGroupIfPossible(menuManager,
170
                    "misc", new UpdatingActionContributionItem(fastViewAction)); //$NON-NLS-1$
171
                    "misc", new UpdatingActionContributionItem(fastViewAction)); //$NON-NLS-1$
171
            appendToGroupIfPossible(menuManager,
172
            appendToGroupIfPossible(menuManager,
173
                    "misc", new UpdatingActionContributionItem(moveToTrimViewAction)); //$NON-NLS-1$
174
            appendToGroupIfPossible(menuManager,
172
                    "size", new SystemMenuSizeFastView(FastViewPane.this)); //$NON-NLS-1$
175
                    "size", new SystemMenuSizeFastView(FastViewPane.this)); //$NON-NLS-1$
173
        }
176
        }
174
177
Lines 218-223 Link Here
218
    };
221
    };
219
222
220
    private SystemMenuFastView fastViewAction = new SystemMenuFastView(site);
223
    private SystemMenuFastView fastViewAction = new SystemMenuFastView(site);
224
    private SystemMenuMoveToTrim moveToTrimViewAction = new SystemMenuMoveToTrim(site);
221
225
222
    private static void appendToGroupIfPossible(IMenuManager m, String groupId,
226
    private static void appendToGroupIfPossible(IMenuManager m, String groupId,
223
            ContributionItem item) {
227
            ContributionItem item) {
Lines 392-397 Link Here
392
        currentPane = new PresentablePart(pane, newClientComposite);
396
        currentPane = new PresentablePart(pane, newClientComposite);
393
        
397
        
394
        fastViewAction.setPane(currentPane);
398
        fastViewAction.setPane(currentPane);
399
        moveToTrimViewAction.setPane(currentPane);
395
        clientComposite = newClientComposite;
400
        clientComposite = newClientComposite;
396
401
397
        clientComposite.addListener(SWT.Resize, resizeListener);
402
        clientComposite.addListener(SWT.Resize, resizeListener);
Lines 507-512 Link Here
507
        }
512
        }
508
513
509
        fastViewAction.setPane(null);
514
        fastViewAction.setPane(null);
515
        moveToTrimViewAction.setPane(null);
516
        
510
        //unzoom before hiding
517
        //unzoom before hiding
511
        currentPane.getPane().setZoomed(false);
518
        currentPane.getPane().setZoomed(false);
512
519
(-)Eclipse UI/org/eclipse/ui/internal/TrimUtil.java (-1 / +1 lines)
Lines 41-47 Link Here
41
    	ToolBar t = new ToolBar(s, SWT.NONE);
41
    	ToolBar t = new ToolBar(s, SWT.NONE);
42
    	t.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
42
    	t.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
43
    	ToolItem ti = new ToolItem(t, SWT.PUSH);
43
    	ToolItem ti = new ToolItem(t, SWT.PUSH);
44
    	ti.setImage(JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_HELP));
44
    	ti.setImage(JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_MESSAGE_INFO));
45
    	s.layout();
45
    	s.layout();
46
    	int toolItemHeight = t.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
46
    	int toolItemHeight = t.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
47
    	GC gc = new GC(s);
47
    	GC gc = new GC(s);
(-)Eclipse UI/org/eclipse/ui/internal/ShowViewAction.java (-4 / +2 lines)
Lines 68-77 Link Here
68
                        ref = (IViewReference)wp.getReference(part); 
68
                        ref = (IViewReference)wp.getReference(part); 
69
                    }
69
                    }
70
                    
70
                    
71
                    if (!wp.isFastView(ref)) {
71
                    FastViewBar bar = ((WorkbenchWindow)page.getWorkbenchWindow()).getFastViewBar();
72
                        wp.addFastView(ref);
72
                    bar.adoptView(ref, -1, true, true, false);
73
                    }
74
                    wp.activate(ref.getPart(true));
75
                } else {
73
                } else {
76
                    page.showView(desc.getId());
74
                    page.showView(desc.getId());
77
                }
75
                }
(-)Eclipse UI/org/eclipse/ui/internal/ShowFastViewContribution.java (-6 / +17 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal;
11
package org.eclipse.ui.internal;
12
12
13
import java.util.Iterator;
14
import java.util.List;
15
13
import org.eclipse.jface.action.ContributionItem;
16
import org.eclipse.jface.action.ContributionItem;
14
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.events.DisposeEvent;
18
import org.eclipse.swt.events.DisposeEvent;
Lines 31-43 Link Here
31
public class ShowFastViewContribution extends ContributionItem {
34
public class ShowFastViewContribution extends ContributionItem {
32
    public static final String FAST_VIEW = "FastView"; //$NON-NLS-1$
35
    public static final String FAST_VIEW = "FastView"; //$NON-NLS-1$
33
36
37
    private FastViewBar fvb;
34
    private IWorkbenchWindow window;
38
    private IWorkbenchWindow window;
35
39
36
    /**
40
    /**
37
     * Create a new menu item.
41
     * Create a new menu item.
38
     */
42
     */
39
    public ShowFastViewContribution(IWorkbenchWindow window) {
43
    public ShowFastViewContribution(FastViewBar fvb, IWorkbenchWindow window) {
40
        super("showFastViewContr"); //$NON-NLS-1$
44
        super("showFastViewContr"); //$NON-NLS-1$
45
        this.fvb = fvb;
41
        this.window = window;
46
        this.window = window;
42
    }
47
    }
43
48
Lines 49-56 Link Here
49
        if (!Util.equals(item.getToolTipText(), ref.getTitle())) {
54
        if (!Util.equals(item.getToolTipText(), ref.getTitle())) {
50
            item.setToolTipText(ref.getTitle());
55
            item.setToolTipText(ref.getTitle());
51
        }
56
        }
57
58
        // TODO: This gets called during shutdown; hide/remove the items?
59
        if (fvb.getWindow().getActiveWorkbenchPage() == null)
60
        	return;
61
        
62
        Perspective persp = fvb.getWindow().getActiveWorkbenchPage().getActivePerspective();
63
        item.setEnabled(persp.isFastView(ref));
52
    }
64
    }
53
    
65
54
    public static ToolItem getItem(ToolBar toSearch, IWorkbenchPartReference ref) {
66
    public static ToolItem getItem(ToolBar toSearch, IWorkbenchPartReference ref) {
55
        ToolItem[] items = toSearch.getItems();
67
        ToolItem[] items = toSearch.getItems();
56
        
68
        
Lines 77-88 Link Here
77
		}
89
		}
78
90
79
        // Get views.
91
        // Get views.
80
        IViewReference[] refs = page.getFastViews();
92
        List refs = fvb.getViewRefs();
81
93
82
        // Create tool item for each view.
94
        // Create tool item for each view.
83
        int size = refs.length;
95
        for (Iterator iterator = refs.iterator(); iterator.hasNext();) {
84
        for (int nX = 0; nX < size; nX++) {
96
            final IViewReference ref = (IViewReference) iterator.next();
85
            final IViewReference ref = refs[nX];
86
            final ToolItem item = new ToolItem(parent, SWT.CHECK, index);
97
            final ToolItem item = new ToolItem(parent, SWT.CHECK, index);
87
            updateItem(item, ref);
98
            updateItem(item, ref);
88
            item.setData(FAST_VIEW, ref);
99
            item.setData(FAST_VIEW, ref);
(-)Eclipse UI/org/eclipse/ui/internal/Perspective.java (-3 / +186 lines)
Lines 27-32 Link Here
27
import org.eclipse.jface.dialogs.MessageDialog;
27
import org.eclipse.jface.dialogs.MessageDialog;
28
import org.eclipse.jface.preference.IPreferenceStore;
28
import org.eclipse.jface.preference.IPreferenceStore;
29
import org.eclipse.osgi.util.NLS;
29
import org.eclipse.osgi.util.NLS;
30
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.graphics.Rectangle;
31
import org.eclipse.swt.graphics.Rectangle;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Control;
33
import org.eclipse.swt.widgets.Control;
Lines 47-53 Link Here
47
import org.eclipse.ui.WorkbenchException;
48
import org.eclipse.ui.WorkbenchException;
48
import org.eclipse.ui.XMLMemento;
49
import org.eclipse.ui.XMLMemento;
49
import org.eclipse.ui.internal.intro.IIntroConstants;
50
import org.eclipse.ui.internal.intro.IIntroConstants;
51
import org.eclipse.ui.internal.layout.ITrimManager;
52
import org.eclipse.ui.internal.layout.LayoutUtil;
50
import org.eclipse.ui.internal.misc.StatusUtil;
53
import org.eclipse.ui.internal.misc.StatusUtil;
54
import org.eclipse.ui.internal.presentations.PresentablePart;
51
import org.eclipse.ui.internal.registry.ActionSetRegistry;
55
import org.eclipse.ui.internal.registry.ActionSetRegistry;
52
import org.eclipse.ui.internal.registry.IActionSetDescriptor;
56
import org.eclipse.ui.internal.registry.IActionSetDescriptor;
53
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
57
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
Lines 84-89 Link Here
84
    private ArrayList perspectiveShortcuts;
88
    private ArrayList perspectiveShortcuts;
85
89
86
    private ArrayList fastViews;
90
    private ArrayList fastViews;
91
    private List globalFastViews;
92
    private ArrayList fastViewBars;
87
93
88
    private Map mapIDtoViewLayoutRec;
94
    private Map mapIDtoViewLayoutRec;
89
95
Lines 136-141 Link Here
136
        alwaysOnActionSets = new ArrayList(2);
142
        alwaysOnActionSets = new ArrayList(2);
137
        alwaysOffActionSets = new ArrayList(2);
143
        alwaysOffActionSets = new ArrayList(2);
138
        fastViews = new ArrayList(2);
144
        fastViews = new ArrayList(2);
145
        globalFastViews = new ArrayList(2);
146
        fastViewBars = new ArrayList(2);
139
        mapIDtoViewLayoutRec = new HashMap();
147
        mapIDtoViewLayoutRec = new HashMap();
140
    }
148
    }
141
149
Lines 310-315 Link Here
310
        return array;
318
        return array;
311
    }
319
    }
312
320
321
    public void closeTrimGroup(FastViewBar groupBar) {
322
    	groupBar.restoreGroup();
323
    	
324
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
325
    	ITrimManager tbm = wbw.getTrimManager();
326
    	tbm.removeTrim(groupBar);
327
    	
328
    	groupBar.dispose();
329
    }
330
    
331
    private String getUniqueGroupId() {
332
		// Get a unique id
333
    	boolean found = false;
334
    	int count = 0;
335
    	String id = ""; //$NON-NLS-1$
336
    	while (!found) {
337
    		id = getDesc().getId() + " (" + count  + ")";  //$NON-NLS-1$//$NON-NLS-2$
338
    		boolean matchFound = false;
339
    		for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
340
				FastViewBar fvb = (FastViewBar) fvbIter.next();
341
				if (fvb.getId().equals(id)) {
342
					matchFound = true;
343
					break;
344
				}
345
			}
346
    		
347
    		if (matchFound)
348
    			count++;
349
    		else
350
    			found = true;
351
    	}
352
    	
353
    	return id;
354
    }
355
    
356
    public void moveToTrim(ViewStack stack) {
357
    	FastViewBar fvb = createFastViewBar(getUniqueGroupId(), FastViewBar.GROUP_FVB , SWT.BOTTOM);
358
    	
359
    	ArrayList refs = new ArrayList();
360
    	List parts = stack.getPresentableParts();
361
    	for (Iterator partIter = parts.iterator(); partIter.hasNext();) {
362
    		PresentablePart part = (PresentablePart) partIter.next();
363
    		if (part.getPane().getPartReference() instanceof ViewReference) {
364
    			refs.add(part.getPane().getPartReference());
365
    		}
366
		}
367
    	fvb.setViewRefs(refs);
368
    	fvb.collapseGroup();
369
    }
370
    
371
    private FastViewBar createFastViewBar(String id, int style, int side) {   	
372
    	// Create the FVB on the given side
373
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
374
    	FastViewBar newFVB = new FastViewBar(wbw, style, id);
375
    	newFVB.createControl(wbw.getShell());
376
    	newFVB.getControl().setVisible(true);
377
    	ITrimManager tbm = wbw.getTrimManager();
378
    	tbm.addTrim(side, newFVB);
379
    	
380
    	fastViewBars.add(newFVB);
381
    	LayoutUtil.resize(newFVB.getControl());
382
    	
383
    	return newFVB;
384
    }
385
    
313
    /**
386
    /**
314
     * Returns the new wizard shortcuts associated with this perspective.
387
     * Returns the new wizard shortcuts associated with this perspective.
315
     * 
388
     * 
Lines 802-808 Link Here
802
                ctrl.setEnabled(false); // Remove focus support.
875
                ctrl.setEnabled(false); // Remove focus support.
803
            }
876
            }
804
        }
877
        }
805
878
        
879
        // update the 'global' FVB
880
        FastViewBar fvb = ((WorkbenchWindow)page.getWorkbenchWindow()).getFastViewBar();
881
        fvb.setViewRefs(globalFastViews);
882
883
        // Show the trim groups
884
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
885
    	ITrimManager tbm = wbw.getTrimManager();
886
        for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
887
        	fvb = (FastViewBar) fvbIter.next();
888
        	fvb.update(false);
889
			tbm.setTrimVisible(fvb, true);
890
		}
891
		
892
		// if we're done then force an update...optimize out if possible
893
		LayoutUtil.resize(fvb.getControl());
894
        
806
        setAllPinsVisible(true);
895
        setAllPinsVisible(true);
807
        presentation.activate(getClientComposite());
896
        presentation.activate(getClientComposite());
808
897
Lines 822-827 Link Here
822
        setActiveFastView(null);
911
        setActiveFastView(null);
823
        setAllPinsVisible(false);
912
        setAllPinsVisible(false);
824
913
914
        // remember the list of 'global' fast views
915
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
916
        globalFastViews = new ArrayList(wbw.getFastViewBar().getViewRefs());
917
        	
825
        // Update fast views.
918
        // Update fast views.
826
        for (int i = 0; i < fastViews.size(); i++) {
919
        for (int i = 0; i < fastViews.size(); i++) {
827
            ViewPane pane = getPane((IViewReference) fastViews.get(i));
920
            ViewPane pane = getPane((IViewReference) fastViews.get(i));
Lines 832-837 Link Here
832
				}
925
				}
833
            }
926
            }
834
        }
927
        }
928
929
        // Hide the trim groups
930
    	ITrimManager tbm = wbw.getTrimManager();
931
        for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
932
			FastViewBar fvb = (FastViewBar) fvbIter.next();
933
			tbm.setTrimVisible(fvb, false);
934
		}
835
    }
935
    }
836
936
837
    /**
937
    /**
Lines 902-912 Link Here
902
        IMemento views[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
1002
        IMemento views[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
903
        result.merge(createReferences(views));
1003
        result.merge(createReferences(views));
904
1004
1005
        // Restore the list of fast views
905
        memento = memento.getChild(IWorkbenchConstants.TAG_FAST_VIEWS);
1006
        memento = memento.getChild(IWorkbenchConstants.TAG_FAST_VIEWS);
906
        if (memento != null) {
1007
        if (memento != null) {
907
            views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
1008
            views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
908
            result.merge(createReferences(views));
1009
            result.merge(createReferences(views));
909
        }
1010
        }
1011
        
910
        return result;
1012
        return result;
911
    }
1013
    }
912
1014
Lines 1106-1111 Link Here
1106
            }
1208
            }
1107
        }
1209
        }
1108
1210
1211
        // Restore the list of 'global' fast views
1212
        globalFastViews = new ArrayList();
1213
        IMemento globalFastViewsMem = memento.getChild(IWorkbenchConstants.TAG_GLOBAL_FAST_VIEWS);
1214
        if (globalFastViewsMem != null) {
1215
        	IMemento[] globalRefs = globalFastViewsMem.getChildren(IWorkbenchConstants.TAG_VIEW);
1216
        	for (int i = 0; i < globalRefs.length; i++) {
1217
    			String viewId = globalRefs[i].getID();
1218
                String secondaryId = ViewFactory.extractSecondaryId(viewId);
1219
                if (secondaryId != null) {
1220
                	viewId = ViewFactory.extractPrimaryId(viewId);
1221
                }
1222
                
1223
                // Resolve the ref
1224
                IViewReference ref = viewFactory.getView(viewId, secondaryId);
1225
                globalFastViews.add(ref);
1226
			}
1227
        }
1228
        else {
1229
        	// Old format, all fast views are 'global'
1230
        	globalFastViews = new ArrayList(fastViews);
1231
        }
1232
1233
        // Restore the trim groups
1234
        IMemento groupsMem = memento.getChild(IWorkbenchConstants.TAG_FAST_GROUPS);
1235
        IMemento[] group = groupsMem.getChildren(IWorkbenchConstants.TAG_FAST_VIEW_DATA);
1236
        for (int i = 0; i < group.length; i++) {
1237
        	String id = group[i].getString(IWorkbenchConstants.TAG_ID);
1238
        	FastViewBar fvb = createFastViewBar(id, FastViewBar.GROUP_FVB, SWT.BOTTOM);
1239
        	fvb.restoreState(group[i]);
1240
1241
        	IMemento viewsMem = group[i].getChild(IWorkbenchConstants.TAG_VIEWS);
1242
    		IMemento[] fvMems = viewsMem.getChildren(IWorkbenchConstants.TAG_VIEW);
1243
    		ArrayList viewRefs = new ArrayList(fvMems.length);
1244
    		for (int j = 0; j < fvMems.length; j++) {
1245
    			String viewId = fvMems[j].getID();
1246
                String secondaryId = ViewFactory.extractSecondaryId(viewId);
1247
                if (secondaryId != null) {
1248
                	viewId = ViewFactory.extractPrimaryId(viewId);
1249
                }
1250
                
1251
                // Resolve the ref
1252
                IViewReference ref = viewFactory.getView(viewId, secondaryId);
1253
                viewRefs.add(ref);
1254
    		}
1255
        	
1256
    		fvb.setViewRefs(viewRefs);
1257
		}
1258
        
1109
        HashSet knownActionSetIds = new HashSet();
1259
        HashSet knownActionSetIds = new HashSet();
1110
1260
1111
        // Load the always on action sets.
1261
        // Load the always on action sets.
Lines 1403-1408 Link Here
1403
                    .getKey(ref));
1553
                    .getKey(ref));
1404
        }
1554
        }
1405
1555
1556
        // Save the set of all fast Views
1406
        if (fastViews.size() > 0) {
1557
        if (fastViews.size() > 0) {
1407
            IMemento childMem = memento
1558
            IMemento childMem = memento
1408
                    .createChild(IWorkbenchConstants.TAG_FAST_VIEWS);
1559
                    .createChild(IWorkbenchConstants.TAG_FAST_VIEWS);
Lines 1418-1423 Link Here
1418
            }
1569
            }
1419
        }
1570
        }
1420
1571
1572
        // Save the set of all 'global' fast Views for this perspective        
1573
        // update the list of 'global' fast views
1574
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
1575
        globalFastViews = new ArrayList(wbw.getFastViewBar().getViewRefs());
1576
    
1577
        IMemento globalFVBMem = memento
1578
                .createChild(IWorkbenchConstants.TAG_GLOBAL_FAST_VIEWS);
1579
        itr = globalFastViews.iterator();
1580
        while (itr.hasNext()) {
1581
            IViewReference ref = (IViewReference) itr.next();
1582
            String id = ViewFactory.getKey(ref);
1583
            globalFVBMem.createChild(IWorkbenchConstants.TAG_VIEW, id);
1584
        }
1585
1421
        // Save the view layout recs.
1586
        // Save the view layout recs.
1422
        for (Iterator i = mapIDtoViewLayoutRec.keySet().iterator(); i.hasNext();) {
1587
        for (Iterator i = mapIDtoViewLayoutRec.keySet().iterator(); i.hasNext();) {
1423
            String compoundId = (String) i.next();
1588
            String compoundId = (String) i.next();
Lines 1445-1450 Link Here
1445
            }
1610
            }
1446
        }
1611
        }
1447
1612
1613
        // Save the list of group FVB's
1614
        IMemento fvbMem = memento.createChild(IWorkbenchConstants.TAG_FAST_GROUPS);
1615
        for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
1616
        	FastViewBar fvb = (FastViewBar) fvbIter.next();
1617
    		IMemento fastViewBarMem = fvbMem.createChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA);
1618
    		fastViewBarMem.putString(IWorkbenchConstants.TAG_ID, fvb.getId());
1619
    		fvb.saveState(fastViewBarMem);
1620
    		
1621
    		// Store the view references for this FVB
1622
    		List viewRefs = fvb.getViewRefs();
1623
    		IMemento viewsMem = fastViewBarMem.createChild(IWorkbenchConstants.TAG_VIEWS);
1624
    		for (Iterator fvIter = viewRefs.iterator(); fvIter.hasNext();) {
1625
    			IViewReference ref = (IViewReference) fvIter.next();
1626
                String id = ViewFactory.getKey(ref);
1627
                viewsMem.createChild(IWorkbenchConstants.TAG_VIEW, id);
1628
    		}
1629
		}
1630
        
1448
        if (errors > 0) {
1631
        if (errors > 0) {
1449
            String message = WorkbenchMessages.Perspective_multipleErrors;
1632
            String message = WorkbenchMessages.Perspective_multipleErrors;
1450
            if (errors == 1) {
1633
            if (errors == 1) {
Lines 1676-1683 Link Here
1676
        int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE);
1859
        int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE);
1677
1860
1678
        if (openViewMode == IPreferenceConstants.OVM_FAST) {
1861
        if (openViewMode == IPreferenceConstants.OVM_FAST) {
1679
            showFastView(ref);
1862
        	FastViewBar fvb = ((WorkbenchWindow)pane.getWorkbenchWindow()).getFastViewBar();
1680
            addFastView(ref);
1863
        	fvb.adoptView(ref, -1, true, true, false);
1681
        } else if (openViewMode == IPreferenceConstants.OVM_FLOAT
1864
        } else if (openViewMode == IPreferenceConstants.OVM_FLOAT
1682
                && presentation.canDetach()) {
1865
                && presentation.canDetach()) {
1683
            presentation.addDetachedPart(pane);
1866
            presentation.addDetachedPart(pane);
(-)Eclipse UI/org/eclipse/ui/internal/FastViewBarContextMenuContribution.java (-1 / +1 lines)
Lines 66-72 Link Here
66
        restoreItem.setText(WorkbenchMessages.ViewPane_fastView);
66
        restoreItem.setText(WorkbenchMessages.ViewPane_fastView);
67
        restoreItem.addSelectionListener(new SelectionAdapter() {
67
        restoreItem.addSelectionListener(new SelectionAdapter() {
68
            public void widgetSelected(SelectionEvent e) {
68
            public void widgetSelected(SelectionEvent e) {
69
                bar.restoreView(selectedView);
69
                bar.restoreView(selectedView, true, true);
70
            }
70
            }
71
        });
71
        });
72
72
(-)Eclipse UI/org/eclipse/ui/internal/FastViewBar.java (-95 / +271 lines)
Lines 76-96 Link Here
76
76
77
    private WorkbenchWindow window;
77
    private WorkbenchWindow window;
78
    private IViewReference selection;
78
    private IViewReference selection;
79
    private List viewRefs = new ArrayList();
79
    
80
    
80
    // "New Fast View" 'Button' fields
81
    // "New Fast View" 'Button' fields
81
    private MenuManager newFastViewMenuMgr;
82
    private MenuManager newFastViewMenuMgr;
82
    private Composite fvbComposite;
83
    private Composite fvbComposite;
83
    private ToolBar menuTB;
84
    private ToolBar menuTB;
84
    private ToolItem menuItem;
85
    private ToolItem showItem = null;
86
    private ToolItem groupItem = null;
87
    private FastGroupTrimButton groupBtn = null;
85
    private CellData toolBarData;
88
    private CellData toolBarData;
86
89
90
    /** Causes the FVB to remove the ref for any view restored to the workbench */
91
    public static final int REMOVE_UNFAST_REFS = 0x0001;
92
    /** Causes the FVB to show the 'group mode' button set */
93
    public static final int SHOW_GROUP_BUTTON = 0x0002;
94
    /** Causes the FVB to show the 'Add View' popup button */
95
    public static final int SHOW_ADD_BUTTON = 0x0004;
96
    
97
    public static final int LEGACY_FVB = REMOVE_UNFAST_REFS | SHOW_ADD_BUTTON;
98
    public static final int GROUP_FVB = SHOW_GROUP_BUTTON;
99
    
100
    private boolean testStyleBit(int toTest) { return (style & toTest) != 0; }
101
    private int style = LEGACY_FVB;
102
    
87
    private static final int HIDDEN_WIDTH = 5;
103
    private static final int HIDDEN_WIDTH = 5;
88
104
89
90
    private int oldLength = 0;
105
    private int oldLength = 0;
91
    
106
    
107
    // Dnd
92
    private ViewDropTarget dropTarget;
108
    private ViewDropTarget dropTarget;
93
94
    private Listener dragListener = new Listener() {
109
    private Listener dragListener = new Listener() {
95
        public void handleEvent(Event event) {
110
        public void handleEvent(Event event) {
96
            Point position = DragUtil.getEventLoc(event);
111
            Point position = DragUtil.getEventLoc(event);
Lines 126-131 Link Here
126
        }
141
        }
127
    };
142
    };
128
	private int fCurrentSide = SWT.DEFAULT;
143
	private int fCurrentSide = SWT.DEFAULT;
144
	
145
	private static final String GLOBAL_FVB_ID ="org.eclise.ui.internal.FastViewBar"; //$NON-NLS-1$ 
146
	private String id = GLOBAL_FVB_ID;
129
147
130
    class ViewDropTarget extends AbstractDropTarget {
148
    class ViewDropTarget extends AbstractDropTarget {
131
        List panes;
149
        List panes;
Lines 148-161 Link Here
148
         * @see org.eclipse.ui.internal.dnd.IDropTarget#drop()
166
         * @see org.eclipse.ui.internal.dnd.IDropTarget#drop()
149
         */
167
         */
150
        public void drop() {
168
        public void drop() {
151
            IViewReference view = getViewFor(position);
169
            IViewReference beforeRef = getViewFor(position);
152
170
153
            Iterator iter = panes.iterator();
171
            Iterator iter = panes.iterator();
154
            while (iter.hasNext()) {
172
            while (iter.hasNext()) {
155
                ViewPane pane = (ViewPane) iter.next();
173
                ViewPane pane = (ViewPane) iter.next();
156
                getPage().addFastView(pane.getViewReference());
174
                IViewReference ref = pane.getViewReference();
157
                getPage().getActivePerspective().moveFastView(
175
                int insertIdx = viewRefs.indexOf(beforeRef);
158
                        pane.getViewReference(), view);
176
                System.out.println("Drop: ref = " + ref.getId() + "insert Index = " + insertIdx); //$NON-NLS-1$ //$NON-NLS-2$
177
                adoptView(ref, insertIdx, true, false, !iter.hasNext());
159
            }
178
            }
160
            update(true);
179
            update(true);
161
        }
180
        }
Lines 199-265 Link Here
199
           
218
           
200
           public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, IWorkbenchPartReference partRef, String changeId) {
219
           public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, IWorkbenchPartReference partRef, String changeId) {
201
               if (page != null && page == window.getActivePage() && page.getPerspective() == perspective) {
220
               if (page != null && page == window.getActivePage() && page.getPerspective() == perspective) {
202
                    
203
                   ToolBar bar = fastViewBar.getControl();
204
                   
205
                   // Handle removals immediately just in case the part (and its image) is about to be disposed
221
                   // Handle removals immediately just in case the part (and its image) is about to be disposed
206
                   if (changeId.equals(IWorkbenchPage.CHANGE_VIEW_HIDE) 
222
                   if (changeId.equals(IWorkbenchPage.CHANGE_VIEW_HIDE)) {
207
                           || changeId.equals(IWorkbenchPage.CHANGE_FAST_VIEW_REMOVE)) {
223
                       removeViewRef((IViewReference) partRef);
208
                          
224
                       return;
209
                       ToolItem item = null;
210
                       
211
                       if (bar != null) {
212
                           item = ShowFastViewContribution.getItem(bar, partRef);
213
                       }
214
                       
215
                       if (item != null) {
216
                           item.dispose();
217
                           updateLayoutData();
218
                           return;
219
                       }
220
                   }
221
                   
222
                   // Ignore changes to non-fastviews
223
                   if (page instanceof WorkbenchPage && partRef instanceof IViewReference) {
224
                       if (!((WorkbenchPage)page).isFastView((IViewReference)partRef)) {
225
                           return;
226
                       }
227
                   }
225
                   }
228
226
229
                   if (changeId.equals(IWorkbenchPage.CHANGE_VIEW_SHOW) 
227
                   // If a view becomes 'unfast' we might want to remove it
230
                           || changeId.equals(IWorkbenchPage.CHANGE_FAST_VIEW_ADD)) {
228
                   if (changeId.equals(IWorkbenchPage.CHANGE_FAST_VIEW_REMOVE)) {
231
                       
229
                	   if ((style & REMOVE_UNFAST_REFS) != 0)
232
                       ToolItem item = null;
230
                		   removeViewRef((IViewReference) partRef);
233
                       
231
                       return;
234
                       if (bar != null) {
235
                           item = ShowFastViewContribution.getItem(bar, partRef);
236
                       }
237
                       
238
                       if (item != null) {
239
                           // If this part is already in the fast view bar, there is nothing to do
240
                           return;
241
                       }
242
                       fastViewBar.markDirty();
243
                   }
232
                   }
244
               } 
233
               } 
245
           }
234
           }
246
           
235
           
247
           public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
236
           public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
248
               if (changeId.equals(IWorkbenchPage.CHANGE_VIEW_HIDE) 
249
                       || changeId.equals(IWorkbenchPage.CHANGE_FAST_VIEW_REMOVE)) {
250
                   
251
                   // In these cases, we've aleady updated the fast view bar in the pre-change
252
                   // listener
253
                   return;
254
               }
255
               
256
               // Ignore changes to anything but the active perspective
257
               if (page != null && page == window.getActivePage() && page.getPerspective() == perspective) {
258
                   if (changeId.equals(IWorkbenchPage.CHANGE_VIEW_SHOW) 
259
                           || changeId.equals(IWorkbenchPage.CHANGE_FAST_VIEW_ADD)) {
260
                       update(false);
261
                   }
262
               }
263
           }
237
           }
264
        });
238
        });
265
239
Lines 280-285 Link Here
280
    }
254
    }
281
255
282
    /**
256
    /**
257
     * Special constructor that sets the ID
258
     * 
259
	 * @param wbw The Workbench window
260
     * @param style The style of FVB desired
261
	 * @param id The trim id 
262
	 */
263
	public FastViewBar(WorkbenchWindow wbw, int style, String id) {
264
		this(wbw);
265
		this.style = style;
266
		this.id = id;
267
	}
268
269
	/**
283
     * Returns the platform's idea of where the fast view bar should be docked in a fresh
270
     * Returns the platform's idea of where the fast view bar should be docked in a fresh
284
     * workspace.  This value is meaningless after a workspace has been setup, since the
271
     * workspace.  This value is meaningless after a workspace has been setup, since the
285
     * fast view bar state is then persisted in the workbench.  This preference is just
272
     * fast view bar state is then persisted in the workbench.  This preference is just
Lines 417-453 Link Here
417
        // Create a toolbar to show an 'Add FastView' menu 'button'
404
        // Create a toolbar to show an 'Add FastView' menu 'button'
418
        menuTB = new ToolBar(fvbComposite, SWT.FLAT | orientation);
405
        menuTB = new ToolBar(fvbComposite, SWT.FLAT | orientation);
419
406
420
        // Construct an item to act as a 'menu button' (a la the PerspectiveSwitcher)
407
        if (testStyleBit(SHOW_ADD_BUTTON)) {
421
        menuItem = new  ToolItem(menuTB, SWT.PUSH, 0);
408
	        // Construct an item to act as a 'menu button' (a la the PerspectiveSwitcher)
409
	        showItem = new  ToolItem(menuTB, SWT.PUSH, 0);
410
	        
411
	        Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_FASTVIEW);
412
	        showItem.setImage(tbImage);
413
	        
414
	        String menuTip = WorkbenchMessages.FastViewBar_0;
415
	        showItem.setToolTipText(menuTip);
416
	        
417
	        // Bring up the 'Add Fast View' menu on a left -or- right button click
418
	        // Right click (context menu)
419
	        showItem.addListener(SWT.MenuDetect, addMenuListener);        
420
	        
421
	        // Left Click...
422
	        showItem.addSelectionListener(new SelectionListener() {
423
				public void widgetSelected(SelectionEvent e) {
424
					Rectangle bb = DragUtil.getDisplayBounds(menuTB);
425
					showAddFastViewPopup(new Point(bb.x,bb.y+bb.height));
426
				}
427
428
				public void widgetDefaultSelected(SelectionEvent e) {
429
				}
430
	        	
431
	        });
432
        }
422
        
433
        
423
        Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_FASTVIEW);
434
        if (testStyleBit(SHOW_GROUP_BUTTON)) {
424
        menuItem.setImage(tbImage);
435
        	groupBtn = new FastGroupTrimButton(menuTB, this);
436
        	groupBtn.setSize(20);
437
        	groupItem = new ToolItem(menuTB, SWT.SEPARATOR, 0);
438
        	groupItem.setControl(groupBtn.getControl());
439
        	groupItem.setWidth(20);
440
        	
441
        }
425
        
442
        
426
        String menuTip = WorkbenchMessages.FastViewBar_0;
427
        menuItem.setToolTipText(menuTip);
428
        //new ToolItem(menuTB, SWT.SEPARATOR, 1);
443
        //new ToolItem(menuTB, SWT.SEPARATOR, 1);
429
        
444
430
        // Now that the ToolBar is populated calculate its size...
445
        // Now that the ToolBar is populated calculate its size...
431
        Point size = menuTB.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
446
        Point size = menuTB.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
432
        menuTB.setBounds(0, 0, size.x, size.y);
447
        menuTB.setBounds(0, 0, size.x, size.y);
433
        
448
        
434
        // Bring up the 'Add Fast View' menu on a left -or- right button click
449
        // Bring up the 'Add Fast View' menu on a left -or- right button click
435
        // Right click (context menu)
450
        // Right click (context menu)
436
        menuItem.addListener(SWT.MenuDetect, addMenuListener);        
437
        menuTB.addListener(SWT.MenuDetect, addMenuListener);
451
        menuTB.addListener(SWT.MenuDetect, addMenuListener);
438
        
452
        
439
        // Left Click...
440
        menuItem.addSelectionListener(new SelectionListener() {
441
			public void widgetSelected(SelectionEvent e) {
442
				Rectangle bb = DragUtil.getDisplayBounds(menuTB);
443
				showAddFastViewPopup(new Point(bb.x,bb.y+bb.height));
444
			}
445
446
			public void widgetDefaultSelected(SelectionEvent e) {
447
			}
448
        	
449
        });
450
        
451
        // try to get the layout correct...
453
        // try to get the layout correct...
452
        toolBarData = new CellData();
454
        toolBarData = new CellData();
453
        toolBarData.align(SWT.FILL, SWT.FILL);
455
        toolBarData.align(SWT.FILL, SWT.FILL);
Lines 455-461 Link Here
455
457
456
        // Construct the ToolBar containing the 'Fast' views
458
        // Construct the ToolBar containing the 'Fast' views
457
        fastViewBar = new ToolBarManager(SWT.FLAT | SWT.WRAP | orientation);
459
        fastViewBar = new ToolBarManager(SWT.FLAT | SWT.WRAP | orientation);
458
        fastViewBar.add(new ShowFastViewContribution(window));
460
        fastViewBar.add(new ShowFastViewContribution(this, window));
459
461
460
        fastViewBar.createControl(fvbComposite);
462
        fastViewBar.createControl(fvbComposite);
461
463
Lines 678-684 Link Here
678
        fastViewBar.dispose();
680
        fastViewBar.dispose();
679
        fastViewBar = null;
681
        fastViewBar = null;
680
        
682
        
681
        menuItem.dispose();
683
        if (showItem != null) {
684
        	showItem.dispose();
685
        	showItem = null;
686
        }
687
        
688
        if (groupItem != null) {
689
        	groupItem.dispose();
690
        	groupItem = null;
691
        }
692
        
682
        menuTB.dispose();
693
        menuTB.dispose();
683
        
694
        
684
        oldLength = 0;
695
        oldLength = 0;
Lines 859-865 Link Here
859
            orientation.putInteger(IWorkbenchConstants.TAG_POSITION,
870
            orientation.putInteger(IWorkbenchConstants.TAG_POSITION,
860
                    ((Integer) viewOrientation.get(next)).intValue());
871
                    ((Integer) viewOrientation.get(next)).intValue());
861
        }
872
        }
862
863
    }
873
    }
864
874
865
    /**
875
    /**
Lines 908-914 Link Here
908
        return window;
918
        return window;
909
    }
919
    }
910
    
920
    
911
    public void restoreView(IViewReference selectedView) {
921
    public void adoptView(IViewReference ref, int insertIndex, boolean makeFast, boolean activate, boolean animate) {
922
        if (ref != null) {
923
            WorkbenchPage page = window.getActiveWorkbenchPage();
924
            if (page != null) {
925
            	// Remember the pane -before- we adopt the view for animations
926
                ViewPane pane = (ViewPane) ((WorkbenchPartReference) ref)
927
                .getPane();
928
            	
929
                if (makeFast)
930
                	page.addFastView(ref);
931
932
                // we -must- have a ref since we're adopting the view
933
                if (!viewRefs.contains(ref))
934
                	addViewRef(ref, insertIndex, true);
935
                
936
                if (activate) {
937
	                IWorkbenchPart toActivate = ref.getPart(true);
938
	                if (toActivate != null) {
939
	                    page.activate(toActivate);
940
	                }
941
                }
942
943
                if (animate && pane != null) {
944
                    int idx = getIndex(ref);
945
                    ToolItem item = getItem(idx);
946
                    Rectangle bounds = item.getBounds();
947
                    Rectangle endBounds = Geometry.toDisplay(item
948
                            .getParent(), bounds);
949
950
	                RectangleAnimation animation = new RectangleAnimation(
951
	                        window.getShell(), pane.getParentBounds(), endBounds);
952
	
953
	                animation.schedule();
954
                }
955
            }
956
        }
957
    }
958
    
959
    public void restoreView(IViewReference selectedView, boolean activate, boolean animate) {
912
        if (selectedView != null) {
960
        if (selectedView != null) {
913
            WorkbenchPage page = window.getActiveWorkbenchPage();
961
            WorkbenchPage page = window.getActiveWorkbenchPage();
914
            if (page != null) {
962
            if (page != null) {
Lines 919-939 Link Here
919
                        .getParent(), bounds);
967
                        .getParent(), bounds);
920
968
921
                page.removeFastView(selectedView);
969
                page.removeFastView(selectedView);
922
970
                
923
                IWorkbenchPart toActivate = selectedView
971
                if (activate) {
924
                        .getPart(true);
972
	                IWorkbenchPart toActivate = selectedView
925
                if (toActivate != null) {
973
	                        .getPart(true);
926
                    page.activate(toActivate);
974
	                if (toActivate != null) {
975
	                    page.activate(toActivate);
976
	                }
927
                }
977
                }
928
978
929
                ViewPane pane = (ViewPane) ((WorkbenchPartReference) selectedView)
979
                ViewPane pane = (ViewPane) ((WorkbenchPartReference) selectedView)
930
                        .getPane();
980
                        .getPane();
931
981
932
                RectangleAnimation animation = new RectangleAnimation(
982
                if (animate) {
933
                        window.getShell(), startBounds, pane
983
	                RectangleAnimation animation = new RectangleAnimation(
934
                                .getParentBounds());
984
	                        window.getShell(), startBounds, pane
935
985
	                                .getParentBounds());
936
                animation.schedule();
986
	
987
	                animation.schedule();
988
                }
937
            }
989
            }
938
        }
990
        }
939
    }
991
    }
Lines 956-962 Link Here
956
	 * @see org.eclipse.ui.internal.IWindowTrim#getId()
1008
	 * @see org.eclipse.ui.internal.IWindowTrim#getId()
957
	 */
1009
	 */
958
	public String getId() {
1010
	public String getId() {
959
		return "org.eclise.ui.internal.FastViewBar"; //$NON-NLS-1$
1011
		return id;
960
	}
1012
	}
961
1013
962
	/* (non-Javadoc)
1014
	/* (non-Javadoc)
Lines 997-1000 Link Here
997
	public boolean isResizeable() {
1049
	public boolean isResizeable() {
998
		return false;
1050
		return false;
999
	}
1051
	}
1052
1053
	/**
1054
	 * @return Returns the viewRefs.
1055
	 */
1056
	public List getViewRefs() {
1057
		return viewRefs;
1058
	}
1059
1060
	/**
1061
	 * @param viewRefs The viewRefs to set.
1062
	 */
1063
	public void setViewRefs(List viewRefs) {
1064
		this.viewRefs = new ArrayList(viewRefs);
1065
        fastViewBar.markDirty();
1066
        update(true);
1067
	}
1068
	
1069
	/**
1070
	 * Add a new view reference into the list
1071
	 * @param ref The reference to add
1072
	 * @param insertIndex The index to insert it at
1073
	 * @param update 
1074
	 */
1075
	public void addViewRef(IViewReference ref, int insertIndex, boolean update) {
1076
		if (ref == null)
1077
			return;
1078
		
1079
		viewRefs.remove(ref);
1080
		if (insertIndex < 0 || insertIndex >= viewRefs.size())
1081
			viewRefs.add(ref);
1082
		else
1083
			viewRefs.add(insertIndex, ref);
1084
		
1085
		if (update) {
1086
	        fastViewBar.markDirty();
1087
	        update(true);
1088
		}
1089
	}
1090
	
1091
	/**
1092
	 * Remove a reference from the list
1093
	 * @param ref The view reference to remove
1094
	 */
1095
	public void removeViewRef(IViewReference ref) {
1096
		if (ref == null)
1097
			return;
1098
		
1099
		viewRefs.remove(ref);
1100
        
1101
        // Remove the ToolItem associated with the reference
1102
        ToolItem item = ShowFastViewContribution.getItem(fastViewBar.getControl(), ref);        
1103
        if (item != null) {
1104
            item.dispose();
1105
            updateLayoutData();
1106
            update(true);
1107
        }
1108
	}
1109
1110
	/**
1111
	 * Restore all refs and close the group
1112
	 */
1113
	public void closeGroup() {
1114
		Perspective persp = window.getActiveWorkbenchPage().getActivePerspective();
1115
		persp.closeTrimGroup(this);
1116
	}
1117
1118
	/**
1119
	 * Move all referenced views to the trim (ie. make
1120
	 * them fast views...)
1121
	 */
1122
	public void collapseGroup() {
1123
		for (Iterator refIter = viewRefs.iterator(); refIter.hasNext();) {
1124
			IViewReference ref = (IViewReference) refIter.next();
1125
			adoptView(ref, -1, true, false, !refIter.hasNext());
1126
		}
1127
		
1128
		update(false);
1129
	}
1130
1131
	/**
1132
	 * Restore all referenced views to the layout
1133
	 */
1134
	public void restoreGroup() {
1135
		for (Iterator refIter = viewRefs.iterator(); refIter.hasNext();) {
1136
			IViewReference ref = (IViewReference) refIter.next();
1137
			restoreView(ref, false, !refIter.hasNext());
1138
		}
1139
		
1140
		update(false);
1141
	}
1142
1143
	/**
1144
	 * @param fvbMem
1145
	 */
1146
	public void saveViewRefs(IMemento memento) {
1147
		IMemento viewsMem = memento.createChild(IWorkbenchConstants.TAG_VIEWS);
1148
		for (Iterator fvIter = viewRefs.iterator(); fvIter.hasNext();) {
1149
			IViewReference ref = (IViewReference) fvIter.next();
1150
            String id = ViewFactory.getKey(ref);
1151
            viewsMem.createChild(IWorkbenchConstants.TAG_VIEW, id);
1152
		}
1153
	}
1154
1155
	/**
1156
	 * Restore the list of view references for this FVB
1157
	 * 
1158
	 * @param fvbMem he IMemento to store the info in
1159
	 */
1160
	public void restoreViewRefs(IMemento memento) {
1161
		IMemento viewsMem = memento.getChild(IWorkbenchConstants.TAG_VIEWS);
1162
		IMemento[] fvMems = viewsMem.getChildren(IWorkbenchConstants.TAG_VIEW);
1163
		for (int i = 0; i < fvMems.length; i++) {
1164
			String viewId = fvMems[i].getID();
1165
            String secondaryId = ViewFactory.extractSecondaryId(viewId);
1166
            if (secondaryId != null) {
1167
            	viewId = ViewFactory.extractPrimaryId(viewId);
1168
            }
1169
            
1170
            // Resolve the ref
1171
            IViewReference ref = window.getActiveWorkbenchPage().getViewFactory().getView(viewId, secondaryId);
1172
            viewRefs.add(ref);
1173
		}
1174
	}
1000
}
1175
}
1176
(-)Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuFastView.java (-10 / +9 lines)
Lines 62-92 Link Here
62
        return viewRef;
62
        return viewRef;
63
    }
63
    }
64
64
65
    private WorkbenchWindow getWorkbenchWindow() {
66
    	return (WorkbenchWindow) viewPane.getPane().getPage().getWorkbenchWindow();
67
    }
68
65
    public boolean shouldBeVisible() {
69
    public boolean shouldBeVisible() {
66
        if (viewPane == null || viewPane.getPane().getPage() == null) {
70
        if (viewPane == null || viewPane.getPane().getPage() == null) {
67
            return false;
71
            return false;
68
        }
72
        }
69
73
70
        WorkbenchWindow workbenchWindow = (WorkbenchWindow) viewPane.getPane().getPage()
74
        return getWorkbenchWindow().getShowFastViewBars() && viewPane != null
71
                .getWorkbenchWindow();
72
73
        return workbenchWindow.getShowFastViewBars() && viewPane != null
74
                && site.isPartMoveable(viewPane);
75
                && site.isPartMoveable(viewPane);
75
    }
76
    }
76
77
    
77
    public void dispose() {
78
    public void dispose() {
78
        viewPane = null;
79
        viewPane = null;
79
    }
80
    }
80
81
81
    public void run() {
82
    public void run() {
82
        if (viewPane.getPane() instanceof ViewPane) {
83
        if (viewPane.getPane() instanceof ViewPane) {
83
            ViewPane pane = (ViewPane) viewPane.getPane();
84
            
85
            if (!isChecked()) {
84
            if (!isChecked()) {
86
                pane.doMakeFast();
85
                getWorkbenchWindow().getFastViewBar().adoptView(getReference(), -1, true, false, true);
87
            } else {
86
            } else {
88
                pane.doRemoveFast();
87
                getWorkbenchWindow().getFastViewBar().restoreView(getReference(), true, true);
89
            }   
88
            }
90
        }
89
        }
91
    }
90
    }
92
}
91
}
(-)Eclipse (+93 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 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
package org.eclipse.ui.internal.presentations;
12
13
import org.eclipse.jface.action.Action;
14
import org.eclipse.ui.IViewReference;
15
import org.eclipse.ui.IWorkbenchPartReference;
16
import org.eclipse.ui.internal.Perspective;
17
import org.eclipse.ui.internal.ViewStack;
18
import org.eclipse.ui.internal.WorkbenchMessages;
19
import org.eclipse.ui.internal.WorkbenchWindow;
20
import org.eclipse.ui.presentations.IStackPresentationSite;
21
22
/**
23
 * mplements the 'Move to Trim' action
24
 * 
25
 * @since 3.2
26
 *
27
 */
28
public class SystemMenuMoveToTrim extends Action implements ISelfUpdatingAction {
29
30
    private PresentablePart viewPane;
31
32
    private IStackPresentationSite site;
33
34
    public SystemMenuMoveToTrim(IStackPresentationSite site) {
35
        this.site = site;
36
        setText(WorkbenchMessages.ViewPane_moveToTrim);
37
        update();
38
    }
39
40
    public void setPane(PresentablePart newPane) {
41
        viewPane = newPane;
42
        update();
43
    }
44
    
45
    public void update() {
46
        IViewReference viewRef = getReference();
47
        
48
        if (viewRef == null
49
                || !site.isPartMoveable(viewPane)) {
50
            setEnabled(false);
51
        } else {
52
            setEnabled(true);
53
            
54
            setChecked(viewPane.getPane().getPage().getActivePerspective().isFastView(
55
                    viewRef));
56
        }
57
    }
58
59
    private IViewReference getReference() {
60
        IViewReference viewRef = null;
61
        
62
        if (viewPane != null) {
63
            IWorkbenchPartReference ref = viewPane.getPane().getPartReference();
64
            
65
            if (ref instanceof IViewReference) {
66
                viewRef = (IViewReference) ref;
67
            }
68
        }
69
        return viewRef;
70
    }
71
72
    private WorkbenchWindow getWorkbenchWindow() {
73
    	return (WorkbenchWindow) viewPane.getPane().getPage().getWorkbenchWindow();
74
    }
75
76
    public boolean shouldBeVisible() {
77
        if (viewPane == null || viewPane.getPane().getPage() == null) {
78
            return false;
79
        }
80
81
        return getWorkbenchWindow().getShowFastViewBars() && viewPane != null
82
                && site.isPartMoveable(viewPane);
83
    }
84
    
85
    public void dispose() {
86
        viewPane = null;
87
    }
88
89
    public void run() {
90
        Perspective psp = viewPane.getPane().getPage().getActivePerspective();
91
        psp.moveToTrim((ViewStack) viewPane.getPane().getStack());
92
    }
93
}
(-)Eclipse (+263 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 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
package org.eclipse.ui.internal;
12
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.events.MouseEvent;
15
import org.eclipse.swt.events.MouseListener;
16
import org.eclipse.swt.events.MouseMoveListener;
17
import org.eclipse.swt.events.MouseTrackListener;
18
import org.eclipse.swt.events.PaintEvent;
19
import org.eclipse.swt.events.PaintListener;
20
import org.eclipse.swt.graphics.Color;
21
import org.eclipse.swt.graphics.GC;
22
import org.eclipse.swt.graphics.Rectangle;
23
import org.eclipse.swt.widgets.Canvas;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
26
27
public class FastGroupTrimButton {
28
	private Canvas button;
29
	private FastViewBar fvb;
30
	private int side;
31
	private Color btnColor;
32
	
33
	private Rectangle closeRect;
34
	private Rectangle restoreRect;
35
	private Rectangle collapseRect;
36
37
	private static final int CTRL_AREA_NONE = 0;
38
	private static final int CTRL_AREA_CLOSE = 1;
39
	private static final int CTRL_AREA_RESTORE = 2;
40
	private static final int CTRL_AREA_COLLAPSE = 3;
41
	
42
	private int curCtrlArea = CTRL_AREA_NONE;
43
	private boolean inControl = false;
44
	private String toolTip;
45
	
46
	public FastGroupTrimButton(Composite parent, FastViewBar fvb) {
47
		this.fvb = fvb;
48
		
49
		if (fvb != null)
50
			side = fvb.getSide();
51
		else
52
			side = SWT.BOTTOM;
53
		
54
		btnColor = parent.getDisplay().getSystemColor(SWT.COLOR_BLACK);
55
		
56
		button = new Canvas(parent, SWT.NONE);
57
		button.addPaintListener(new PaintListener() {
58
			public void paintControl(PaintEvent e) {
59
				e.gc.setForeground(btnColor);
60
				paintButtons(e);
61
			}
62
		});
63
		
64
		button.addMouseTrackListener(new MouseTrackListener() {
65
			public void mouseEnter(MouseEvent e) {
66
				inControl = true;
67
				// Provide 'track' feedback?
68
			}
69
			public void mouseExit(MouseEvent e) {
70
				inControl = false;
71
				// remove 'track' feedback?
72
			}
73
			public void mouseHover(MouseEvent e) {
74
				button.setToolTipText(toolTip);
75
			}			
76
		});
77
		
78
		button.addMouseMoveListener(new MouseMoveListener() {
79
			public void mouseMove(MouseEvent e) {
80
				if (closeRect.contains(e.x,e.y)) {
81
					curCtrlArea = CTRL_AREA_CLOSE;
82
					toolTip = "Close Group"; //$NON-NLS-1$
83
				}
84
				else if (restoreRect.contains(e.x,e.y)) {
85
					curCtrlArea = CTRL_AREA_RESTORE;
86
					toolTip = "Restore Group"; //$NON-NLS-1$
87
				}
88
				else if (collapseRect.contains(e.x,e.y)) {
89
					curCtrlArea = CTRL_AREA_COLLAPSE;
90
					toolTip = "Collapse Group"; //$NON-NLS-1$
91
				}
92
				else
93
					curCtrlArea = CTRL_AREA_NONE;
94
			}
95
		});
96
		button.addMouseListener(new MouseListener() {
97
			public void mouseDoubleClick(MouseEvent e) {}
98
			public void mouseUp(MouseEvent e) {}
99
			public void mouseDown(MouseEvent e) {
100
				if (inControl && curCtrlArea != CTRL_AREA_NONE) {
101
					switch (curCtrlArea) {
102
					case CTRL_AREA_CLOSE:
103
						FastGroupTrimButton.this.fvb.closeGroup();
104
						break;
105
					case CTRL_AREA_COLLAPSE:
106
						FastGroupTrimButton.this.fvb.collapseGroup();
107
						break;
108
					case CTRL_AREA_RESTORE:
109
						FastGroupTrimButton.this.fvb.restoreGroup();
110
						break;
111
					}
112
				}
113
			}			
114
		});
115
	}
116
117
	public void setSize(int size) {
118
		button.setSize(size, size);
119
	}
120
	
121
	protected void paintButtons(PaintEvent e) {
122
		Rectangle bb = button.getBounds();
123
		setButtonRects(bb);
124
		
125
		paintClose(e.gc);
126
		paintRestore(e.gc);
127
		paintCollapse(e.gc);
128
	}
129
130
	private void paintCollapse(GC gc) {
131
		switch(side) {
132
		case SWT.BOTTOM:
133
			drawDownArrow(gc, collapseRect);
134
			break;
135
		case SWT.TOP:
136
			drawUpArrow(gc, collapseRect);
137
			break;
138
		case SWT.LEFT:
139
			drawLeftArrow(gc, collapseRect);
140
			break;
141
		case SWT.RIGHT:
142
			drawRightArrow(gc, collapseRect);
143
			break;
144
		}
145
	}
146
147
	private void paintRestore(GC gc) {
148
		switch(side) {
149
		case SWT.BOTTOM:
150
			drawUpArrow(gc, restoreRect);
151
			break;
152
		case SWT.TOP:
153
			drawDownArrow(gc, restoreRect);
154
			break;
155
		case SWT.LEFT:
156
			drawRightArrow(gc, restoreRect);
157
			break;
158
		case SWT.RIGHT:
159
			drawLeftArrow(gc, restoreRect);
160
			break;
161
		}
162
	}
163
164
	private void paintClose(GC gc) {
165
		int border = 2;
166
		gc.drawLine(closeRect.x+border, closeRect.y+border, (closeRect.x+closeRect.width)-border, (closeRect.y+closeRect.height)-border);
167
		gc.drawLine((closeRect.x+closeRect.width)-border, closeRect.y+border, closeRect.x+border, (closeRect.y+closeRect.height)-border);
168
//		int minX = closeRect.x + 2;
169
//		int maxX = (closeRect.x+closeRect.width) - 2;
170
//		int stopMax = maxX;
171
//		int y = (closeRect.y + (closeRect.height)/2) - ((maxX-minX)/2);
172
//
173
//		while (minX <= stopMax) {
174
//			gc.drawLine(minX, y, minX, y);
175
//			gc.drawLine(maxX, y, maxX, y);
176
//			minX++; maxX--; y++;
177
//		}
178
	}
179
180
	private void drawDownArrow(GC gc, Rectangle rect) {
181
		int y = rect.y + 1;
182
		int minX = rect.x + 2;
183
		int maxX = (rect.x+rect.width) - 2;
184
		
185
		while (minX <= maxX) {
186
			gc.drawLine(minX, y, maxX, y);
187
			y++;
188
			gc.drawLine(minX, y, maxX, y);
189
			minX++; maxX--; y++;
190
		}
191
	}
192
193
	private void drawRightArrow(GC gc, Rectangle rect) {
194
		int x = rect.x + 1;
195
		int minY = rect.y + 2;
196
		int maxY = (rect.y+rect.height) - 2;
197
		
198
		while (minY <= maxY) {
199
			gc.drawLine(x, minY, x, maxY);
200
			x++;
201
			gc.drawLine(x, minY, x, maxY);
202
			minY++; maxY--; x++;
203
		}
204
	}
205
206
	private void drawUpArrow(GC gc, Rectangle rect) {
207
		int y = (rect.y+rect.height) - 1;
208
		int minX = rect.x + 2;
209
		int maxX = (rect.x+rect.width) - 2;
210
		
211
		while (minX <= maxX) {
212
			gc.drawLine(minX, y, maxX, y);
213
			y--;
214
			gc.drawLine(minX, y, maxX, y);
215
			minX++; maxX--; y--;
216
		}
217
	}
218
219
	private void drawLeftArrow(GC gc, Rectangle rect) {
220
		int x = (rect.x+rect.width) - 1;
221
		int minY = rect.y + 2;
222
		int maxY = (rect.y+rect.height) - 2;
223
		
224
		while (minY <= maxY) {
225
			gc.drawLine(x, minY, x, maxY);
226
			x--;
227
			gc.drawLine(x, minY, x, maxY);
228
			minY++; maxY--; x--;
229
		}
230
	}
231
232
	private void setButtonRects(Rectangle bb) {
233
		int hw = bb.width/2;
234
		int hh = bb.height/2;
235
236
		switch (side) {
237
		case SWT.BOTTOM:
238
			closeRect = new Rectangle(bb.x, bb.y+(bb.height/4), hw, hh);
239
			restoreRect = new Rectangle(bb.x+hw, bb.y, hw, hh);
240
			collapseRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh);
241
			break;
242
		case SWT.TOP:
243
			closeRect = new Rectangle(bb.x, bb.y+(bb.height/4), hw, hh);
244
			collapseRect = new Rectangle(bb.x+hw, bb.y, hw, hh);
245
			restoreRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh);
246
			break;
247
		case SWT.LEFT:
248
			closeRect = new Rectangle(bb.x+(bb.width/4), bb.y, hw, hh);
249
			collapseRect = new Rectangle(bb.x, bb.y+hh, hw, hh);
250
			restoreRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh);
251
			break;
252
		case SWT.RIGHT:
253
			closeRect = new Rectangle(bb.x+(bb.width/4), bb.y, hw, hh);
254
			restoreRect = new Rectangle(bb.x, bb.y+hh, hw, hh);
255
			collapseRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh);
256
			break;
257
		}
258
	}
259
260
	public Control getControl() {
261
		return button;
262
	}
263
}

Return to bug 153957