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/EditorSashContainer.java (-1 / +63 lines)
Lines 25-30 Link Here
25
import org.eclipse.swt.widgets.Control;
25
import org.eclipse.swt.widgets.Control;
26
import org.eclipse.ui.IMemento;
26
import org.eclipse.ui.IMemento;
27
import org.eclipse.ui.PlatformUI;
27
import org.eclipse.ui.PlatformUI;
28
import org.eclipse.ui.internal.layout.ITrimManager;
28
import org.eclipse.ui.internal.presentations.PresentationSerializer;
29
import org.eclipse.ui.internal.presentations.PresentationSerializer;
29
import org.eclipse.ui.presentations.StackPresentation;
30
import org.eclipse.ui.presentations.StackPresentation;
30
31
Lines 307-313 Link Here
307
            }
308
            }
308
            mapIDtoPart.put(partID, workbook);
309
            mapIDtoPart.put(partID, workbook);
309
        }
310
        }
310
        return result;
311
312
        // Trim Stack Support
313
    	Integer trimState = memento.getInteger(IWorkbenchConstants.TAG_PART_TRIMSTATE);
314
    	if (trimState != null && trimState.intValue() != LayoutPart.TRIMSTATE_NORMAL)
315
    		setTrimState(trimState.intValue());
316
317
    	return result;
311
    }
318
    }
312
319
313
    /**
320
    /**
Lines 353-358 Link Here
353
                        .getRatio());
360
                        .getRatio());
354
            }
361
            }
355
        }
362
        }
363
        
364
        // Trim Stack Support
365
        if (getTrimState() != LayoutPart.TRIMSTATE_NORMAL)
366
        	memento.putInteger(IWorkbenchConstants.TAG_PART_TRIMSTATE, getTrimState());
367
        
356
        return result;
368
        return result;
357
    }
369
    }
358
370
Lines 531-534 Link Here
531
        }
543
        }
532
        return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
544
        return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
533
    }
545
    }
546
    
547
    // Trim Stack Support
548
	public void setTrimState(int newTrimState) {
549
    	if (newTrimState == getTrimState())
550
    		return;
551
552
    	// Remember the new state
553
    	int oldTrimState = getTrimState();
554
    	
555
    	// set the new one
556
    	super.setTrimState(newTrimState);
557
558
		WorkbenchWindow wbw = (WorkbenchWindow) getWorkbenchWindow();
559
		if (wbw == null)
560
			return;
561
		
562
		// Access workbench context
563
        Perspective persp = page.getActivePerspective();
564
    	ITrimManager tbm = wbw.getTrimManager();
565
    	EditorAreaTrimPart viewStackTrim = (EditorAreaTrimPart) tbm.getTrim(getID());
566
		
567
    	// NOTE: The part visibility is handled by the Perspective
568
		// for legacy reasons. All this does is show/hide the trim...
569
		    	
570
    	// Are we moving the View Stack -to- the trim?
571
    	if (oldTrimState == LayoutPart.TRIMSTATE_NORMAL) {    		
572
        	// Is it already in the trim?
573
        	if (viewStackTrim == null) {
574
        		// If it's not already in the trim...create it
575
        		int side = SWT.BOTTOM;
576
        		if (persp != null)
577
        			side = persp.calcStackSide(getBounds());
578
        		
579
        		viewStackTrim = new EditorAreaTrimPart(wbw, this);
580
    	    	viewStackTrim.dock(side);
581
        		tbm.addTrim(side, viewStackTrim);
582
        	}
583
        	
584
    		tbm.setTrimVisible(viewStackTrim, true);
585
    	}
586
    	
587
    	// Are we restoring the View Stack -from- the trim?
588
    	if (newTrimState == LayoutPart.TRIMSTATE_NORMAL) {
589
    		if (viewStackTrim == null)
590
    			return;
591
    		
592
        	// hide the trim widget
593
        	tbm.setTrimVisible(viewStackTrim, false);
594
    	}
595
    }
534
}
596
}
(-)Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java (+2 lines)
Lines 118-123 Link Here
118
118
119
    public static final String TAG_PART_NAME = "partName"; //$NON-NLS-1$
119
    public static final String TAG_PART_NAME = "partName"; //$NON-NLS-1$
120
120
121
    public static final String TAG_PART_TRIMSTATE = "inTrim"; //$NON-NLS-1$
122
121
    public static final String TAG_RELATIVE = "relative"; //$NON-NLS-1$
123
    public static final String TAG_RELATIVE = "relative"; //$NON-NLS-1$
122
124
123
    public static final String TAG_RELATIONSHIP = "relationship"; //$NON-NLS-1$
125
    public static final String TAG_RELATIONSHIP = "relationship"; //$NON-NLS-1$
(-)Eclipse UI/org/eclipse/ui/internal/ViewSashContainer.java (-1 / +69 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal;
11
package org.eclipse.ui.internal;
12
12
13
import java.util.ArrayList;
13
import java.util.HashMap;
14
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.List;
14
import java.util.Map;
17
import java.util.Map;
15
18
16
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.IStatus;
Lines 19-24 Link Here
19
import org.eclipse.swt.widgets.Control;
22
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.ui.IMemento;
23
import org.eclipse.ui.IMemento;
21
import org.eclipse.ui.PlatformUI;
24
import org.eclipse.ui.PlatformUI;
25
import org.eclipse.ui.internal.layout.ITrimManager;
26
import org.eclipse.ui.internal.layout.IWindowTrim;
22
27
23
/**
28
/**
24
 * Represents the top level container.
29
 * Represents the top level container.
Lines 197-205 Link Here
197
				}
202
				}
198
            }
203
            }
199
204
200
            // If this is a folder save the contents.
205
            // If this is a folder (ViewStack) save the contents.
201
            if (folder != null) {
206
            if (folder != null) {
202
                childMem.putString(IWorkbenchConstants.TAG_FOLDER, "true");//$NON-NLS-1$
207
                childMem.putString(IWorkbenchConstants.TAG_FOLDER, "true");//$NON-NLS-1$
208
                
203
                IMemento folderMem = childMem
209
                IMemento folderMem = childMem
204
                        .createChild(IWorkbenchConstants.TAG_FOLDER);
210
                        .createChild(IWorkbenchConstants.TAG_FOLDER);
205
                result.add(folder.saveState(folderMem));
211
                result.add(folder.saveState(folderMem));
Lines 304-307 Link Here
304
310
305
        super.replace(oldChild, newChild);
311
        super.replace(oldChild, newChild);
306
    }
312
    }
313
314
	// Trim Stack Support
315
	
316
	/**
317
	 * Restore any parts that are in the trim due
318
	 * to a zoom (maximize) operation
319
	 */
320
	public boolean restoreZoomedTrimParts() {
321
		boolean needsLayout = false;
322
    	LayoutPart[] children = getChildren();
323
    	for (int i = 0; i < children.length; i++) {
324
			if (children[i].getTrimState() == LayoutPart.TRIMSTATE_ZOOMEDTOTRIM) {
325
				// All parts in the trim must have placeholders
326
				if (children[i] instanceof PartPlaceholder) {
327
					// restore the part from the trim
328
					PartPlaceholder ph = (PartPlaceholder) children[i];
329
					ph.setTrimState(LayoutPart.TRIMSTATE_NORMAL);
330
					needsLayout = true;
331
				}
332
			}
333
    	}
334
    	
335
    	return needsLayout;
336
	}
337
338
	/**
339
	 * @return A list containibg all trim representing a LayoutPart
340
	 */
341
	public List getTrimForParts() {
342
		List trim = new ArrayList();
343
344
		// If a part is in the trim then get the trim element using the part's
345
		// id
346
		WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow();
347
		ITrimManager tbm = wbw.getTrimManager();
348
		LayoutPart[] children = getChildren();
349
		for (int i = 0; i < children.length; i++) {
350
			if (children[i].getTrimState() == LayoutPart.TRIMSTATE_IN_TRIM
351
					|| children[i].getTrimState() == LayoutPart.TRIMSTATE_ZOOMEDTOTRIM) {
352
				IWindowTrim partTrim = tbm.getTrim(children[i].getID());
353
				if (partTrim != null)
354
					trim.add(partTrim);
355
			}
356
		}
357
358
		return trim;
359
	}
360
	
361
	/**
362
	 * Show any trim representing parts of this layout
363
	 * @param visible true to show the trim, false to hide it
364
	 */
365
	public void setTrimVisible(boolean visible) {
366
		List partTrim = getTrimForParts();
367
		WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow();
368
		ITrimManager tbm = wbw.getTrimManager();
369
		for (Iterator trimPartIter = partTrim.iterator(); trimPartIter
370
				.hasNext();) {
371
			IWindowTrim trimForPart = (IWindowTrim) trimPartIter.next();
372
			tbm.setTrimVisible(trimForPart, visible);
373
		}
374
	}
307
}
375
}
(-)Eclipse UI/org/eclipse/ui/internal/LayoutPart.java (+36 lines)
Lines 34-39 Link Here
34
34
35
    public static final String PROP_VISIBILITY = "PROP_VISIBILITY"; //$NON-NLS-1$
35
    public static final String PROP_VISIBILITY = "PROP_VISIBILITY"; //$NON-NLS-1$
36
36
37
    // Trim Stack Support
38
    public final static int TRIMSTATE_NORMAL = 0;		// 'normal'...in the presentation
39
    public final static int TRIMSTATE_IN_TRIM = 1;		// 'minimized'...in the trim but wont restore on an unzoom
40
    public final static int TRIMSTATE_ZOOMEDTOTRIM = 2;	// 'zoomed'...in the trim as a result of a 'zoom' on some other part
41
    
42
    protected int trimState = TRIMSTATE_NORMAL;
43
    
37
    /**
44
    /**
38
     * Number of times deferUpdates(true) has been called without a corresponding
45
     * Number of times deferUpdates(true) has been called without a corresponding
39
     * deferUpdates(false)
46
     * deferUpdates(false)
Lines 485-488 Link Here
485
     */
492
     */
486
    public void testInvariants() {
493
    public void testInvariants() {
487
    }
494
    }
495
496
	// Trim Stack Support
497
	
498
	/**
499
	 * @return Returns the trimState.
500
	 */
501
	public int getTrimState() {
502
		return trimState;
503
	}
504
505
	/**
506
	 * @param trimState The trimState to set.
507
	 */
508
	public void setTrimState(int trimState) {
509
		this.trimState = trimState;
510
	}
511
512
	/**
513
	 * Causes a layout part to refresh its state.
514
	 * This is called by the Perspective to cause
515
	 * any necessary trim to be constructed on activation 
516
	 */
517
	public void createInitialTrim() {
518
		if (trimState != LayoutPart.TRIMSTATE_NORMAL) {
519
	    	int curState = getTrimState();
520
	    	trimState = LayoutPart.TRIMSTATE_NORMAL;
521
	    	setTrimState(curState);
522
		}
523
	}
488
}
524
}
(-)Eclipse UI/org/eclipse/ui/internal/IWorkbenchGraphicConstants.java (-2 / +4 lines)
Lines 53-62 Link Here
53
    
53
    
54
    //Fast view enabled and disabled icons
54
    //Fast view enabled and disabled icons
55
    public final static String IMG_ETOOL_NEW_FASTVIEW = "IMG_ETOOL_NEW_FASTVIEW"; //$NON-NLS-1$
55
    public final static String IMG_ETOOL_NEW_FASTVIEW = "IMG_ETOOL_NEW_FASTVIEW"; //$NON-NLS-1$
56
    public final static String IMG_ETOOL_RESTORE_FASTVIEW = "IMG_ETOOL_RESTORE_FASTVIEW"; //$NON-NLS-1$
57
    
58
    public final static String IMG_DTOOL_NEW_FASTVIEW = "IMG_DTOOL_NEW_FASTVIEW"; //$NON-NLS-1$
56
    public final static String IMG_DTOOL_NEW_FASTVIEW = "IMG_DTOOL_NEW_FASTVIEW"; //$NON-NLS-1$
59
57
58
    // TrimStack buttons
59
    public final static String IMG_ETOOL_RESTORE_TRIMPART = "IMG_ETOOL_RESTORE_TRIMPART"; //$NON-NLS-1$
60
    public final static String IMG_ETOOL_EDITOR_TRIMPART = "IMG_ETOOL_EDITOR_TRIMPART"; //$NON-NLS-1$
61
    
60
    // local toolbars
62
    // local toolbars
61
    
63
    
62
    public final static String IMG_LCL_CLOSE_VIEW = "IMG_LCL_CLOSE_VIEW"; //$NON-NLS-1$
64
    public final static String IMG_LCL_CLOSE_VIEW = "IMG_LCL_CLOSE_VIEW"; //$NON-NLS-1$
(-)Eclipse UI/org/eclipse/ui/internal/PartStack.java (-1 / +23 lines)
Lines 908-913 Link Here
908
        String activeTabID = memento
908
        String activeTabID = memento
909
                .getString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID);
909
                .getString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID);
910
910
911
        // Trim Stack Support
912
    	Integer trimState = memento.getInteger(IWorkbenchConstants.TAG_PART_TRIMSTATE);
913
    	if (trimState != null && trimState.intValue() != LayoutPart.TRIMSTATE_NORMAL)
914
    		setTrimState(trimState.intValue());
915
        
911
        // Read the page elements.
916
        // Read the page elements.
912
        IMemento[] children = memento.getChildren(IWorkbenchConstants.TAG_PAGE);
917
        IMemento[] children = memento.getChildren(IWorkbenchConstants.TAG_PAGE);
913
        if (children != null) {
918
        if (children != null) {
Lines 1011-1016 Link Here
1011
			memento.putString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID, requestedCurrent
1016
			memento.putString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID, requestedCurrent
1012
                    .getCompoundId());
1017
                    .getCompoundId());
1013
		}
1018
		}
1019
        
1020
        // Trim Stack Support
1021
        if (getTrimState() != LayoutPart.TRIMSTATE_NORMAL)
1022
        	memento.putInteger(IWorkbenchConstants.TAG_PART_TRIMSTATE, getTrimState());
1014
1023
1015
        Iterator iter = children.iterator();
1024
        Iterator iter = children.iterator();
1016
        while (iter.hasNext()) {
1025
        while (iter.hasNext()) {
Lines 1171-1177 Link Here
1171
    		// Make a one element list to pass on
1180
    		// Make a one element list to pass on
1172
    		List stacks = new ArrayList();
1181
    		List stacks = new ArrayList();
1173
    		stacks.add(this);
1182
    		stacks.add(this);
1174
    		persp.moveToTrim(stacks, FastViewBar.GROUP_FVB);
1183
    		persp.movePartsToTrim(stacks, false);
1175
    		return;
1184
    		return;
1176
    	}
1185
    	}
1177
    	
1186
    	
Lines 1485-1488 Link Here
1485
            ((IPropertyListener) listeners[i]).propertyChanged(this, id);
1494
            ((IPropertyListener) listeners[i]).propertyChanged(this, id);
1486
        }
1495
        }
1487
    }
1496
    }
1497
    
1498
    // TrimStack Support
1499
    
1500
    /**
1501
     * Explicitly sets the presentation state. This is used by the
1502
     * new min/max code to force the CTabFolder to show the proper
1503
     * state without going through the 'setState' code (which causes
1504
     * nasty side-effects.
1505
     * @param newState The state to set the presentation to
1506
     */
1507
    public void setPresentationState(int newState) {
1508
    	presentationSite.setPresentationState(newState);
1509
    }
1488
}
1510
}
(-)Eclipse UI/org/eclipse/ui/internal/FastViewBar.java (-7 / +5 lines)
Lines 182-191 Link Here
182
                ViewPane pane = (ViewPane) iter.next();
182
                ViewPane pane = (ViewPane) iter.next();
183
                IViewReference ref = pane.getViewReference();
183
                IViewReference ref = pane.getViewReference();
184
                
184
                
185
                // Only allow one reference in an FVB per perspective
185
                // Drop only occurs on the global fast view bar
186
                FastViewBar curFVB = getPage().getActivePerspective().getFVBForRef(ref);
186
                FastViewBar curFVB = window.getFastViewBar();
187
                if (curFVB == null && window.getFastViewBar().hasViewRef(ref))
188
                	curFVB = window.getFastViewBar();
189
                	
187
                	
190
                if (curFVB != null) {
188
                if (curFVB != null) {
191
                	curFVB.removeViewRef(ref);
189
                	curFVB.removeViewRef(ref);
Lines 483-489 Link Here
483
	        // Construct an item to act as a 'menu button' (a la the PerspectiveSwitcher)
481
	        // Construct an item to act as a 'menu button' (a la the PerspectiveSwitcher)
484
	        restoreItem = new  ToolItem(menuTB, SWT.PUSH, 0);
482
	        restoreItem = new  ToolItem(menuTB, SWT.PUSH, 0);
485
	        
483
	        
486
	        Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_FASTVIEW);
484
	        Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_TRIMPART);
487
	        restoreItem.setImage(tbImage);
485
	        restoreItem.setImage(tbImage);
488
	        
486
	        
489
	        String menuTip = WorkbenchMessages.StandardSystemToolbar_Restore;
487
	        String menuTip = WorkbenchMessages.StandardSystemToolbar_Restore;
Lines 1160-1167 Link Here
1160
	 * Restore all refs and close the group
1158
	 * Restore all refs and close the group
1161
	 */
1159
	 */
1162
	public void closeGroup() {
1160
	public void closeGroup() {
1163
		Perspective persp = window.getActiveWorkbenchPage().getActivePerspective();
1161
//		Perspective persp = window.getActiveWorkbenchPage().getActivePerspective();
1164
		persp.closeTrimGroup(this);
1162
//		persp.closeTrimGroup(this);
1165
	}
1163
	}
1166
1164
1167
	/**
1165
	/**
(-)Eclipse UI/org/eclipse/ui/internal/ContainerPlaceholder.java (+18 lines)
Lines 149-152 Link Here
149
    public boolean childIsZoomed(LayoutPart toTest) {
149
    public boolean childIsZoomed(LayoutPart toTest) {
150
        return false;
150
        return false;
151
    }
151
    }
152
    
153
    /* (non-Javadoc)
154
     * @see org.eclipse.ui.internal.LayoutPart#setTrimState(int)
155
     */
156
    public void setTrimState(int newTrimState) {
157
    	if (realContainer != null)
158
    		getRealContainer().setTrimState(newTrimState);
159
    }
160
    
161
    /* (non-Javadoc)
162
     * @see org.eclipse.ui.internal.LayoutPart#getTrimState()
163
     */
164
    public int getTrimState() {
165
    	if (realContainer != null)
166
    		return getRealContainer().getTrimState();
167
    	
168
    	return super.getTrimState();
169
    }
152
}
170
}
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchImages.java (-2 / +5 lines)
Lines 225-235 Link Here
225
225
226
        declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_FASTVIEW,
226
        declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_FASTVIEW,
227
                PATH_ETOOL + "new_fastview.gif", true); //$NON-NLS-1$
227
                PATH_ETOOL + "new_fastview.gif", true); //$NON-NLS-1$
228
        declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_FASTVIEW,
229
                PATH_ETOOL + "fastview_restore.gif", true); //$NON-NLS-1$
230
        declareImage(IWorkbenchGraphicConstants.IMG_DTOOL_NEW_FASTVIEW,
228
        declareImage(IWorkbenchGraphicConstants.IMG_DTOOL_NEW_FASTVIEW,
231
                PATH_DTOOL + "new_fastview.gif", true); //$NON-NLS-1$
229
                PATH_DTOOL + "new_fastview.gif", true); //$NON-NLS-1$
232
230
231
        declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_TRIMPART,
232
                PATH_ETOOL + "fastview_restore.gif", true); //$NON-NLS-1$
233
        declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_EDITOR_TRIMPART,
234
                PATH_ETOOL + "editor_area.gif", true); //$NON-NLS-1$
235
        
233
        declareImage(ISharedImages.IMG_TOOL_FORWARD, PATH_ELOCALTOOL
236
        declareImage(ISharedImages.IMG_TOOL_FORWARD, PATH_ELOCALTOOL
234
                + "forward_nav.gif", true); //$NON-NLS-1$
237
                + "forward_nav.gif", true); //$NON-NLS-1$
235
        declareImage(ISharedImages.IMG_TOOL_FORWARD_HOVER, PATH_ELOCALTOOL
238
        declareImage(ISharedImages.IMG_TOOL_FORWARD_HOVER, PATH_ELOCALTOOL
(-)Eclipse UI/org/eclipse/ui/internal/FastGroupTrimButton.java (-269 lines)
Removed 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
}
(-)Eclipse UI/org/eclipse/ui/internal/EditorSiteDragAndDropServiceImpl.java (-2 lines)
Lines 24-31 Link Here
24
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.swt.widgets.Control;
25
import org.eclipse.ui.PlatformUI;
25
import org.eclipse.ui.PlatformUI;
26
import org.eclipse.ui.dnd.IDragAndDropService;
26
import org.eclipse.ui.dnd.IDragAndDropService;
27
import org.eclipse.ui.internal.WorkbenchWindow;
28
import org.eclipse.ui.internal.WorkbenchWindowConfigurer;
29
import org.eclipse.ui.services.IDisposable;
27
import org.eclipse.ui.services.IDisposable;
30
28
31
/**
29
/**
(-)Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java (-32 / +42 lines)
Lines 35-40 Link Here
35
import org.eclipse.ui.internal.dnd.IDropTarget;
35
import org.eclipse.ui.internal.dnd.IDropTarget;
36
import org.eclipse.ui.internal.dnd.SwtUtil;
36
import org.eclipse.ui.internal.dnd.SwtUtil;
37
import org.eclipse.ui.internal.util.PrefUtil;
37
import org.eclipse.ui.internal.util.PrefUtil;
38
import org.eclipse.ui.presentations.IStackPresentationSite;
38
39
39
/**
40
/**
40
 * Abstract container that groups various layout
41
 * Abstract container that groups various layout
Lines 57-63 Link Here
57
    private LayoutPart zoomedPart;
58
    private LayoutPart zoomedPart;
58
    
59
    
59
    // 'Smart' zoom
60
    // 'Smart' zoom
60
    private boolean smartZoomed = false;
61
    private LayoutPart smartZoomedPart = null;
61
62
62
    protected WorkbenchPage page;
63
    protected WorkbenchPage page;
63
64
Lines 853-903 Link Here
853
        this.parent.setBounds(r);
854
        this.parent.setBounds(r);
854
    }
855
    }
855
856
856
    private void smartZoomIn(LayoutPart part, Perspective persp) {
857
    private void smartZoomIn(LayoutPart zoomingPart, Perspective persp) {
857
    	// HACK!! since we aren't changing the 'state' maximize always
858
    	// Prevent recursion
858
    	// get called; 'unzoom' if necessary
859
    	if (smartZoomedPart != null)
859
    	if (smartZoomed) {
860
    		return;
860
    		// Restore the editor area if necessary
861
    		persp.showEditorArea();
862
    		
863
    		// Restore (close) and groups created during a zoom
864
            persp.restoreZoomGroups();
865
            
866
            // we're 'unzoomed'
867
            smartZoomed = false;
868
            
869
            // Remember that we need to trigger a layout
870
            layoutDirty = true;
871
872
            return;
873
    	}
874
    	
861
    	
875
    	// 'Smart'(?) zoom...'minimize' all view stacks except the
862
    	// 'Smart'(?) zoom...'minimize' all view stacks except the
876
    	// one we're zooming. If we're zooming the editor then -all-
863
    	// one we're zooming. If we're zooming the editor then -all-
877
    	// view stacks get minimized
864
    	// view stacks get minimized
878
        LayoutPart[] children = getChildren();
865
        LayoutPart[] children = getChildren();
879
        List stacks = new ArrayList();
866
        List trimParts = new ArrayList();
880
        for (int i = 0; i < children.length; i++) {
867
        for (int i = 0; i < children.length; i++) {
881
            LayoutPart child = children[i];
868
            if (children[i] != zoomingPart)
882
    		// Close the editor stack unless it's the 'zooming' part
869
            	trimParts.add(children[i]);
883
    		if (child instanceof EditorSashContainer && child != part) { 
884
    			persp.hideEditorArea();
885
    		}
886
    		else if (child instanceof ViewStack) {
887
    			if (child != part) {
888
    				stacks.add(child);
889
    			}
890
    		}
891
        }
870
        }
892
871
893
        persp.moveToTrim(stacks, FastViewBar.GROUP_FVB | FastViewBar.ZOOM_GROUP);
872
        persp.movePartsToTrim(trimParts, true);
894
        
873
        
895
        // We're -not- really zoomed, don't lie
874
        // We're -not- really zoomed, don't lie
896
        zoomedPart = null;
875
        zoomedPart = null;
897
        
876
        
898
        // ...but we're 'zoomed'
877
        // ...but we're 'zoomed'
899
        smartZoomed = true;
878
        smartZoomedPart = zoomingPart;
900
        
879
        
880
        if (smartZoomedPart instanceof PartStack) {
881
        	((PartStack)smartZoomedPart).setPresentationState(IStackPresentationSite.STATE_MAXIMIZED);
882
        }
883
        // Remember that we need to trigger a layout
884
        layoutDirty = true;
885
    }
886
887
    private void smartZoomOut(Perspective persp) {
888
    	// Prevent recursion
889
    	if (smartZoomedPart == null)
890
    		return;
891
    	
892
        // we're 'unzoomed'
893
    	LayoutPart zoomedPartCache = smartZoomedPart;
894
        smartZoomedPart = null;
895
		
896
		// Restore (close) trim parts created during a zoom
897
        persp.restoreZoomedParts();
898
        
899
        if (zoomedPartCache instanceof PartStack) {
900
        	((PartStack)zoomedPartCache).setPresentationState(IStackPresentationSite.STATE_RESTORED);
901
        }
901
        // Remember that we need to trigger a layout
902
        // Remember that we need to trigger a layout
902
        layoutDirty = true;
903
        layoutDirty = true;
903
    }
904
    }
Lines 1024-1029 Link Here
1024
     * Note: Method assumes we are active.
1025
     * Note: Method assumes we are active.
1025
     */
1026
     */
1026
    private void zoomOut() {
1027
    private void zoomOut() {
1028
        // 'Smart'? Zoom out
1029
		Perspective persp = this.getPage().getActivePerspective();
1030
        IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
1031
        boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
1032
    	if (useNewMinMax) {
1033
    		smartZoomOut(persp);
1034
    		return;
1035
    	}
1036
    	
1027
        // Sanity check.
1037
        // Sanity check.
1028
        if (!isZoomed()) {
1038
        if (!isZoomed()) {
1029
			return;
1039
			return;
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java (-1 / +1 lines)
Lines 567-573 Link Here
567
	public static String StandardSystemToolbar_Maximize;
567
	public static String StandardSystemToolbar_Maximize;
568
	public static String StandardSystemToolbar_Restore;
568
	public static String StandardSystemToolbar_Restore;
569
569
570
	public static String ViewPane_moveToTrim;
570
	public static String EditorArea_Tooltip;
571
	public static String ViewPane_fastView;
571
	public static String ViewPane_fastView;
572
	public static String ViewPane_minimizeView;
572
	public static String ViewPane_minimizeView;
573
	public static String ViewPane_moveView;
573
	public static String ViewPane_moveView;
(-)Eclipse UI/org/eclipse/ui/internal/ViewStack.java (+92 lines)
Lines 12-18 Link Here
12
 *******************************************************************************/
12
 *******************************************************************************/
13
package org.eclipse.ui.internal;
13
package org.eclipse.ui.internal;
14
14
15
import java.util.Iterator;
16
import java.util.List;
17
15
import org.eclipse.jface.action.IMenuManager;
18
import org.eclipse.jface.action.IMenuManager;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.ui.IViewReference;
21
import org.eclipse.ui.internal.layout.ITrimManager;
16
import org.eclipse.ui.internal.presentations.PresentablePart;
22
import org.eclipse.ui.internal.presentations.PresentablePart;
17
import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
23
import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
18
import org.eclipse.ui.internal.presentations.SystemMenuDetach;
24
import org.eclipse.ui.internal.presentations.SystemMenuDetach;
Lines 154-157 Link Here
154
    public StackPresentation getTestPresentation() {
160
    public StackPresentation getTestPresentation() {
155
    	return getPresentation();
161
    	return getPresentation();
156
    }
162
    }
163
164
    
165
    // Trim Stack Support
166
    
167
    public void setTrimState(int newTrimState) {
168
    	if (newTrimState == getTrimState())
169
    		return;
170
171
    	// Remember the new state
172
    	int oldTrimState = getTrimState();
173
    	
174
    	// set the new one
175
    	super.setTrimState(newTrimState);
176
177
		WorkbenchWindow wbw = (WorkbenchWindow) getWorkbenchWindow();
178
		if (wbw == null)
179
			return;
180
		
181
		// Access workbench context
182
        Perspective persp = page.getActivePerspective();
183
    	ITrimManager tbm = wbw.getTrimManager();
184
    	ViewStackTrimPart viewStackTrim = (ViewStackTrimPart) tbm.getTrim(getID());
185
    	
186
    	// Are we moving the View Stack -to- the trim?
187
    	if (oldTrimState == LayoutPart.TRIMSTATE_NORMAL) {
188
        	// Remove the real stack from the presentation
189
        	ContainerPlaceholder ph = null;
190
	        ph = new ContainerPlaceholder(getID());
191
	        ph.setRealContainer(this);
192
	        getContainer().replace(this, ph);
193
	        page.refreshActiveView();
194
195
        	// Is it already in the trim?
196
        	if (viewStackTrim == null) {
197
        		// If it's not already in the trim...create it
198
        		int side = SWT.BOTTOM;
199
        		if (persp != null)
200
        			side = persp.calcStackSide(getBounds());
201
        		
202
        		viewStackTrim = new ViewStackTrimPart(wbw, ph);
203
    	    	viewStackTrim.dock(side);
204
        		tbm.addTrim(side, viewStackTrim);
205
        	}
206
	        
207
        	// Refresh the trim's state and show it
208
        	viewStackTrim.setPlaceholder(ph);
209
        	viewStackTrim.refresh();
210
        	
211
        	// Make the views 'fast'
212
        	if (persp != null) {
213
        		List refs = viewStackTrim.getViewRefs();
214
        		for (Iterator refIter = refs.iterator(); refIter
215
						.hasNext();) {
216
					IViewReference ref = (IViewReference) refIter.next();
217
					persp.addFastViewHack(ref);
218
				}
219
        	}
220
    		tbm.setTrimVisible(viewStackTrim, true);
221
    	}
222
    	
223
    	// Are we restoring the View Stack -from- the trim?
224
    	if (newTrimState == LayoutPart.TRIMSTATE_NORMAL) {
225
    		if (viewStackTrim == null)
226
    			return;
227
        	
228
        	// Make the views un-'fast'
229
        	if (persp != null) {
230
        		List refs = viewStackTrim.getViewRefs();
231
        		for (Iterator refIter = refs.iterator(); refIter
232
						.hasNext();) {
233
					IViewReference ref = (IViewReference) refIter.next();
234
					persp.removeFastViewHack(ref);
235
				}
236
        	}
237
    		
238
        	// hide the trim widget
239
        	tbm.setTrimVisible(viewStackTrim, false);
240
        	
241
        	// Restore the real container
242
        	ContainerPlaceholder ph = viewStackTrim.getPlaceholder();
243
        	ILayoutContainer container = ph.getContainer();
244
        	LayoutPart ps = ph.getRealContainer();
245
    		ph.setRealContainer(null);
246
            container.replace(ph, ps);
247
    	}
248
    }
157
}
249
}
(-)Eclipse UI/org/eclipse/ui/internal/messages.properties (-1 / +1 lines)
Lines 563-569 Link Here
563
StandardSystemToolbar_Maximize = Maximize
563
StandardSystemToolbar_Maximize = Maximize
564
StandardSystemToolbar_Restore = Restore
564
StandardSystemToolbar_Restore = Restore
565
565
566
ViewPane_moveToTrim = &Move to Trim
566
EditorArea_Tooltip = Editor Area
567
ViewPane_fastView = &Fast View
567
ViewPane_fastView = &Fast View
568
ViewPane_minimizeView= Mi&nimize
568
ViewPane_minimizeView= Mi&nimize
569
ViewPane_moveView=&View
569
ViewPane_moveView=&View
(-)Eclipse UI/org/eclipse/ui/internal/Perspective.java (-390 / +391 lines)
Lines 26-33 Link Here
26
import org.eclipse.jface.dialogs.ErrorDialog;
26
import org.eclipse.jface.dialogs.ErrorDialog;
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.jface.util.Geometry;
29
import org.eclipse.osgi.util.NLS;
30
import org.eclipse.osgi.util.NLS;
30
import org.eclipse.swt.SWT;
31
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.graphics.Point;
31
import org.eclipse.swt.graphics.Rectangle;
33
import org.eclipse.swt.graphics.Rectangle;
32
import org.eclipse.swt.widgets.Composite;
34
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.swt.widgets.Control;
35
import org.eclipse.swt.widgets.Control;
Lines 43-48 Link Here
43
import org.eclipse.ui.IViewSite;
45
import org.eclipse.ui.IViewSite;
44
import org.eclipse.ui.IWorkbenchPart;
46
import org.eclipse.ui.IWorkbenchPart;
45
import org.eclipse.ui.IWorkbenchPartReference;
47
import org.eclipse.ui.IWorkbenchPartReference;
48
import org.eclipse.ui.IWorkbenchPreferenceConstants;
46
import org.eclipse.ui.PartInitException;
49
import org.eclipse.ui.PartInitException;
47
import org.eclipse.ui.PlatformUI;
50
import org.eclipse.ui.PlatformUI;
48
import org.eclipse.ui.WorkbenchException;
51
import org.eclipse.ui.WorkbenchException;
Lines 50-57 Link Here
50
import org.eclipse.ui.internal.dnd.DragUtil;
53
import org.eclipse.ui.internal.dnd.DragUtil;
51
import org.eclipse.ui.internal.intro.IIntroConstants;
54
import org.eclipse.ui.internal.intro.IIntroConstants;
52
import org.eclipse.ui.internal.layout.ITrimManager;
55
import org.eclipse.ui.internal.layout.ITrimManager;
56
import org.eclipse.ui.internal.layout.IWindowTrim;
53
import org.eclipse.ui.internal.misc.StatusUtil;
57
import org.eclipse.ui.internal.misc.StatusUtil;
54
import org.eclipse.ui.internal.presentations.PresentablePart;
55
import org.eclipse.ui.internal.registry.ActionSetRegistry;
58
import org.eclipse.ui.internal.registry.ActionSetRegistry;
56
import org.eclipse.ui.internal.registry.IActionSetDescriptor;
59
import org.eclipse.ui.internal.registry.IActionSetDescriptor;
57
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
60
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
Lines 59-64 Link Here
59
import org.eclipse.ui.internal.registry.PerspectiveExtensionReader;
62
import org.eclipse.ui.internal.registry.PerspectiveExtensionReader;
60
import org.eclipse.ui.internal.registry.PerspectiveRegistry;
63
import org.eclipse.ui.internal.registry.PerspectiveRegistry;
61
import org.eclipse.ui.internal.registry.StickyViewDescriptor;
64
import org.eclipse.ui.internal.registry.StickyViewDescriptor;
65
import org.eclipse.ui.internal.util.PrefUtil;
62
import org.eclipse.ui.views.IStickyViewDescriptor;
66
import org.eclipse.ui.views.IStickyViewDescriptor;
63
import org.eclipse.ui.views.IViewDescriptor;
67
import org.eclipse.ui.views.IViewDescriptor;
64
import org.eclipse.ui.views.IViewRegistry;
68
import org.eclipse.ui.views.IViewRegistry;
Lines 88-96 Link Here
88
    private ArrayList perspectiveShortcuts;
92
    private ArrayList perspectiveShortcuts;
89
93
90
    private ArrayList fastViews;
94
    private ArrayList fastViews;
91
    private List globalFastViews;
92
    private boolean globalFVBsaved = false;
93
    private ArrayList fastViewBars;
94
95
95
    private Map mapIDtoViewLayoutRec;
96
    private Map mapIDtoViewLayoutRec;
96
97
Lines 143-176 Link Here
143
        alwaysOnActionSets = new ArrayList(2);
144
        alwaysOnActionSets = new ArrayList(2);
144
        alwaysOffActionSets = new ArrayList(2);
145
        alwaysOffActionSets = new ArrayList(2);
145
        fastViews = new ArrayList(2);
146
        fastViews = new ArrayList(2);
146
        globalFastViews = new ArrayList(2);
147
        fastViewBars = new ArrayList(2);
148
        mapIDtoViewLayoutRec = new HashMap();
147
        mapIDtoViewLayoutRec = new HashMap();
149
    }
148
    }
150
149
151
    /**
150
	/**
152
     * Sets the fast view attribute.
151
	 * Sets the fast view attribute. Note: The page is expected to update action
153
     * Note: The page is expected to update action bars.
152
	 * bars.
154
     */
153
	 */
155
    public void addFastView(IViewReference ref) {
154
	public void addFastView(IViewReference ref) {
156
        ViewPane pane = (ViewPane) ((WorkbenchPartReference) ref).getPane();
155
		addFastView(ref, true);
157
        if (!isFastView(ref)) {
156
	}
158
            // Only remove the part from the presentation if it
157
	
159
            // is actually in the presentation.
158
	/**
160
            if (presentation.hasPlaceholder(ref.getId(), ref.getSecondaryId())
159
	 * Sets the fast view attribute. Note: The page is expected to update action
161
                    || pane.getContainer() != null) {
160
	 * bars.
162
				presentation.removePart(pane);
161
	 */
163
			}
162
	public void addFastView(IViewReference ref, boolean handleLayout) {
164
            // We are drag-enabling the pane because it has been disabled
163
		ViewPane pane = (ViewPane) ((WorkbenchPartReference) ref).getPane();
165
            // when it was removed from the perspective presentation.
164
		if (!isFastView(ref)) {
166
            fastViews.add(ref);
165
			if (handleLayout) {
167
            pane.setFast(true);
166
				// Only remove the part from the presentation if it
168
            Control ctrl = pane.getControl();
167
				// is actually in the presentation.
169
            if (ctrl != null) {
168
				if (presentation.hasPlaceholder(ref.getId(), ref.getSecondaryId())
169
						|| pane.getContainer() != null) {
170
					presentation.removePart(pane);
171
				}
172
			}
173
			
174
			// We are drag-enabling the pane because it has been disabled
175
			// when it was removed from the perspective presentation.
176
			fastViews.add(ref);
177
			pane.setFast(true);
178
			Control ctrl = pane.getControl();
179
			if (ctrl != null) {
170
				ctrl.setEnabled(false); // Remove focus support.
180
				ctrl.setEnabled(false); // Remove focus support.
171
			}
181
			}
172
        }
182
		}
173
    }
183
	}
174
184
175
    /**
185
    /**
176
     * Moves a part forward in the Z order of a perspective so it is visible.
186
     * Moves a part forward in the Z order of a perspective so it is visible.
Lines 319-470 Link Here
319
        return array;
329
        return array;
320
    }
330
    }
321
331
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
    	groupBar.getControl().setVisible(false);
329
    	groupBar.dispose();
330
    	
331
    	fastViewBars.remove(groupBar);
332
    	
333
    	tbm.forceLayout();
334
    }
335
    
336
    private String getUniqueGroupId() {
337
		// Get a unique id
338
    	boolean found = false;
339
    	int count = 0;
340
    	String id = ""; //$NON-NLS-1$
341
    	while (!found) {
342
    		id = getDesc().getId() + " (" + count  + ")";  //$NON-NLS-1$//$NON-NLS-2$
343
    		boolean matchFound = false;
344
    		for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
345
				FastViewBar fvb = (FastViewBar) fvbIter.next();
346
				if (fvb.getId().equals(id)) {
347
					matchFound = true;
348
					break;
349
				}
350
			}
351
    		
352
    		if (matchFound)
353
    			count++;
354
    		else
355
    			found = true;
356
    	}
357
    	
358
    	return id;
359
    }
360
    
361
    private int calcStackSide (ViewStack stack) {
362
    	// Where is the stack in relation to the EditorArea?
363
    	Rectangle stackBounds = stack.getBounds();
364
    	Rectangle editorAreaBounds = editorArea.getBounds();
365
    	
366
    	if ((stackBounds.x+stackBounds.width) < editorAreaBounds.x)
367
    		return SWT.LEFT;
368
    	if (stackBounds.x > (editorAreaBounds.x+editorAreaBounds.width))
369
    		return SWT.RIGHT;
370
    	if ((stackBounds.y+stackBounds.height) < editorAreaBounds.y)
371
    		return SWT.TOP;
372
    	if (stackBounds.y > (editorAreaBounds.y+editorAreaBounds.height))
373
    		return SWT.BOTTOM;
374
    	
375
    	return SWT.BOTTOM; // shouldn't be able to get here...
376
    }
377
    
378
    public void moveToTrim(List stacks, int style) {
379
    	if (stacks == null || stacks.size() == 0)
380
    		return;
381
    	
382
    	Shell shell = ((ViewStack)stacks.get(0)).getShell();
383
    	RectangleAnimation animation = new RectangleAnimation(shell, null, null);
384
    	
385
		// Capture the area the stack currently occupies (and its image)
386
    	for (Iterator stackIter = stacks.iterator(); stackIter.hasNext();) {
387
			ViewStack stack = (ViewStack) stackIter.next();
388
			animation.addStartRect(DragUtil.getDisplayBounds(stack.getControl()));
389
    	}
390
    	
391
    	// Iterate through all the stacks, moveing each to the trim
392
    	List newFVBs = new ArrayList(stacks.size());
393
    	for (Iterator stackIter = stacks.iterator(); stackIter.hasNext();) {
394
			ViewStack stack = (ViewStack) stackIter.next();
395
			
396
			// Place the stack on the correct side
397
	    	int side = calcStackSide(stack);
398
	    	FastViewBar fvb = createFastViewBar(getUniqueGroupId(), style, side);
399
	    	newFVBs.add(fvb);
400
	    	
401
	    	// Add all the views in the stack to teh new FVB
402
	    	ArrayList refs = new ArrayList();
403
	    	List parts = stack.getPresentableParts();
404
	    	for (Iterator partIter = parts.iterator(); partIter.hasNext();) {
405
	    		PresentablePart part = (PresentablePart) partIter.next();
406
	    		if (part.getPane().getPartReference() instanceof ViewReference) {
407
	    			refs.add(part.getPane().getPartReference());
408
	    		}
409
			}
410
	    	fvb.setViewRefs(refs);
411
	    	
412
	    	// Set the display orientation based on the stack's geometry
413
	    	Rectangle stackBounds = stack.getBounds();
414
	    	int orientation = (stackBounds.width > stackBounds.height) ? SWT.HORIZONTAL : SWT.VERTICAL;
415
	    	fvb.setOrientation(orientation);
416
	    	
417
	    	// Move the views 'into' the new group
418
	    	fvb.collapseGroup();
419
    	
420
    	}
421
422
    	// Force a layout
423
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
424
    	ITrimManager tbm = wbw.getTrimManager();
425
    	tbm.forceLayout();
426
    	
427
    	// Now that the layout is finished we can add the 'end' rects for the animation
428
    	for (Iterator fvbIter = newFVBs.iterator(); fvbIter.hasNext();) {
429
			FastViewBar fvb = (FastViewBar) fvbIter.next();
430
			animation.addEndRect(DragUtil.getDisplayBounds(fvb.getControl()));
431
		}
432
    	
433
    	animation.schedule();
434
    }
435
    
436
    public void restoreZoomGroups() {
437
		List toClose = new ArrayList();
438
		
439
		// Get the groups to close in another list and...
440
    	for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
441
			FastViewBar fvb = (FastViewBar) fvbIter.next();
442
			if (fvb.testStyleBit(FastViewBar.ZOOM_GROUP))
443
				toClose.add(fvb);
444
		}
445
    	
446
    	// ... close them
447
    	for (Iterator closeIter = toClose.iterator(); closeIter.hasNext();) {
448
			FastViewBar fvb = (FastViewBar) closeIter.next();
449
				fvb.closeGroup();
450
		}
451
    }
452
    
453
    private FastViewBar createFastViewBar(String id, int style, int side) {   	
454
    	// Create the FVB on the given side
455
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
456
    	FastViewBar newFVB = new FastViewBar(wbw, style, id);
457
    	newFVB.createControl(wbw.getShell());
458
    	newFVB.dock(side);
459
    	newFVB.getControl().setVisible(true);
460
    	ITrimManager tbm = wbw.getTrimManager();
461
    	tbm.addTrim(side, newFVB);
462
    	
463
    	fastViewBars.add(newFVB);
464
    	
465
    	return newFVB;
466
    }
467
    
468
    /**
332
    /**
469
     * Returns the new wizard shortcuts associated with this perspective.
333
     * Returns the new wizard shortcuts associated with this perspective.
470
     * 
334
     * 
Lines 936-1029 Link Here
936
    /**
800
    /**
937
     * activate.
801
     * activate.
938
     */
802
     */
939
    protected void onActivate() {
803
	protected void onActivate() {
940
        
804
		// Update editor area state.
941
        // Update editor area state.
805
		if (editorArea.getControl() != null) {
942
        if (editorArea.getControl() != null) {
806
			editorArea.setVisible(isEditorAreaVisible());
943
            editorArea.setVisible(isEditorAreaVisible());
807
		}
944
        }
808
809
		// update the 'global' FVB
810
		FastViewBar fvb = ((WorkbenchWindow) page.getWorkbenchWindow())
811
				.getFastViewBar();
812
		if (fvb != null) {
813
			fvb.setViewRefs(fastViews);
814
		}
815
816
		// Update fast views.
817
		// Make sure the control for the fastviews are create so they can
818
		// be activated.
819
		for (int i = 0; i < fastViews.size(); i++) {
820
			ViewPane pane = getPane((IViewReference) fastViews.get(i));
821
			if (pane != null) {
822
				Control ctrl = pane.getControl();
823
				if (ctrl == null) {
824
					pane.createControl(getClientComposite());
825
					ctrl = pane.getControl();
826
				}
827
				ctrl.setEnabled(false); // Remove focus support.
828
			}
829
		}
945
830
946
        // Update fast views.
831
		// Set the visibility of all fast view pins
947
        // Make sure the control for the fastviews are create so they can
832
		setAllPinsVisible(true);
948
        // be activated.
949
        for (int i = 0; i < fastViews.size(); i++) {
950
            ViewPane pane = getPane((IViewReference) fastViews.get(i));
951
            if (pane != null) {
952
                Control ctrl = pane.getControl();
953
                if (ctrl == null) {
954
                    pane.createControl(getClientComposite());
955
                    ctrl = pane.getControl();
956
                }
957
                ctrl.setEnabled(false); // Remove focus support.
958
            }
959
        }
960
        
961
        // update the 'global' FVB
962
        FastViewBar fvb = ((WorkbenchWindow)page.getWorkbenchWindow()).getFastViewBar();
963
        if (fvb != null) {
964
	        fvb.setViewRefs(globalFastViews);
965
	        globalFVBsaved = false;
966
        }
967
833
968
        // Show the trim groups
834
		// Show the layout
969
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
835
		presentation.activate(getClientComposite());
970
    	ITrimManager tbm = wbw.getTrimManager();
836
971
    	if (tbm != null) {
837
		// Trim Stack Support
972
	        for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
838
        IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
973
	        	fvb = (FastViewBar) fvbIter.next();
839
        boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
974
	        	fvb.update(false);
840
    	if (useNewMinMax) {
975
				tbm.setTrimVisible(fvb, true);
841
			// We 'stall' the creation of trim elements until the first activation
976
			}
842
			createInitialTrim();
977
			
843
			
844
			// Show Trim parts -after- activation
845
			presentation.getLayout().setTrimVisible(true);
846
			
847
			// The editor area's trim stack's visibility is the inverse
848
			// Of the actual editor area
849
			WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow();
850
			ITrimManager tbm = wbw.getTrimManager();
851
			IWindowTrim eaTrim = tbm.getTrim(editorArea.getID());
852
			if (eaTrim != null) {
853
				tbm.setTrimVisible(eaTrim, !isEditorAreaVisible());
854
			}
855
	
978
			// if we're done then force an update...optimize out if possible
856
			// if we're done then force an update...optimize out if possible
979
			tbm.forceLayout();
857
			tbm.forceLayout();
980
    	}
858
    	}
981
        
982
        setAllPinsVisible(true);
983
        presentation.activate(getClientComposite());
984
859
985
        if (shouldHideEditorsOnActivate) {
860
		if (shouldHideEditorsOnActivate) {
986
            // We do this here to ensure that createPartControl is called on the top editor
861
			// We do this here to ensure that createPartControl is called on the
987
            // before it is hidden. See bug 20166.
862
			// top editor
988
            hideEditorArea();
863
			// before it is hidden. See bug 20166.
989
            shouldHideEditorsOnActivate = false;
864
			hideEditorArea();
990
        }
865
			shouldHideEditorsOnActivate = false;
991
    }
866
		}
867
	}
992
868
993
    /**
869
    /**
870
	 * Create any trim necessary to support the current
871
	 * layout state 
872
	 */
873
	private void createInitialTrim() {
874
		WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow();
875
		ITrimManager tbm = wbw.getTrimManager();
876
877
		LayoutPart[] children = presentation.getLayout().getChildren();
878
		for (int i = 0; i < children.length; i++) {
879
			if (children[i].getTrimState() == LayoutPart.TRIMSTATE_IN_TRIM
880
					|| children[i].getTrimState() == LayoutPart.TRIMSTATE_ZOOMEDTOTRIM) {
881
				IWindowTrim partTrim = tbm.getTrim(children[i].getID());
882
				if (partTrim == null) {
883
					children[i].createInitialTrim();
884
				}
885
			}
886
		}
887
	}
888
889
	/**
994
     * deactivate.
890
     * deactivate.
995
     */
891
     */
996
    protected void onDeactivate() {
892
	protected void onDeactivate() {
997
        presentation.deactivate();
893
		presentation.deactivate();
998
        setActiveFastView(null);
894
		setActiveFastView(null);
999
        setAllPinsVisible(false);
895
		setAllPinsVisible(false);
1000
896
1001
        // remember the list of 'global' fast views
897
		// Update fast views.
1002
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
898
		for (int i = 0; i < fastViews.size(); i++) {
1003
    	FastViewBar globalFVB = wbw.getFastViewBar();
899
			ViewPane pane = getPane((IViewReference) fastViews.get(i));
1004
    	if (globalFVB != null) {
900
			if (pane != null) {
1005
	        globalFastViews = new ArrayList(globalFVB.getViewRefs());
901
				Control ctrl = pane.getControl();
1006
	        globalFVBsaved = true;
902
				if (ctrl != null) {
1007
    	}
1008
        
1009
        // Update fast views.
1010
        for (int i = 0; i < fastViews.size(); i++) {
1011
            ViewPane pane = getPane((IViewReference) fastViews.get(i));
1012
            if (pane != null) {
1013
                Control ctrl = pane.getControl();
1014
                if (ctrl != null) {
1015
					ctrl.setEnabled(true); // Add focus support.
903
					ctrl.setEnabled(true); // Add focus support.
1016
				}
904
				}
1017
            }
905
			}
1018
        }
1019
1020
        // Hide the trim groups
1021
    	ITrimManager tbm = wbw.getTrimManager();
1022
        for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
1023
			FastViewBar fvb = (FastViewBar) fvbIter.next();
1024
			tbm.setTrimVisible(fvb, false);
1025
		}
906
		}
1026
    }
907
908
		// Trim Stack Support
909
        IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
910
        boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
911
    	if (useNewMinMax) {
912
			// OK, adjust the trim to hide any view stacks that
913
			// are -currently- showing in the trim
914
			presentation.getLayout().setTrimVisible(false);
915
    	}
916
	}
1027
917
1028
    /**
918
    /**
1029
     * Notifies that a part has been activated.
919
     * Notifies that a part has been activated.
Lines 1043-1072 Link Here
1043
    public void performedShowIn(String partId) {
933
    public void performedShowIn(String partId) {
1044
        showInTimes.put(partId, new Long(System.currentTimeMillis()));
934
        showInTimes.put(partId, new Long(System.currentTimeMillis()));
1045
    }
935
    }
1046
    
936
1047
    /**
937
	/**
1048
     * Sets the fast view attribute.
938
	 * Sets the fast view attribute. Note: The page is expected to update action
1049
     * Note: The page is expected to update action bars.
939
	 * bars.
1050
     */
940
	 */
1051
    public void removeFastView(IViewReference ref) {
941
	public void removeFastView(IViewReference ref) {
1052
        ViewPane pane = getPane(ref);
942
		removeFastView(ref, true);
1053
        if (isFastView(ref)) {
943
	}
1054
            if (activeFastView == ref) {
944
	
945
	/**
946
	 * Sets the fast view attribute. Note: The page is expected to update action
947
	 * bars.
948
	 */
949
	public void removeFastView(IViewReference ref, boolean handleLayout) {
950
		ViewPane pane = getPane(ref);
951
		if (isFastView(ref)) {
952
			if (activeFastView == ref) {
1055
				setActiveFastView(null);
953
				setActiveFastView(null);
1056
			}
954
			}
1057
            fastViews.remove(ref);
955
			fastViews.remove(ref);
1058
            pane.setFast(false);
956
			pane.setFast(false);
1059
            Control ctrl = pane.getControl();
957
			Control ctrl = pane.getControl();
1060
            if (ctrl != null) {
958
			if (ctrl != null) {
1061
				ctrl.setEnabled(true); // Modify focus support.
959
				ctrl.setEnabled(true); // Modify focus support.
1062
			}
960
			}
1063
            // We are disabling the pane because it will be enabled when it
961
			
1064
            // is added to the presentation. When a pane is enabled a drop
962
			if (handleLayout) {
1065
            // listener is added to it, and we do not want to have multiple
963
				// We are disabling the pane because it will be enabled when it
1066
            // listeners for a pane
964
				// is added to the presentation. When a pane is enabled a drop
1067
            presentation.addPart(pane);
965
				// listener is added to it, and we do not want to have multiple
1068
        }
966
				// listeners for a pane
1069
    }
967
				presentation.addPart(pane);
968
			}
969
		}
970
	}
1070
971
1071
    /**
972
    /**
1072
     * Fills a presentation with layout data.
973
     * Fills a presentation with layout data.
Lines 1093-1105 Link Here
1093
        IMemento views[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
994
        IMemento views[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
1094
        result.merge(createReferences(views));
995
        result.merge(createReferences(views));
1095
996
1096
        // Restore the list of fast views
1097
        memento = memento.getChild(IWorkbenchConstants.TAG_FAST_VIEWS);
997
        memento = memento.getChild(IWorkbenchConstants.TAG_FAST_VIEWS);
1098
        if (memento != null) {
998
        if (memento != null) {
1099
            views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
999
            views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
1100
            result.merge(createReferences(views));
1000
            result.merge(createReferences(views));
1101
        }
1001
        }
1102
        
1103
        return result;
1002
        return result;
1104
    }
1003
    }
1105
1004
Lines 1299-1354 Link Here
1299
            }
1198
            }
1300
        }
1199
        }
1301
1200
1302
        // Restore the list of 'global' fast views
1303
        globalFastViews = new ArrayList();
1304
        IMemento globalFastViewsMem = memento.getChild(IWorkbenchConstants.TAG_GLOBAL_FAST_VIEWS);
1305
        if (globalFastViewsMem != null) {
1306
        	IMemento[] globalRefs = globalFastViewsMem.getChildren(IWorkbenchConstants.TAG_VIEW);
1307
        	for (int i = 0; i < globalRefs.length; i++) {
1308
    			String viewId = globalRefs[i].getID();
1309
                String secondaryId = ViewFactory.extractSecondaryId(viewId);
1310
                if (secondaryId != null) {
1311
                	viewId = ViewFactory.extractPrimaryId(viewId);
1312
                }
1313
                
1314
                // Resolve the ref
1315
                IViewReference ref = viewFactory.getView(viewId, secondaryId);
1316
                globalFastViews.add(ref);
1317
			}
1318
        }
1319
        else {
1320
        	// Old format, all fast views are 'global'
1321
        	globalFastViews = new ArrayList(fastViews);
1322
        }
1323
1324
        // Restore the trim groups
1325
        IMemento groupsMem = memento.getChild(IWorkbenchConstants.TAG_FAST_GROUPS);
1326
        if (groupsMem != null) {
1327
	        IMemento[] group = groupsMem.getChildren(IWorkbenchConstants.TAG_FAST_VIEW_DATA);
1328
	        for (int i = 0; i < group.length; i++) {
1329
	        	String id = group[i].getString(IWorkbenchConstants.TAG_ID);
1330
	        	FastViewBar fvb = createFastViewBar(id, FastViewBar.GROUP_FVB, SWT.BOTTOM);
1331
	        	fvb.restoreState(group[i]);
1332
	
1333
	        	IMemento viewsMem = group[i].getChild(IWorkbenchConstants.TAG_VIEWS);
1334
	    		IMemento[] fvMems = viewsMem.getChildren(IWorkbenchConstants.TAG_VIEW);
1335
	    		ArrayList viewRefs = new ArrayList(fvMems.length);
1336
	    		for (int j = 0; j < fvMems.length; j++) {
1337
	    			String viewId = fvMems[j].getID();
1338
	                String secondaryId = ViewFactory.extractSecondaryId(viewId);
1339
	                if (secondaryId != null) {
1340
	                	viewId = ViewFactory.extractPrimaryId(viewId);
1341
	                }
1342
	                
1343
	                // Resolve the ref
1344
	                IViewReference ref = viewFactory.getView(viewId, secondaryId);
1345
	                viewRefs.add(ref);
1346
	    		}
1347
	        	
1348
	    		fvb.setViewRefs(viewRefs);
1349
			}
1350
        }
1351
        
1352
        HashSet knownActionSetIds = new HashSet();
1201
        HashSet knownActionSetIds = new HashSet();
1353
1202
1354
        // Load the always on action sets.
1203
        // Load the always on action sets.
Lines 1646-1652 Link Here
1646
                    .getKey(ref));
1495
                    .getKey(ref));
1647
        }
1496
        }
1648
1497
1649
        // Save the set of all fast Views
1650
        if (fastViews.size() > 0) {
1498
        if (fastViews.size() > 0) {
1651
            IMemento childMem = memento
1499
            IMemento childMem = memento
1652
                    .createChild(IWorkbenchConstants.TAG_FAST_VIEWS);
1500
                    .createChild(IWorkbenchConstants.TAG_FAST_VIEWS);
Lines 1662-1685 Link Here
1662
            }
1510
            }
1663
        }
1511
        }
1664
1512
1665
        // Save the set of all 'global' fast Views for this perspective        
1666
        // update the list of 'global' fast views
1667
    	WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow();
1668
    	FastViewBar globalFVB = wbw.getFastViewBar();
1669
        if (globalFVB != null && !globalFVBsaved) {
1670
	        globalFastViews = new ArrayList(globalFVB.getViewRefs());
1671
	        globalFVBsaved = true;
1672
        }
1673
    
1674
        IMemento globalFVBMem = memento
1675
                .createChild(IWorkbenchConstants.TAG_GLOBAL_FAST_VIEWS);
1676
        itr = globalFastViews.iterator();
1677
        while (itr.hasNext()) {
1678
            IViewReference ref = (IViewReference) itr.next();
1679
            String id = ViewFactory.getKey(ref);
1680
            globalFVBMem.createChild(IWorkbenchConstants.TAG_VIEW, id);
1681
        }
1682
1683
        // Save the view layout recs.
1513
        // Save the view layout recs.
1684
        for (Iterator i = mapIDtoViewLayoutRec.keySet().iterator(); i.hasNext();) {
1514
        for (Iterator i = mapIDtoViewLayoutRec.keySet().iterator(); i.hasNext();) {
1685
            String compoundId = (String) i.next();
1515
            String compoundId = (String) i.next();
Lines 1707-1730 Link Here
1707
            }
1537
            }
1708
        }
1538
        }
1709
1539
1710
        // Save the list of group FVB's
1711
        IMemento fvbMem = memento.createChild(IWorkbenchConstants.TAG_FAST_GROUPS);
1712
        for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
1713
        	FastViewBar fvb = (FastViewBar) fvbIter.next();
1714
    		IMemento fastViewBarMem = fvbMem.createChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA);
1715
    		fastViewBarMem.putString(IWorkbenchConstants.TAG_ID, fvb.getId());
1716
    		fvb.saveState(fastViewBarMem);
1717
    		
1718
    		// Store the view references for this FVB
1719
    		List viewRefs = fvb.getViewRefs();
1720
    		IMemento viewsMem = fastViewBarMem.createChild(IWorkbenchConstants.TAG_VIEWS);
1721
    		for (Iterator fvIter = viewRefs.iterator(); fvIter.hasNext();) {
1722
    			IViewReference ref = (IViewReference) fvIter.next();
1723
                String id = ViewFactory.getKey(ref);
1724
                viewsMem.createChild(IWorkbenchConstants.TAG_VIEW, id);
1725
    		}
1726
		}
1727
        
1728
        if (errors > 0) {
1540
        if (errors > 0) {
1729
            String message = WorkbenchMessages.Perspective_multipleErrors;
1541
            String message = WorkbenchMessages.Perspective_multipleErrors;
1730
            if (errors == 1) {
1542
            if (errors == 1) {
Lines 1834-1866 Link Here
1834
        }
1646
        }
1835
    }
1647
    }
1836
1648
1837
    public FastViewBar getFVBForRef(IViewReference ref) {
1838
    	for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) {
1839
			FastViewBar fvb = (FastViewBar) fvbIter.next();
1840
			if (fvb.hasViewRef(ref))
1841
				return fvb;
1842
		}
1843
    	
1844
    	return null;
1845
    }
1846
    /**
1649
    /**
1847
     * Sets the selection for the shortcut bar icon representing the givevn fast view.
1650
     * Sets the selection for the shortcut bar icon representing the givevn fast view.
1848
     */
1651
     */
1849
    private void setFastViewIconSelection(IViewReference ref, boolean selected) {
1652
    private void setFastViewIconSelection(IViewReference ref, boolean selected) {
1850
        WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow();
1653
		// First, is it in a Trim Stack?
1851
        FastViewBar bar = getFVBForRef(ref);
1654
		ViewStackTrimPart ts = getTrimStackForRef(ref);
1852
        if (bar == null)
1655
		if (ts != null) {
1853
        	bar = window.getFastViewBar();
1656
			ts.setIconSelection(ref, selected);
1854
        
1657
			return;
1855
        if (bar != null) {
1658
		}
1856
            if (selected) {
1659
1857
                bar.setSelection(ref);
1660
		WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow();
1858
            } else {
1661
		FastViewBar bar = window.getFastViewBar();
1859
                if (ref == bar.getSelection()) {
1662
		if (bar != null) {
1860
                    bar.setSelection(null);
1663
			if (selected) {
1861
                }
1664
				bar.setSelection(ref);
1862
            }
1665
			} else {
1863
        }
1666
				if (ref == bar.getSelection()) {
1667
					bar.setSelection(null);
1668
				}
1669
			}
1670
		}
1864
    }
1671
    }
1865
1672
1866
    /**
1673
    /**
Lines 1909-1914 Link Here
1909
        editorHolder = null;
1716
        editorHolder = null;
1910
    }
1717
    }
1911
1718
1719
	private ViewStackTrimPart getTrimStackForRef(IViewReference ref) {
1720
		// Is it in a minimized stack?
1721
		List trimParts = presentation.getLayout().getTrimForParts();
1722
		for (Iterator trimIter = trimParts.iterator(); trimIter.hasNext();) {
1723
			IWindowTrim trim = (IWindowTrim) trimIter.next();
1724
			if (trim instanceof ViewStackTrimPart) {
1725
				if (((ViewStackTrimPart) trim).hasViewRef(ref))
1726
					return (ViewStackTrimPart) trim;
1727
			}
1728
		}
1729
1730
		return null;
1731
	}
1732
1912
    /**
1733
    /**
1913
     * Shows a fast view.
1734
     * Shows a fast view.
1914
     * @return whether the view was successfully shown
1735
     * @return whether the view was successfully shown
Lines 1926-1940 Link Here
1926
1747
1927
        saveFastViewWidthRatio();
1748
        saveFastViewWidthRatio();
1928
1749
1929
        WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow();
1750
1930
        FastViewBar bar = getFVBForRef(ref);
1751
		// Determine the display orientation
1931
        if (bar == null)
1752
		int side;
1932
        	bar = window.getFastViewBar();
1753
		ViewStackTrimPart ts = getTrimStackForRef(ref);
1933
        
1754
		if (ts != null) {
1934
        if (bar == null) {
1755
			side = ts.getViewSide();
1935
            return false;
1756
		} else {
1936
        }
1757
			WorkbenchWindow window = (WorkbenchWindow) page
1937
        int side = bar.getViewSide(ref);
1758
					.getWorkbenchWindow();
1759
			FastViewBar bar = window.getFastViewBar();
1760
1761
			if (bar == null) {
1762
				return false;
1763
			}
1764
1765
			side = bar.getViewSide(ref);
1766
		}
1938
1767
1939
        fastViewPane.showView(getClientComposite(), pane, side,
1768
        fastViewPane.showView(getClientComposite(), pane, side,
1940
                getFastViewWidthRatio(ref)); 
1769
                getFastViewWidthRatio(ref)); 
Lines 1971-1978 Link Here
1971
        int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE);
1800
        int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE);
1972
1801
1973
        if (openViewMode == IPreferenceConstants.OVM_FAST) {
1802
        if (openViewMode == IPreferenceConstants.OVM_FAST) {
1974
        	FastViewBar fvb = ((WorkbenchWindow)pane.getWorkbenchWindow()).getFastViewBar();
1803
            showFastView(ref);
1975
        	fvb.adoptView(ref, -1, true, true);
1804
            addFastView(ref);
1976
        } else if (openViewMode == IPreferenceConstants.OVM_FLOAT
1805
        } else if (openViewMode == IPreferenceConstants.OVM_FLOAT
1977
                && presentation.canDetach()) {
1806
                && presentation.canDetach()) {
1978
            presentation.addDetachedPart(pane);
1807
            presentation.addDetachedPart(pane);
Lines 2171-2174 Link Here
2171
		return fastViewPane;
2000
		return fastViewPane;
2172
	}
2001
	}
2173
2002
2003
	// Trim Stack Support
2004
2005
	/**
2006
	 * Hack to get around 'addFastView' issues
2007
	 * 
2008
	 * @param ref
2009
	 */
2010
	public void addFastViewHack(IViewReference ref) {
2011
		//addFastView(ref, false);
2012
	}
2013
2014
	/**
2015
	 * Hack to get around 'addFastView' issues
2016
	 * 
2017
	 * @param ref
2018
	 */
2019
	public void removeFastViewHack(IViewReference ref) {
2020
		//removeFastView(ref, false);
2021
	}
2022
2023
	/**
2024
	 * Moves any parts that support trim representation into the trim
2025
	 * 
2026
	 * @param parts The parts to (potentially) move to the trim
2027
	 * @param restoreOnUnzoom 'true' iff we want the parts to
2028
	 * automatically restore on an 'unzoom'.
2029
	 */
2030
	public void movePartsToTrim(List parts, boolean restoreOnUnzoom) {
2031
		if (parts == null || parts.size() == 0)
2032
			return;
2033
2034
		Shell shell = page.getWorkbenchWindow().getShell();
2035
		RectangleAnimation animation = new RectangleAnimation(shell, null, null);
2036
2037
		// Capture the area the stack currently occupies (and its image)
2038
		for (Iterator stackIter = parts.iterator(); stackIter.hasNext();) {
2039
			LayoutPart part = (LayoutPart) stackIter.next();
2040
			if (part.getControl() != null)
2041
				animation.addStartRect(DragUtil.getDisplayBounds(part
2042
						.getControl()));
2043
		}
2044
2045
		// Gain access to the trim manager
2046
		WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow();
2047
		ITrimManager tbm = wbw.getTrimManager();
2048
2049
		// Iterate through all the parts, moving each to the trim
2050
		int newTrimState = restoreOnUnzoom ? LayoutPart.TRIMSTATE_ZOOMEDTOTRIM
2051
				: LayoutPart.TRIMSTATE_IN_TRIM;
2052
		
2053
		// We hide the editor container last so its position can be used
2054
		// to calculate the correct side for other trim
2055
		boolean moveEditorAreaToTrim = false;
2056
		
2057
		List newTrimParts = new ArrayList();
2058
		for (Iterator stackIter = parts.iterator(); stackIter.hasNext();) {
2059
			LayoutPart part = (LayoutPart) stackIter.next();
2060
			
2061
			// for now be careful and only manipulate 'known' part types
2062
			// should generalize...
2063
			if (part instanceof ViewStack) {
2064
				part.setTrimState(newTrimState);
2065
				IWindowTrim partTrim = tbm.getTrim(part.getID());
2066
				if (partTrim != null) {
2067
					newTrimParts.add(partTrim);
2068
				}
2069
			} else if (part instanceof EditorSashContainer) {
2070
				moveEditorAreaToTrim = true;
2071
			}
2072
		}
2073
2074
		if (moveEditorAreaToTrim) {
2075
			editorArea.setTrimState(newTrimState);
2076
			hideEditorArea();
2077
2078
			IWindowTrim partTrim = tbm.getTrim(editorArea.getID());
2079
			if (partTrim != null) {
2080
				newTrimParts.add(partTrim);
2081
			}
2082
		}
2083
		
2084
		// Force a layout if necessary
2085
		if (newTrimParts.size() == 0)
2086
			return;
2087
		
2088
		// OK, we're good to go
2089
		tbm.forceLayout();
2090
2091
		// Now that the layout is finished we can add the 'end' rects for the
2092
		// animation
2093
		for (Iterator tsIter = newTrimParts.iterator(); tsIter.hasNext();) {
2094
			TrimPart ts = (TrimPart) tsIter.next();
2095
			animation.addEndRect(DragUtil.getDisplayBounds(ts.getControl()));
2096
		}
2097
2098
		animation.schedule();
2099
	}
2100
2101
	/**
2102
	 * Restores a part in the trim to the actual layout
2103
	 * @param part The part to restore
2104
	 */
2105
	public void restoreTrimPart(LayoutPart part) {
2106
		// Remove any current fastview
2107
		setActiveFastView(null);
2108
2109
		// Set the part's state to place it back in the layout
2110
		part.setTrimState(LayoutPart.TRIMSTATE_NORMAL);
2111
2112
		if (part == editorArea)
2113
			showEditorArea();
2114
		
2115
		WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow();
2116
		ITrimManager tbm = wbw.getTrimManager();
2117
		tbm.forceLayout();
2118
	}
2119
2120
	/**
2121
	 * Determine the correct side to initially dock a new
2122
	 * trim part on. We do this by checking its rect against
2123
	 * the editor area.
2124
	 * 
2125
	 * @param stackBounds The bounds of the stack we want to create trim for
2126
	 * @return the SWT side to dock the trim element on
2127
	 */
2128
	public int calcStackSide(Rectangle stackBounds) {
2129
		// Where is the stack in relation to the EditorArea?
2130
		Rectangle editorAreaBounds = editorArea.getBounds();
2131
		
2132
		// Is this the Editor Area
2133
		if (editorAreaBounds.equals(stackBounds))
2134
			return SWT.TOP;
2135
		
2136
		Point stackCenter = Geometry.centerPoint(stackBounds);
2137
		Point editorAreaCenter = Geometry.centerPoint(editorAreaBounds);
2138
2139
		int dx = editorAreaCenter.x - stackCenter.x;
2140
		int dy = editorAreaCenter.y - stackCenter.y;
2141
2142
		if (Math.abs(dx) > Math.abs(dy)) {
2143
			return (dx > 0) ? SWT.LEFT : SWT.RIGHT;
2144
		}
2145
2146
		return (dy > 0) ? SWT.TOP : SWT.BOTTOM;
2147
	}
2148
2149
	/**
2150
	 * Restore any parts that are showing in the trim as
2151
	 * a result of a 'zoom' operation
2152
	 */
2153
	public void restoreZoomedParts() {
2154
		// Remove any current fastview
2155
		setActiveFastView(null);
2156
2157
		// Is the editotr 'zoomed'?
2158
		boolean editorZoomed = (editorHolder != null &&
2159
			editorArea.getTrimState() == LayoutPart.TRIMSTATE_ZOOMEDTOTRIM);
2160
			
2161
		// have the layout restore the parts
2162
		boolean needsLayout = presentation.getLayout().restoreZoomedTrimParts();
2163
		if (needsLayout) {
2164
			// Force a layout
2165
			WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow();
2166
			ITrimManager tbm = wbw.getTrimManager();
2167
			tbm.forceLayout();
2168
		}
2169
		
2170
		if (editorZoomed) {
2171
			editorArea.setTrimState(LayoutPart.TRIMSTATE_NORMAL);
2172
			showEditorArea();
2173
		}
2174
	}
2174
}
2175
}
(-)Eclipse (+53 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
12
package org.eclipse.ui.internal;
13
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.events.SelectionEvent;
16
import org.eclipse.swt.events.SelectionListener;
17
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.widgets.ToolItem;
19
20
/**
21
 * A trim element representing the EditorArea
22
 * 
23
 * @since 3.3
24
 *
25
 */
26
public class EditorAreaTrimPart extends TrimPart {
27
28
	public EditorAreaTrimPart(WorkbenchWindow window, EditorSashContainer editorArea) {
29
		super(window, editorArea);
30
	}
31
	
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.ui.internal.TrimPart#addItems()
34
	 */
35
	protected void addItems() {
36
        // Since we dont have fast view behaviour for ediors we
37
		// simply restore the editor area on selection
38
        ToolItem editorAreaItem = new  ToolItem(toolBar, SWT.PUSH, toolBar.getItemCount());        
39
        Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_EDITOR_TRIMPART);
40
        editorAreaItem.setImage(tbImage);       
41
        String menuTip = WorkbenchMessages.EditorArea_Tooltip;
42
        editorAreaItem.setToolTipText(menuTip);
43
        editorAreaItem.addSelectionListener(new SelectionListener() {
44
			public void widgetDefaultSelected(SelectionEvent e) {
45
				restorePart();
46
			}
47
			public void widgetSelected(SelectionEvent e) {
48
				restorePart();
49
			}
50
        });
51
	}
52
53
}
(-)Eclipse (+253 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
12
package org.eclipse.ui.internal;
13
14
import java.util.ArrayList;
15
import java.util.Iterator;
16
import java.util.List;
17
18
import org.eclipse.jface.util.Geometry;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.events.SelectionEvent;
21
import org.eclipse.swt.events.SelectionListener;
22
import org.eclipse.swt.graphics.Point;
23
import org.eclipse.swt.graphics.Rectangle;
24
import org.eclipse.swt.widgets.ToolItem;
25
import org.eclipse.ui.IViewReference;
26
import org.eclipse.ui.IWorkbenchPartReference;
27
import org.eclipse.ui.internal.presentations.PresentablePart;
28
import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation;
29
import org.eclipse.ui.presentations.IPresentablePart;
30
31
/**
32
 * A trim element representing a ViewStack in the trim.
33
 * <p>
34
 * The placeholder must be non-null and its
35
 * 'real' container must be a <code>ViewStack</code>.
36
 * </p>
37
 * 
38
 * @since 3.3
39
 *
40
 */
41
public class ViewStackTrimPart extends TrimPart {	
42
	ContainerPlaceholder placeHolder;	
43
	ViewStack stack;
44
	
45
	// The orientation of the fast view pane when showing a view
46
	int paneOrientation;
47
	
48
	/**
49
	 * Construct a new trim element for the given ViewStack
50
	 * 
51
	 * @param window The window hosting the trim
52
	 * @param placeHolder The placeholder who's real container is
53
	 * the ViewStack being represented. 
54
	 */
55
	public ViewStackTrimPart(WorkbenchWindow window, ContainerPlaceholder placeHolder) {
56
		super(window, placeHolder.getRealContainer());
57
58
		setPlaceholder(placeHolder);
59
60
		// Set the display orientation based on the stack's geometry
61
    	Rectangle stackBounds = stack.getBounds();
62
    	paneOrientation = (stackBounds.width > stackBounds.height) ? SWT.HORIZONTAL : SWT.VERTICAL;
63
	}   	
64
65
	/**
66
	 * Sets the current placeholder. This is used by the ViewStack
67
	 * when its trim state changes, causing it to create a new placeholder.
68
	 * 
69
	 * @param placeHolder the current placeholder
70
	 */
71
	public void setPlaceholder(ContainerPlaceholder placeHolder) {
72
		this.placeHolder = placeHolder;
73
		this.stack = (ViewStack) placeHolder.getRealContainer();
74
	}
75
76
	/**
77
	 * Add a button for every view reference in the stack being
78
	 * represented.
79
	 */
80
	protected void addItems() {
81
		List orderedViews = getTrueViewOrder();
82
		if (orderedViews.size() == 0)
83
			return;
84
		
85
        // Add a button for each view reference in the stack
86
		for (Iterator iterator = orderedViews.iterator(); iterator.hasNext();) {
87
			IViewReference ref = (IViewReference) iterator.next();
88
89
			// Set up the item's 'look'
90
			ToolItem viewButton = new ToolItem(toolBar, SWT.CHECK);        
91
			viewButton.setImage(ref.getTitleImage());       
92
	        viewButton.setToolTipText(ref.getTitle());
93
	        viewButton.addSelectionListener(new SelectionListener() {
94
				public void widgetDefaultSelected(SelectionEvent e) {
95
					showView(e);
96
				}
97
				public void widgetSelected(SelectionEvent e) {
98
					showView(e);
99
				}
100
	        });
101
	        
102
	        viewButton.setData(ref);
103
		}
104
	}
105
106
	/**
107
	 * Returns the 'side' to place the current fast view on. This should
108
	 * really be changed...
109
	 * 
110
	 * @return The side (calc'd a la the FastViewBar:getViewSide method)
111
	 */
112
	public int getPaneOrientation() {
113
		// determine where the bar is in relation to the workbench window
114
		Rectangle tsBounds = getControl().getBounds();
115
		Rectangle wbBounds = getControl().getShell().getBounds();
116
		
117
	    if (paneOrientation == SWT.HORIZONTAL) {
118
	    	if (curSide == SWT.LEFT || curSide == SWT.RIGHT) {
119
	    		// is the trim bar nearer to the top or the bottom?
120
	    		if (Geometry.centerPoint(tsBounds).y < Geometry.centerPoint(wbBounds).y)
121
	    			return SWT.TOP;
122
123
	    		return SWT.BOTTOM;
124
	    	}
125
126
    		return curSide;
127
	    }
128
	
129
	    // Vertical
130
		if (curSide == SWT.TOP || curSide == SWT.BOTTOM) {
131
			// is the trim bar nearer to the left or the right?
132
			if (Geometry.centerPoint(tsBounds).x < Geometry.centerPoint(wbBounds).x)
133
				return SWT.LEFT;
134
135
			return SWT.RIGHT;
136
		}
137
138
		return curSide;
139
	}
140
141
	/**
142
	 * Show the selected view as a fast view.
143
	 * 
144
	 * @param e The event causing the view to be shown
145
	 * 
146
	 */
147
	protected void showView(SelectionEvent e) {
148
		Perspective persp = window.getActiveWorkbenchPage().getActivePerspective();
149
		ToolItem item = (ToolItem) e.getSource();
150
		IViewReference ref = (IViewReference) item.getData();
151
		persp.toggleFastView(ref);
152
	}
153
154
	/**
155
	 * @return a List of <code>IViewReference</code>
156
	 * sorted into the order in which they appear in the
157
	 * visual stack.
158
	 */
159
	private List getTrueViewOrder() {
160
		List orderedViews = new ArrayList();
161
		if (stack.getPresentation() instanceof TabbedStackPresentation) {
162
			TabbedStackPresentation tsp = (TabbedStackPresentation) stack.getPresentation();
163
			
164
			// KLUDGE!! uses a 'testing only' API
165
			IPresentablePart[] parts = tsp.getPartList();
166
			for (int i = 0; i < parts.length; i++) {
167
				if (parts[i] instanceof PresentablePart) {
168
					PresentablePart part = (PresentablePart) parts[i];
169
					IWorkbenchPartReference ref = part.getPane().getPartReference();
170
					if (ref instanceof IViewReference)
171
						orderedViews.add(ref);		
172
				}
173
			}
174
		}
175
		
176
		return orderedViews;
177
	}
178
	
179
	/**
180
	 * @param refToFind The reference being checked for
181
	 * @return true if this stack owns the reference.
182
	 */
183
	public boolean hasViewRef(IViewReference refToFind) {
184
		ToolItem[] items = toolBar.getItems();
185
		for (int i = 0; i < items.length; i++) {
186
			IViewReference ref = (IViewReference) items[i].getData();
187
			if (ref == refToFind)
188
				return true;
189
		}
190
		
191
		return false;
192
	}
193
194
	/**
195
	 * @return The list of all view references in the stack
196
	 */
197
	public List getViewRefs() {
198
		List refs = new ArrayList(toolBar.getItemCount());
199
		ToolItem[] items = toolBar.getItems();
200
		for (int i = 0; i < items.length; i++) {
201
			Object data = items[i].getData();
202
			if (data instanceof IViewReference)
203
				refs.add(data);
204
		}
205
		
206
		return refs;
207
	}
208
	
209
	/**
210
	 * @return The side that the fast view pane should be attached to
211
	 * based on the position of the trim element.
212
	 */
213
	public int getViewSide() {
214
        if (paneOrientation == SWT.HORIZONTAL) {
215
        	if (curSide == SWT.TOP || curSide == SWT.BOTTOM)
216
        		return curSide;
217
        	
218
        	return SWT.TOP;
219
        }
220
        
221
        // Vertical
222
        if (curSide == SWT.LEFT || curSide == SWT.RIGHT)
223
        	return curSide;
224
        
225
        // Are we on the left or right 'end' of the trim area?
226
        Point trimCenter = Geometry.centerPoint(getControl().getBounds());
227
        Point shellCenter = Geometry.centerPoint(getControl().getShell().getClientArea());
228
        return (trimCenter.x < shellCenter.x) ? SWT.LEFT : SWT.RIGHT;
229
	}
230
231
	/**
232
	 * @return the current placeholder
233
	 */
234
	public ContainerPlaceholder getPlaceholder() {
235
		return placeHolder;
236
	}
237
238
	/**
239
	 * This is used by the Perspective to match the icon's
240
	 * state to the state of the active fast view.
241
	 *  
242
	 * @param refToSet The view reference to set the state of
243
	 * @param selected The new state for the icon
244
	 */
245
	public void setIconSelection(IViewReference refToSet, boolean selected) {
246
		ToolItem[] items = toolBar.getItems();
247
		for (int i = 0; i < items.length; i++) {
248
			IViewReference ref = (IViewReference) items[i].getData();
249
			if (ref == refToSet)
250
				items[i].setSelection(selected);
251
		}
252
	}
253
}
(-)Eclipse (+180 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
12
package org.eclipse.ui.internal;
13
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.events.SelectionEvent;
16
import org.eclipse.swt.events.SelectionListener;
17
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Point;
19
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.swt.widgets.ToolBar;
21
import org.eclipse.swt.widgets.ToolItem;
22
import org.eclipse.ui.internal.layout.IWindowTrim;
23
24
/**
25
 * This is the base class to use to represent a LayoutPart when
26
 * it is being displayed in the trim.
27
 * <p>
28
 * It manages the life-cycle of the control and its contents but
29
 * requres that subclasses populate the ToolBar with its own items
30
 * and the logic to control them.
31
 * 
32
 * @since 3.3
33
 *
34
 */
35
public abstract class TrimPart implements IWindowTrim {
36
	// State
37
	protected WorkbenchWindow window;
38
	protected LayoutPart part;
39
	
40
	// Trim State
41
	protected ToolBar toolBar = null;
42
	protected int curSide;
43
44
	// Abstract methods for subclass's life-cycle
45
	
46
	/**
47
	 * Add the items appropiate for the particular
48
	 * subclass.
49
	 */
50
	protected abstract void addItems();
51
	
52
	/**
53
	 * Constructs a trim element for some LayoutPart
54
	 * 
55
	 * @param window The window hosting this trim element
56
	 * @param part The LayoutPart being represented
57
	 */
58
	public TrimPart(WorkbenchWindow window, LayoutPart part) {
59
		this.window = window;		
60
		this.part = part;
61
	}   	
62
63
	// TrimPart Life-cycle
64
	
65
	/**
66
	 * Put the stack back into the presentation
67
	 */
68
	protected void restorePart() {
69
		Perspective persp = window.getActiveWorkbenchPage().getActivePerspective();
70
		
71
		if (part != null)
72
			persp.restoreTrimPart(part);
73
	}
74
75
	/**
76
	 * Clear items added by the subclass. The subclass should
77
	 * add a dispose listener if it needs to clean up...
78
	 */
79
	private void clearContributions() {
80
		// Clear all items -except- the restore button
81
		ToolItem[] items = toolBar.getItems();
82
		for (int i = 1; i < items.length; i++) {
83
			items[i].dispose();
84
		}
85
	}
86
	
87
	/**
88
	 * Cycle the contents of the part in order to pick
89
	 * up any changes in the actual part that the trim
90
	 * is representing. 
91
	 */
92
	public void refresh() {
93
		clearContributions();
94
		addItems();
95
	}
96
	
97
	// IWindowTrim handling
98
99
	/**
100
	 * Create the Toolbar
101
	 */
102
	private void createControl() {
103
		int orientation = (curSide == SWT.TOP || curSide == SWT.BOTTOM) ? 
104
				SWT.HORIZONTAL : SWT.VERTICAL;
105
		toolBar = new ToolBar(window.getShell(), orientation);
106
		
107
        // Construct the 'restore' button
108
        ToolItem restoreItem = new  ToolItem(toolBar, SWT.PUSH, 0);        
109
        Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_TRIMPART);
110
        restoreItem.setImage(tbImage);       
111
        String menuTip = WorkbenchMessages.StandardSystemToolbar_Restore;
112
        restoreItem.setToolTipText(menuTip);
113
        restoreItem.addSelectionListener(new SelectionListener() {
114
			public void widgetDefaultSelected(SelectionEvent e) {
115
				restorePart();
116
			}
117
			public void widgetSelected(SelectionEvent e) {
118
				restorePart();
119
			}
120
        });
121
        
122
		// refresh the bar's contents
123
		addItems();
124
	}
125
126
	private void dispose() {
127
		if (toolBar != null)
128
			toolBar.dispose();
129
		toolBar = null;
130
	}
131
	
132
	public void dock(int dropSide) {
133
		curSide = dropSide;
134
	
135
		// Re-create the toolBar
136
		dispose();
137
		createControl();
138
	}
139
140
	public Control getControl() {
141
		return toolBar;
142
	}
143
144
	public String getDisplayName() {
145
		return part.getID();
146
	}
147
148
	public int getHeightHint() {
149
		Point cs =  toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
150
		return cs.y;
151
	}
152
153
	public String getId() {
154
		return part.getID();
155
	}
156
157
	public int getValidSides() {
158
		return SWT.TOP | SWT.BOTTOM | SWT.LEFT | SWT.RIGHT;
159
	}
160
161
	public int getWidthHint() {
162
		return toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
163
	}
164
165
	public void handleClose() {
166
	}
167
168
	public boolean isCloseable() {
169
		return false;
170
	}
171
172
	public boolean isResizeable() {
173
		return false;
174
	}
175
176
	public int getCurrentSide() {
177
		return curSide;
178
	}
179
180
}

Return to bug 153957