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/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/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/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/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/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/Perspective.java (-5 / +209 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 boolean globalFVBsaved = false;
93
    private ArrayList fastViewBars;
87
94
88
    private Map mapIDtoViewLayoutRec;
95
    private Map mapIDtoViewLayoutRec;
89
96
Lines 136-141 Link Here
136
        alwaysOnActionSets = new ArrayList(2);
143
        alwaysOnActionSets = new ArrayList(2);
137
        alwaysOffActionSets = new ArrayList(2);
144
        alwaysOffActionSets = new ArrayList(2);
138
        fastViews = new ArrayList(2);
145
        fastViews = new ArrayList(2);
146
        globalFastViews = new ArrayList(2);
147
        fastViewBars = new ArrayList(2);
139
        mapIDtoViewLayoutRec = new HashMap();
148
        mapIDtoViewLayoutRec = new HashMap();
140
    }
149
    }
141
150
Lines 310-315 Link Here
310
        return array;
319
        return array;
311
    }
320
    }
312
321
322
    public void closeTrimGroup(FastViewBar groupBar) {
323
    	groupBar.restoreGroup();
324
    	
325
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
326
    	ITrimManager tbm = wbw.getTrimManager();
327
    	tbm.removeTrim(groupBar);
328
    	
329
    	groupBar.dispose();
330
    }
331
    
332
    private String getUniqueGroupId() {
333
		// Get a unique id
334
    	boolean found = false;
335
    	int count = 0;
336
    	String id = ""; //$NON-NLS-1$
337
    	while (!found) {
338
    		id = getDesc().getId() + " (" + count  + ")";  //$NON-NLS-1$//$NON-NLS-2$
339
    		boolean matchFound = false;
340
    		for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
341
				FastViewBar fvb = (FastViewBar) fvbIter.next();
342
				if (fvb.getId().equals(id)) {
343
					matchFound = true;
344
					break;
345
				}
346
			}
347
    		
348
    		if (matchFound)
349
    			count++;
350
    		else
351
    			found = true;
352
    	}
353
    	
354
    	return id;
355
    }
356
    
357
    public void moveToTrim(ViewStack stack) {
358
    	FastViewBar fvb = createFastViewBar(getUniqueGroupId(), FastViewBar.GROUP_FVB , SWT.BOTTOM);
359
    	
360
    	ArrayList refs = new ArrayList();
361
    	List parts = stack.getPresentableParts();
362
    	for (Iterator partIter = parts.iterator(); partIter.hasNext();) {
363
    		PresentablePart part = (PresentablePart) partIter.next();
364
    		if (part.getPane().getPartReference() instanceof ViewReference) {
365
    			refs.add(part.getPane().getPartReference());
366
    		}
367
		}
368
    	fvb.setViewRefs(refs);
369
    	fvb.collapseGroup();
370
    }
371
    
372
    private FastViewBar createFastViewBar(String id, int style, int side) {   	
373
    	// Create the FVB on the given side
374
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
375
    	FastViewBar newFVB = new FastViewBar(wbw, style, id);
376
    	newFVB.createControl(wbw.getShell());
377
    	newFVB.getControl().setVisible(true);
378
    	ITrimManager tbm = wbw.getTrimManager();
379
    	tbm.addTrim(side, newFVB);
380
    	
381
    	fastViewBars.add(newFVB);
382
    	LayoutUtil.resize(newFVB.getControl());
383
    	
384
    	return newFVB;
385
    }
386
    
313
    /**
387
    /**
314
     * Returns the new wizard shortcuts associated with this perspective.
388
     * Returns the new wizard shortcuts associated with this perspective.
315
     * 
389
     * 
Lines 802-808 Link Here
802
                ctrl.setEnabled(false); // Remove focus support.
876
                ctrl.setEnabled(false); // Remove focus support.
803
            }
877
            }
804
        }
878
        }
805
879
        
880
        // update the 'global' FVB
881
        FastViewBar fvb = ((WorkbenchWindow)page.getWorkbenchWindow()).getFastViewBar();
882
        fvb.setViewRefs(globalFastViews);
883
        globalFVBsaved = false;
884
885
        // Show the trim groups
886
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
887
    	ITrimManager tbm = wbw.getTrimManager();
888
        for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
889
        	fvb = (FastViewBar) fvbIter.next();
890
        	fvb.update(false);
891
			tbm.setTrimVisible(fvb, true);
892
		}
893
		
894
		// if we're done then force an update...optimize out if possible
895
		LayoutUtil.resize(fvb.getControl());
896
        
806
        setAllPinsVisible(true);
897
        setAllPinsVisible(true);
807
        presentation.activate(getClientComposite());
898
        presentation.activate(getClientComposite());
808
899
Lines 822-827 Link Here
822
        setActiveFastView(null);
913
        setActiveFastView(null);
823
        setAllPinsVisible(false);
914
        setAllPinsVisible(false);
824
915
916
        // remember the list of 'global' fast views
917
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
918
        globalFastViews = new ArrayList(wbw.getFastViewBar().getViewRefs());
919
        globalFVBsaved = true;
920
        
825
        // Update fast views.
921
        // Update fast views.
826
        for (int i = 0; i < fastViews.size(); i++) {
922
        for (int i = 0; i < fastViews.size(); i++) {
827
            ViewPane pane = getPane((IViewReference) fastViews.get(i));
923
            ViewPane pane = getPane((IViewReference) fastViews.get(i));
Lines 832-837 Link Here
832
				}
928
				}
833
            }
929
            }
834
        }
930
        }
931
932
        // Hide the trim groups
933
    	ITrimManager tbm = wbw.getTrimManager();
934
        for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
935
			FastViewBar fvb = (FastViewBar) fvbIter.next();
936
			tbm.setTrimVisible(fvb, false);
937
		}
835
    }
938
    }
836
939
837
    /**
940
    /**
Lines 902-912 Link Here
902
        IMemento views[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
1005
        IMemento views[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
903
        result.merge(createReferences(views));
1006
        result.merge(createReferences(views));
904
1007
1008
        // Restore the list of fast views
905
        memento = memento.getChild(IWorkbenchConstants.TAG_FAST_VIEWS);
1009
        memento = memento.getChild(IWorkbenchConstants.TAG_FAST_VIEWS);
906
        if (memento != null) {
1010
        if (memento != null) {
907
            views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
1011
            views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
908
            result.merge(createReferences(views));
1012
            result.merge(createReferences(views));
909
        }
1013
        }
1014
        
910
        return result;
1015
        return result;
911
    }
1016
    }
912
1017
Lines 1106-1111 Link Here
1106
            }
1211
            }
1107
        }
1212
        }
1108
1213
1214
        // Restore the list of 'global' fast views
1215
        globalFastViews = new ArrayList();
1216
        IMemento globalFastViewsMem = memento.getChild(IWorkbenchConstants.TAG_GLOBAL_FAST_VIEWS);
1217
        if (globalFastViewsMem != null) {
1218
        	IMemento[] globalRefs = globalFastViewsMem.getChildren(IWorkbenchConstants.TAG_VIEW);
1219
        	for (int i = 0; i < globalRefs.length; i++) {
1220
    			String viewId = globalRefs[i].getID();
1221
                String secondaryId = ViewFactory.extractSecondaryId(viewId);
1222
                if (secondaryId != null) {
1223
                	viewId = ViewFactory.extractPrimaryId(viewId);
1224
                }
1225
                
1226
                // Resolve the ref
1227
                IViewReference ref = viewFactory.getView(viewId, secondaryId);
1228
                globalFastViews.add(ref);
1229
			}
1230
        }
1231
        else {
1232
        	// Old format, all fast views are 'global'
1233
        	globalFastViews = new ArrayList(fastViews);
1234
        }
1235
1236
        // Restore the trim groups
1237
        IMemento groupsMem = memento.getChild(IWorkbenchConstants.TAG_FAST_GROUPS);
1238
        IMemento[] group = groupsMem.getChildren(IWorkbenchConstants.TAG_FAST_VIEW_DATA);
1239
        for (int i = 0; i < group.length; i++) {
1240
        	String id = group[i].getString(IWorkbenchConstants.TAG_ID);
1241
        	FastViewBar fvb = createFastViewBar(id, FastViewBar.GROUP_FVB, SWT.BOTTOM);
1242
        	fvb.restoreState(group[i]);
1243
1244
        	IMemento viewsMem = group[i].getChild(IWorkbenchConstants.TAG_VIEWS);
1245
    		IMemento[] fvMems = viewsMem.getChildren(IWorkbenchConstants.TAG_VIEW);
1246
    		ArrayList viewRefs = new ArrayList(fvMems.length);
1247
    		for (int j = 0; j < fvMems.length; j++) {
1248
    			String viewId = fvMems[j].getID();
1249
                String secondaryId = ViewFactory.extractSecondaryId(viewId);
1250
                if (secondaryId != null) {
1251
                	viewId = ViewFactory.extractPrimaryId(viewId);
1252
                }
1253
                
1254
                // Resolve the ref
1255
                IViewReference ref = viewFactory.getView(viewId, secondaryId);
1256
                viewRefs.add(ref);
1257
    		}
1258
        	
1259
    		fvb.setViewRefs(viewRefs);
1260
		}
1261
        
1109
        HashSet knownActionSetIds = new HashSet();
1262
        HashSet knownActionSetIds = new HashSet();
1110
1263
1111
        // Load the always on action sets.
1264
        // Load the always on action sets.
Lines 1403-1408 Link Here
1403
                    .getKey(ref));
1556
                    .getKey(ref));
1404
        }
1557
        }
1405
1558
1559
        // Save the set of all fast Views
1406
        if (fastViews.size() > 0) {
1560
        if (fastViews.size() > 0) {
1407
            IMemento childMem = memento
1561
            IMemento childMem = memento
1408
                    .createChild(IWorkbenchConstants.TAG_FAST_VIEWS);
1562
                    .createChild(IWorkbenchConstants.TAG_FAST_VIEWS);
Lines 1418-1423 Link Here
1418
            }
1572
            }
1419
        }
1573
        }
1420
1574
1575
        // Save the set of all 'global' fast Views for this perspective        
1576
        // update the list of 'global' fast views
1577
        if (!globalFVBsaved) {
1578
	    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
1579
	        globalFastViews = new ArrayList(wbw.getFastViewBar().getViewRefs());
1580
	        globalFVBsaved = true;
1581
        }
1582
    
1583
        IMemento globalFVBMem = memento
1584
                .createChild(IWorkbenchConstants.TAG_GLOBAL_FAST_VIEWS);
1585
        itr = globalFastViews.iterator();
1586
        while (itr.hasNext()) {
1587
            IViewReference ref = (IViewReference) itr.next();
1588
            String id = ViewFactory.getKey(ref);
1589
            globalFVBMem.createChild(IWorkbenchConstants.TAG_VIEW, id);
1590
        }
1591
1421
        // Save the view layout recs.
1592
        // Save the view layout recs.
1422
        for (Iterator i = mapIDtoViewLayoutRec.keySet().iterator(); i.hasNext();) {
1593
        for (Iterator i = mapIDtoViewLayoutRec.keySet().iterator(); i.hasNext();) {
1423
            String compoundId = (String) i.next();
1594
            String compoundId = (String) i.next();
Lines 1445-1450 Link Here
1445
            }
1616
            }
1446
        }
1617
        }
1447
1618
1619
        // Save the list of group FVB's
1620
        IMemento fvbMem = memento.createChild(IWorkbenchConstants.TAG_FAST_GROUPS);
1621
        for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
1622
        	FastViewBar fvb = (FastViewBar) fvbIter.next();
1623
    		IMemento fastViewBarMem = fvbMem.createChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA);
1624
    		fastViewBarMem.putString(IWorkbenchConstants.TAG_ID, fvb.getId());
1625
    		fvb.saveState(fastViewBarMem);
1626
    		
1627
    		// Store the view references for this FVB
1628
    		List viewRefs = fvb.getViewRefs();
1629
    		IMemento viewsMem = fastViewBarMem.createChild(IWorkbenchConstants.TAG_VIEWS);
1630
    		for (Iterator fvIter = viewRefs.iterator(); fvIter.hasNext();) {
1631
    			IViewReference ref = (IViewReference) fvIter.next();
1632
                String id = ViewFactory.getKey(ref);
1633
                viewsMem.createChild(IWorkbenchConstants.TAG_VIEW, id);
1634
    		}
1635
		}
1636
        
1448
        if (errors > 0) {
1637
        if (errors > 0) {
1449
            String message = WorkbenchMessages.Perspective_multipleErrors;
1638
            String message = WorkbenchMessages.Perspective_multipleErrors;
1450
            if (errors == 1) {
1639
            if (errors == 1) {
Lines 1554-1565 Link Here
1554
        }
1743
        }
1555
    }
1744
    }
1556
1745
1746
    public FastViewBar getFVBForRef(IViewReference ref) {
1747
    	for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
1748
			FastViewBar fvb = (FastViewBar) fvbIter.next();
1749
			if (fvb.hasViewRef(ref))
1750
				return fvb;
1751
		}
1752
    	
1753
    	return null;
1754
    }
1557
    /**
1755
    /**
1558
     * Sets the selection for the shortcut bar icon representing the givevn fast view.
1756
     * Sets the selection for the shortcut bar icon representing the givevn fast view.
1559
     */
1757
     */
1560
    private void setFastViewIconSelection(IViewReference ref, boolean selected) {
1758
    private void setFastViewIconSelection(IViewReference ref, boolean selected) {
1561
        WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow();
1759
        WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow();
1562
        FastViewBar bar = window.getFastViewBar();
1760
        FastViewBar bar = getFVBForRef(ref);
1761
        if (bar == null)
1762
        	bar = window.getFastViewBar();
1763
        
1563
        if (bar != null) {
1764
        if (bar != null) {
1564
            if (selected) {
1765
            if (selected) {
1565
                bar.setSelection(ref);
1766
                bar.setSelection(ref);
Lines 1635-1641 Link Here
1635
        saveFastViewWidthRatio();
1836
        saveFastViewWidthRatio();
1636
1837
1637
        WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow();
1838
        WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow();
1638
        FastViewBar bar = window.getFastViewBar();
1839
        FastViewBar bar = getFVBForRef(ref);
1840
        if (bar == null)
1841
        	bar = window.getFastViewBar();
1842
        
1639
        if (bar == null) {
1843
        if (bar == null) {
1640
            return false;
1844
            return false;
1641
        }
1845
        }
Lines 1676-1683 Link Here
1676
        int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE);
1880
        int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE);
1677
1881
1678
        if (openViewMode == IPreferenceConstants.OVM_FAST) {
1882
        if (openViewMode == IPreferenceConstants.OVM_FAST) {
1679
            showFastView(ref);
1883
        	FastViewBar fvb = ((WorkbenchWindow)pane.getWorkbenchWindow()).getFastViewBar();
1680
            addFastView(ref);
1884
        	fvb.adoptView(ref, -1, true, true, false);
1681
        } else if (openViewMode == IPreferenceConstants.OVM_FLOAT
1885
        } else if (openViewMode == IPreferenceConstants.OVM_FLOAT
1682
                && presentation.canDetach()) {
1886
                && presentation.canDetach()) {
1683
            presentation.addDetachedPart(pane);
1887
            presentation.addDetachedPart(pane);
(-)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/FastViewBar.java (-95 / +256 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
                
158
                        pane.getViewReference(), view);
176
                // Only allow one reference in an FVB per perspective
177
                FastViewBar curFVB = getPage().getActivePerspective().getFVBForRef(ref);
178
                if (curFVB == null && window.getFastViewBar().hasViewRef(ref))
179
                	curFVB = window.getFastViewBar();
180
                	
181
                if (curFVB != null) {
182
                	curFVB.removeViewRef(ref);
183
                }
184
                
185
                int insertIdx = viewRefs.indexOf(beforeRef);
186
                adoptView(ref, insertIdx, true, false, !iter.hasNext());
159
            }
187
            }
160
            update(true);
188
            update(true);
161
        }
189
        }
Lines 199-265 Link Here
199
           
227
           
200
           public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, IWorkbenchPartReference partRef, String changeId) {
228
           public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, IWorkbenchPartReference partRef, String changeId) {
201
               if (page != null && page == window.getActivePage() && page.getPerspective() == perspective) {
229
               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
230
                   // Handle removals immediately just in case the part (and its image) is about to be disposed
206
                   if (changeId.equals(IWorkbenchPage.CHANGE_VIEW_HIDE) 
231
                   if (changeId.equals(IWorkbenchPage.CHANGE_VIEW_HIDE)) {
207
                           || changeId.equals(IWorkbenchPage.CHANGE_FAST_VIEW_REMOVE)) {
232
                       removeViewRef((IViewReference) partRef);
208
                          
233
                       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
                   }
234
                   }
228
235
229
                   if (changeId.equals(IWorkbenchPage.CHANGE_VIEW_SHOW) 
236
                   // If a view becomes 'unfast' we might want to remove it
230
                           || changeId.equals(IWorkbenchPage.CHANGE_FAST_VIEW_ADD)) {
237
                   if (changeId.equals(IWorkbenchPage.CHANGE_FAST_VIEW_REMOVE)) {
231
                       
238
                	   if ((style & REMOVE_UNFAST_REFS) != 0)
232
                       ToolItem item = null;
239
                		   removeViewRef((IViewReference) partRef);
233
                       
240
                       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
                   }
241
                   }
244
               } 
242
               } 
245
           }
243
           }
246
           
244
           
247
           public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
245
           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
           }
246
           }
264
        });
247
        });
265
248
Lines 280-285 Link Here
280
    }
263
    }
281
264
282
    /**
265
    /**
266
     * Special constructor that sets the ID
267
     * 
268
	 * @param wbw The Workbench window
269
     * @param style The style of FVB desired
270
	 * @param id The trim id 
271
	 */
272
	public FastViewBar(WorkbenchWindow wbw, int style, String id) {
273
		this(wbw);
274
		this.style = style;
275
		this.id = id;
276
	}
277
278
	/**
283
     * Returns the platform's idea of where the fast view bar should be docked in a fresh
279
     * 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
280
     * 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
281
     * 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'
413
        // Create a toolbar to show an 'Add FastView' menu 'button'
418
        menuTB = new ToolBar(fvbComposite, SWT.FLAT | orientation);
414
        menuTB = new ToolBar(fvbComposite, SWT.FLAT | orientation);
419
415
420
        // Construct an item to act as a 'menu button' (a la the PerspectiveSwitcher)
416
        if (testStyleBit(SHOW_ADD_BUTTON)) {
421
        menuItem = new  ToolItem(menuTB, SWT.PUSH, 0);
417
	        // Construct an item to act as a 'menu button' (a la the PerspectiveSwitcher)
418
	        showItem = new  ToolItem(menuTB, SWT.PUSH, 0);
419
	        
420
	        Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_FASTVIEW);
421
	        showItem.setImage(tbImage);
422
	        
423
	        String menuTip = WorkbenchMessages.FastViewBar_0;
424
	        showItem.setToolTipText(menuTip);
425
	        
426
	        // Bring up the 'Add Fast View' menu on a left -or- right button click
427
	        // Right click (context menu)
428
	        showItem.addListener(SWT.MenuDetect, addMenuListener);        
429
	        
430
	        // Left Click...
431
	        showItem.addSelectionListener(new SelectionListener() {
432
				public void widgetSelected(SelectionEvent e) {
433
					Rectangle bb = DragUtil.getDisplayBounds(menuTB);
434
					showAddFastViewPopup(new Point(bb.x,bb.y+bb.height));
435
				}
436
437
				public void widgetDefaultSelected(SelectionEvent e) {
438
				}
439
	        	
440
	        });
441
        }
422
        
442
        
423
        Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_FASTVIEW);
443
        if (testStyleBit(SHOW_GROUP_BUTTON)) {
424
        menuItem.setImage(tbImage);
444
        	groupBtn = new FastGroupTrimButton(menuTB, this);
445
        	groupBtn.setSize(20);
446
        	groupItem = new ToolItem(menuTB, SWT.SEPARATOR, 0);
447
        	groupItem.setControl(groupBtn.getControl());
448
        	groupItem.setWidth(20);
449
        	
450
        }
425
        
451
        
426
        String menuTip = WorkbenchMessages.FastViewBar_0;
427
        menuItem.setToolTipText(menuTip);
428
        //new ToolItem(menuTB, SWT.SEPARATOR, 1);
452
        //new ToolItem(menuTB, SWT.SEPARATOR, 1);
429
        
453
430
        // Now that the ToolBar is populated calculate its size...
454
        // Now that the ToolBar is populated calculate its size...
431
        Point size = menuTB.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
455
        Point size = menuTB.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
432
        menuTB.setBounds(0, 0, size.x, size.y);
456
        menuTB.setBounds(0, 0, size.x, size.y);
433
        
457
        
434
        // Bring up the 'Add Fast View' menu on a left -or- right button click
458
        // Bring up the 'Add Fast View' menu on a left -or- right button click
435
        // Right click (context menu)
459
        // Right click (context menu)
436
        menuItem.addListener(SWT.MenuDetect, addMenuListener);        
437
        menuTB.addListener(SWT.MenuDetect, addMenuListener);
460
        menuTB.addListener(SWT.MenuDetect, addMenuListener);
438
        
461
        
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...
462
        // try to get the layout correct...
452
        toolBarData = new CellData();
463
        toolBarData = new CellData();
453
        toolBarData.align(SWT.FILL, SWT.FILL);
464
        toolBarData.align(SWT.FILL, SWT.FILL);
Lines 455-461 Link Here
455
466
456
        // Construct the ToolBar containing the 'Fast' views
467
        // Construct the ToolBar containing the 'Fast' views
457
        fastViewBar = new ToolBarManager(SWT.FLAT | SWT.WRAP | orientation);
468
        fastViewBar = new ToolBarManager(SWT.FLAT | SWT.WRAP | orientation);
458
        fastViewBar.add(new ShowFastViewContribution(window));
469
        fastViewBar.add(new ShowFastViewContribution(this, window));
459
470
460
        fastViewBar.createControl(fvbComposite);
471
        fastViewBar.createControl(fvbComposite);
461
472
Lines 678-684 Link Here
678
        fastViewBar.dispose();
689
        fastViewBar.dispose();
679
        fastViewBar = null;
690
        fastViewBar = null;
680
        
691
        
681
        menuItem.dispose();
692
        if (showItem != null) {
693
        	showItem.dispose();
694
        	showItem = null;
695
        }
696
        
697
        if (groupItem != null) {
698
        	groupItem.dispose();
699
        	groupItem = null;
700
        }
701
        
682
        menuTB.dispose();
702
        menuTB.dispose();
683
        
703
        
684
        oldLength = 0;
704
        oldLength = 0;
Lines 859-865 Link Here
859
            orientation.putInteger(IWorkbenchConstants.TAG_POSITION,
879
            orientation.putInteger(IWorkbenchConstants.TAG_POSITION,
860
                    ((Integer) viewOrientation.get(next)).intValue());
880
                    ((Integer) viewOrientation.get(next)).intValue());
861
        }
881
        }
862
863
    }
882
    }
864
883
865
    /**
884
    /**
Lines 908-914 Link Here
908
        return window;
927
        return window;
909
    }
928
    }
910
    
929
    
911
    public void restoreView(IViewReference selectedView) {
930
    public void adoptView(IViewReference ref, int insertIndex, boolean makeFast, boolean activate, boolean animate) {
931
        if (ref != null) {
932
            WorkbenchPage page = window.getActiveWorkbenchPage();
933
            if (page != null) {
934
            	// Remember the pane -before- we adopt the view for animations
935
                ViewPane pane = (ViewPane) ((WorkbenchPartReference) ref)
936
                .getPane();
937
            	
938
                if (makeFast)
939
                	page.addFastView(ref);
940
941
                // we -must- have a ref since we're adopting the view
942
                if (!viewRefs.contains(ref))
943
                	addViewRef(ref, insertIndex, true);
944
                
945
                if (activate) {
946
	                IWorkbenchPart toActivate = ref.getPart(true);
947
	                if (toActivate != null) {
948
	                    page.activate(toActivate);
949
	                }
950
                }
951
952
                if (animate && pane != null) {
953
                    int idx = getIndex(ref);
954
                    ToolItem item = getItem(idx);
955
                    Rectangle bounds = item.getBounds();
956
                    Rectangle endBounds = Geometry.toDisplay(item
957
                            .getParent(), bounds);
958
959
	                RectangleAnimation animation = new RectangleAnimation(
960
	                        window.getShell(), pane.getParentBounds(), endBounds);
961
	
962
	                animation.schedule();
963
                }
964
            }
965
        }
966
    }
967
    
968
    public void restoreView(IViewReference selectedView, boolean activate, boolean animate) {
912
        if (selectedView != null) {
969
        if (selectedView != null) {
913
            WorkbenchPage page = window.getActiveWorkbenchPage();
970
            WorkbenchPage page = window.getActiveWorkbenchPage();
914
            if (page != null) {
971
            if (page != null) {
Lines 919-939 Link Here
919
                        .getParent(), bounds);
976
                        .getParent(), bounds);
920
977
921
                page.removeFastView(selectedView);
978
                page.removeFastView(selectedView);
922
979
                
923
                IWorkbenchPart toActivate = selectedView
980
                if (activate) {
924
                        .getPart(true);
981
	                IWorkbenchPart toActivate = selectedView
925
                if (toActivate != null) {
982
	                        .getPart(true);
926
                    page.activate(toActivate);
983
	                if (toActivate != null) {
984
	                    page.activate(toActivate);
985
	                }
927
                }
986
                }
928
987
929
                ViewPane pane = (ViewPane) ((WorkbenchPartReference) selectedView)
988
                ViewPane pane = (ViewPane) ((WorkbenchPartReference) selectedView)
930
                        .getPane();
989
                        .getPane();
931
990
932
                RectangleAnimation animation = new RectangleAnimation(
991
                if (animate) {
933
                        window.getShell(), startBounds, pane
992
	                RectangleAnimation animation = new RectangleAnimation(
934
                                .getParentBounds());
993
	                        window.getShell(), startBounds, pane
935
994
	                                .getParentBounds());
936
                animation.schedule();
995
	
996
	                animation.schedule();
997
                }
937
            }
998
            }
938
        }
999
        }
939
    }
1000
    }
Lines 956-962 Link Here
956
	 * @see org.eclipse.ui.internal.IWindowTrim#getId()
1017
	 * @see org.eclipse.ui.internal.IWindowTrim#getId()
957
	 */
1018
	 */
958
	public String getId() {
1019
	public String getId() {
959
		return "org.eclise.ui.internal.FastViewBar"; //$NON-NLS-1$
1020
		return id;
960
	}
1021
	}
961
1022
962
	/* (non-Javadoc)
1023
	/* (non-Javadoc)
Lines 997-1000 Link Here
997
	public boolean isResizeable() {
1058
	public boolean isResizeable() {
998
		return false;
1059
		return false;
999
	}
1060
	}
1061
1062
	/**
1063
	 * @return Returns the viewRefs.
1064
	 */
1065
	public List getViewRefs() {
1066
		return viewRefs;
1067
	}
1068
1069
	/**
1070
	 * @param viewRefs The viewRefs to set.
1071
	 */
1072
	public void setViewRefs(List viewRefs) {
1073
		this.viewRefs = new ArrayList(viewRefs);
1074
        fastViewBar.markDirty();
1075
        update(true);
1076
	}
1077
	
1078
	/**
1079
	 * Add a new view reference into the list
1080
	 * @param ref The reference to add
1081
	 * @param insertIndex The index to insert it at
1082
	 * @param update 
1083
	 */
1084
	public void addViewRef(IViewReference ref, int insertIndex, boolean update) {
1085
		if (ref == null)
1086
			return;
1087
		
1088
		viewRefs.remove(ref);
1089
		if (insertIndex < 0 || insertIndex >= viewRefs.size())
1090
			viewRefs.add(ref);
1091
		else
1092
			viewRefs.add(insertIndex, ref);
1093
		
1094
		if (update) {
1095
	        fastViewBar.markDirty();
1096
	        update(true);
1097
		}
1098
	}
1099
	
1100
	/**
1101
	 * Remove a reference from the list
1102
	 * @param ref The view reference to remove
1103
	 */
1104
	public void removeViewRef(IViewReference ref) {
1105
		if (ref == null)
1106
			return;
1107
		
1108
		viewRefs.remove(ref);
1109
        
1110
        // Remove the ToolItem associated with the reference
1111
        ToolItem item = ShowFastViewContribution.getItem(fastViewBar.getControl(), ref);        
1112
        if (item != null) {
1113
            item.dispose();
1114
            updateLayoutData();
1115
            update(true);
1116
        }
1117
	}
1118
1119
	/**
1120
	 * Deteremine if this fast view contains the given reference
1121
	 * @param ref The reference to check
1122
	 * @return <code>true</code> iff this FVB contains the reference
1123
	 */
1124
	public boolean hasViewRef(IViewReference ref) {
1125
		return viewRefs.contains(ref);
1126
	}
1127
	
1128
	/**
1129
	 * Restore all refs and close the group
1130
	 */
1131
	public void closeGroup() {
1132
		Perspective persp = window.getActiveWorkbenchPage().getActivePerspective();
1133
		persp.closeTrimGroup(this);
1134
	}
1135
1136
	/**
1137
	 * Move all referenced views to the trim (ie. make
1138
	 * them fast views...)
1139
	 */
1140
	public void collapseGroup() {
1141
		for (Iterator refIter = viewRefs.iterator(); refIter.hasNext();) {
1142
			IViewReference ref = (IViewReference) refIter.next();
1143
			adoptView(ref, -1, true, false, !refIter.hasNext());
1144
		}
1145
		
1146
		update(false);
1147
	}
1148
1149
	/**
1150
	 * Restore all referenced views to the layout
1151
	 */
1152
	public void restoreGroup() {
1153
		for (Iterator refIter = viewRefs.iterator(); refIter.hasNext();) {
1154
			IViewReference ref = (IViewReference) refIter.next();
1155
			restoreView(ref, false, !refIter.hasNext());
1156
		}
1157
		
1158
		update(false);
1159
	}
1000
}
1160
}
1161
(-)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/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 (+97 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
        String enabled  = System.getProperty("MultiFVB"); //$NON-NLS-1$
82
        if (enabled == null)
83
        	return false;
84
        
85
        return getWorkbenchWindow().getShowFastViewBars() && viewPane != null
86
                && site.isPartMoveable(viewPane);
87
    }
88
    
89
    public void dispose() {
90
        viewPane = null;
91
    }
92
93
    public void run() {
94
        Perspective psp = viewPane.getPane().getPage().getActivePerspective();
95
        psp.moveToTrim((ViewStack) viewPane.getPane().getStack());
96
    }
97
}
(-)Eclipse (+269 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;
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
/**
28
 * Implements the 'group' handling for trim groups
29
 * 
30
 * @since 3.2
31
 *
32
 */
33
public class FastGroupTrimButton {
34
	private Canvas button;
35
	private FastViewBar fvb;
36
	private int side;
37
	private Color btnColor;
38
	
39
	private Rectangle closeRect;
40
	private Rectangle restoreRect;
41
	private Rectangle collapseRect;
42
43
	private static final int CTRL_AREA_NONE = 0;
44
	private static final int CTRL_AREA_CLOSE = 1;
45
	private static final int CTRL_AREA_RESTORE = 2;
46
	private static final int CTRL_AREA_COLLAPSE = 3;
47
	
48
	private int curCtrlArea = CTRL_AREA_NONE;
49
	private boolean inControl = false;
50
	private String toolTip;
51
	
52
	public FastGroupTrimButton(Composite parent, FastViewBar fvb) {
53
		this.fvb = fvb;
54
		
55
		if (fvb != null)
56
			side = fvb.getSide();
57
		else
58
			side = SWT.BOTTOM;
59
		
60
		btnColor = parent.getDisplay().getSystemColor(SWT.COLOR_BLACK);
61
		
62
		button = new Canvas(parent, SWT.NONE);
63
		button.addPaintListener(new PaintListener() {
64
			public void paintControl(PaintEvent e) {
65
				e.gc.setForeground(btnColor);
66
				paintButtons(e);
67
			}
68
		});
69
		
70
		button.addMouseTrackListener(new MouseTrackListener() {
71
			public void mouseEnter(MouseEvent e) {
72
				inControl = true;
73
				// Provide 'track' feedback?
74
			}
75
			public void mouseExit(MouseEvent e) {
76
				inControl = false;
77
				// remove 'track' feedback?
78
			}
79
			public void mouseHover(MouseEvent e) {
80
				button.setToolTipText(toolTip);
81
			}			
82
		});
83
		
84
		button.addMouseMoveListener(new MouseMoveListener() {
85
			public void mouseMove(MouseEvent e) {
86
				if (closeRect.contains(e.x,e.y)) {
87
					curCtrlArea = CTRL_AREA_CLOSE;
88
					toolTip = "Close Group"; //$NON-NLS-1$
89
				}
90
				else if (restoreRect.contains(e.x,e.y)) {
91
					curCtrlArea = CTRL_AREA_RESTORE;
92
					toolTip = "Restore Group"; //$NON-NLS-1$
93
				}
94
				else if (collapseRect.contains(e.x,e.y)) {
95
					curCtrlArea = CTRL_AREA_COLLAPSE;
96
					toolTip = "Collapse Group"; //$NON-NLS-1$
97
				}
98
				else
99
					curCtrlArea = CTRL_AREA_NONE;
100
			}
101
		});
102
		button.addMouseListener(new MouseListener() {
103
			public void mouseDoubleClick(MouseEvent e) {}
104
			public void mouseUp(MouseEvent e) {}
105
			public void mouseDown(MouseEvent e) {
106
				if (inControl && curCtrlArea != CTRL_AREA_NONE) {
107
					switch (curCtrlArea) {
108
					case CTRL_AREA_CLOSE:
109
						FastGroupTrimButton.this.fvb.closeGroup();
110
						break;
111
					case CTRL_AREA_COLLAPSE:
112
						FastGroupTrimButton.this.fvb.collapseGroup();
113
						break;
114
					case CTRL_AREA_RESTORE:
115
						FastGroupTrimButton.this.fvb.restoreGroup();
116
						break;
117
					}
118
				}
119
			}			
120
		});
121
	}
122
123
	public void setSize(int size) {
124
		button.setSize(size, size);
125
	}
126
	
127
	protected void paintButtons(PaintEvent e) {
128
		Rectangle bb = button.getBounds();
129
		setButtonRects(bb);
130
		
131
		paintClose(e.gc);
132
		paintRestore(e.gc);
133
		paintCollapse(e.gc);
134
	}
135
136
	private void paintCollapse(GC gc) {
137
		switch(side) {
138
		case SWT.BOTTOM:
139
			drawDownArrow(gc, collapseRect);
140
			break;
141
		case SWT.TOP:
142
			drawUpArrow(gc, collapseRect);
143
			break;
144
		case SWT.LEFT:
145
			drawLeftArrow(gc, collapseRect);
146
			break;
147
		case SWT.RIGHT:
148
			drawRightArrow(gc, collapseRect);
149
			break;
150
		}
151
	}
152
153
	private void paintRestore(GC gc) {
154
		switch(side) {
155
		case SWT.BOTTOM:
156
			drawUpArrow(gc, restoreRect);
157
			break;
158
		case SWT.TOP:
159
			drawDownArrow(gc, restoreRect);
160
			break;
161
		case SWT.LEFT:
162
			drawRightArrow(gc, restoreRect);
163
			break;
164
		case SWT.RIGHT:
165
			drawLeftArrow(gc, restoreRect);
166
			break;
167
		}
168
	}
169
170
	private void paintClose(GC gc) {
171
		int border = 2;
172
		gc.drawLine(closeRect.x+border, closeRect.y+border, (closeRect.x+closeRect.width)-border, (closeRect.y+closeRect.height)-border);
173
		gc.drawLine((closeRect.x+closeRect.width)-border, closeRect.y+border, closeRect.x+border, (closeRect.y+closeRect.height)-border);
174
//		int minX = closeRect.x + 2;
175
//		int maxX = (closeRect.x+closeRect.width) - 2;
176
//		int stopMax = maxX;
177
//		int y = (closeRect.y + (closeRect.height)/2) - ((maxX-minX)/2);
178
//
179
//		while (minX <= stopMax) {
180
//			gc.drawLine(minX, y, minX, y);
181
//			gc.drawLine(maxX, y, maxX, y);
182
//			minX++; maxX--; y++;
183
//		}
184
	}
185
186
	private void drawDownArrow(GC gc, Rectangle rect) {
187
		int y = rect.y + 1;
188
		int minX = rect.x + 2;
189
		int maxX = (rect.x+rect.width) - 2;
190
		
191
		while (minX <= maxX) {
192
			gc.drawLine(minX, y, maxX, y);
193
			y++;
194
			gc.drawLine(minX, y, maxX, y);
195
			minX++; maxX--; y++;
196
		}
197
	}
198
199
	private void drawRightArrow(GC gc, Rectangle rect) {
200
		int x = rect.x + 1;
201
		int minY = rect.y + 2;
202
		int maxY = (rect.y+rect.height) - 2;
203
		
204
		while (minY <= maxY) {
205
			gc.drawLine(x, minY, x, maxY);
206
			x++;
207
			gc.drawLine(x, minY, x, maxY);
208
			minY++; maxY--; x++;
209
		}
210
	}
211
212
	private void drawUpArrow(GC gc, Rectangle rect) {
213
		int y = (rect.y+rect.height) - 1;
214
		int minX = rect.x + 2;
215
		int maxX = (rect.x+rect.width) - 2;
216
		
217
		while (minX <= maxX) {
218
			gc.drawLine(minX, y, maxX, y);
219
			y--;
220
			gc.drawLine(minX, y, maxX, y);
221
			minX++; maxX--; y--;
222
		}
223
	}
224
225
	private void drawLeftArrow(GC gc, Rectangle rect) {
226
		int x = (rect.x+rect.width) - 1;
227
		int minY = rect.y + 2;
228
		int maxY = (rect.y+rect.height) - 2;
229
		
230
		while (minY <= maxY) {
231
			gc.drawLine(x, minY, x, maxY);
232
			x--;
233
			gc.drawLine(x, minY, x, maxY);
234
			minY++; maxY--; x--;
235
		}
236
	}
237
238
	private void setButtonRects(Rectangle bb) {
239
		int hw = bb.width/2;
240
		int hh = bb.height/2;
241
242
		switch (side) {
243
		case SWT.BOTTOM:
244
			closeRect = new Rectangle(bb.x, bb.y+(bb.height/4), hw, hh);
245
			restoreRect = new Rectangle(bb.x+hw, bb.y, hw, hh);
246
			collapseRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh);
247
			break;
248
		case SWT.TOP:
249
			closeRect = new Rectangle(bb.x, bb.y+(bb.height/4), hw, hh);
250
			collapseRect = new Rectangle(bb.x+hw, bb.y, hw, hh);
251
			restoreRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh);
252
			break;
253
		case SWT.LEFT:
254
			closeRect = new Rectangle(bb.x+(bb.width/4), bb.y, hw, hh);
255
			collapseRect = new Rectangle(bb.x, bb.y+hh, hw, hh);
256
			restoreRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh);
257
			break;
258
		case SWT.RIGHT:
259
			closeRect = new Rectangle(bb.x+(bb.width/4), bb.y, hw, hh);
260
			restoreRect = new Rectangle(bb.x, bb.y+hh, hw, hh);
261
			collapseRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh);
262
			break;
263
		}
264
	}
265
266
	public Control getControl() {
267
		return button;
268
	}
269
}

Return to bug 153957