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

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/ColorSchemeService.java (-1 / +5 lines)
Lines 132-140 Link Here
132
        c[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
132
        c[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
133
        c[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
133
        c[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
134
134
135
		//percent[0] = presentation.getGradientPercentage();
135
        percent[0] = theme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT);
136
        percent[0] = theme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT);
136
        vertical = theme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL);
137
        vertical = theme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL);
137
        
138
	        
139
        //vertical = false;
140
141
        // Note: This is currently being overridden in PartTabFolderPresentation
138
        control.setBackground(c, percent, vertical);		
142
        control.setBackground(c, percent, vertical);		
139
143
140
        if (presentation.isActive()) {                
144
        if (presentation.isActive()) {                
(-)Eclipse UI/org/eclipse/ui/internal/PartTabFolder.java (-14 / +17 lines)
Lines 40-45 Link Here
40
import org.eclipse.ui.presentations.StackDropResult;
40
import org.eclipse.ui.presentations.StackDropResult;
41
import org.eclipse.ui.presentations.StackPresentation;
41
import org.eclipse.ui.presentations.StackPresentation;
42
42
43
/**
44
 * Manages a set of ViewPanes that are docked into the workbench window. The container for a PartTabFolder
45
 * is always a PartSashContainer (or null), and its children are always either PartPlaceholders or PartPanes.
46
 * 
47
 * TODO: write a common base class for EditorWorkbook and PartTabFolder.
48
 * TODO: remove the LayoutPart superclass. All code can either refer to PartPane, 
49
 * PartPlaceholder, PartSashContainer, or the common base class for EditorWorkbook and PartTabFolder.
50
 * The frequent downcasting is due to the fact that much of the code tries to use LayoutPart 
51
 * or ILayoutContainer references for many different purposes.
52
 */
43
public class PartTabFolder extends LayoutPart implements ILayoutContainer {
53
public class PartTabFolder extends LayoutPart implements ILayoutContainer {
44
54
45
    private boolean active = false;
55
    private boolean active = false;
Lines 538-557 Link Here
538
                .performDrag(part, DragUtil.getDisplayBounds(part.getControl()));
548
                .performDrag(part, DragUtil.getDisplayBounds(part.getControl()));
539
    }
549
    }
540
550
541
    /**
542
     * Returns the current presentable part, or null if there is no current
543
     * selection
544
     * 
545
     * @return the current presentable part, or null if there is no current
546
     *         selection
547
     */
548
    /*
549
     * not used private IPresentablePart getCurrentPresentablePart() { if
550
     * (current != null) { return current.getPresentablePart(); }
551
     * 
552
     * return null; }
553
     */
554
555
    private void presentationSelectionChanged(IPresentablePart newSelection) {
551
    private void presentationSelectionChanged(IPresentablePart newSelection) {
556
        setSelection(getLayoutPart(newSelection));
552
        setSelection(getLayoutPart(newSelection));
557
553
Lines 922-925 Link Here
922
            systemMenuManager.add(paneContribution);
918
            systemMenuManager.add(paneContribution);
923
        }
919
        }
924
    }
920
    }
921
922
	/**
923
	 * 
924
	 */
925
	public void showSystemMenu() {
926
		getPresentation().showSystemMenu();
927
	}
925
}
928
}
(-)Eclipse UI/org/eclipse/ui/internal/PresentableEditorPart.java (+17 lines)
Lines 15-22 Link Here
15
15
16
import org.eclipse.swt.graphics.Image;
16
import org.eclipse.swt.graphics.Image;
17
import org.eclipse.swt.graphics.Rectangle;
17
import org.eclipse.swt.graphics.Rectangle;
18
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.ui.IEditorReference;
19
import org.eclipse.ui.IEditorReference;
19
import org.eclipse.ui.IPropertyListener;
20
import org.eclipse.ui.IPropertyListener;
21
import org.eclipse.ui.internal.presentations.IPartMenu;
20
import org.eclipse.ui.presentations.IPresentablePart;
22
import org.eclipse.ui.presentations.IPresentablePart;
21
23
22
public class PresentableEditorPart implements IPresentablePart {
24
public class PresentableEditorPart implements IPresentablePart {
Lines 97-101 Link Here
97
	public boolean isBusy() {
99
	public boolean isBusy() {
98
		// editors do not support busy currently
100
		// editors do not support busy currently
99
		return false;
101
		return false;
102
	}
103
104
	/* (non-Javadoc)
105
	 * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar()
106
	 */
107
	public Control getToolBar() {
108
		return null;
109
	}
110
111
	/* (non-Javadoc)
112
	 * @see org.eclipse.ui.presentations.IPresentablePart#getPartMenu()
113
	 */
114
	public IPartMenu getMenu() {
115
		// TODO Auto-generated method stub
116
		return null;
100
	}
117
	}
101
}
118
}
(-)Eclipse UI/org/eclipse/ui/internal/PresentableViewPart.java (-6 / +44 lines)
Lines 16-25 Link Here
16
import org.eclipse.jface.util.IPropertyChangeListener;
16
import org.eclipse.jface.util.IPropertyChangeListener;
17
import org.eclipse.jface.util.PropertyChangeEvent;
17
import org.eclipse.jface.util.PropertyChangeEvent;
18
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Point;
19
import org.eclipse.swt.graphics.Rectangle;
20
import org.eclipse.swt.graphics.Rectangle;
21
import org.eclipse.swt.widgets.Control;
22
import org.eclipse.swt.widgets.ToolBar;
20
import org.eclipse.ui.IPropertyListener;
23
import org.eclipse.ui.IPropertyListener;
21
import org.eclipse.ui.IViewReference;
24
import org.eclipse.ui.IViewReference;
22
import org.eclipse.ui.IWorkbenchPartSite;
25
import org.eclipse.ui.IWorkbenchPartSite;
26
import org.eclipse.ui.internal.presentations.IPartMenu;
23
import org.eclipse.ui.presentations.IPresentablePart;
27
import org.eclipse.ui.presentations.IPresentablePart;
24
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
28
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
25
29
Lines 27-36 Link Here
27
31
28
    private final List listeners = new ArrayList();
32
    private final List listeners = new ArrayList();
29
 
33
 
30
31
    private ViewPane pane;
34
    private ViewPane pane;
32
    
35
    
33
    private boolean busy = false;
36
    private boolean busy = false;
37
    
38
    private IPartMenu viewMenu = new IPartMenu() {
39
		public void showMenu(Point location) {
40
			pane.showViewMenu(location);
41
		}
42
    };
34
43
35
    private final IPropertyListener propertyListenerProxy = new IPropertyListener() {
44
    private final IPropertyListener propertyListenerProxy = new IPropertyListener() {
36
45
Lines 52-68 Link Here
52
        				/* (non-Javadoc)
61
        				/* (non-Javadoc)
53
						 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
62
						 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
54
						 */
63
						 */
55
						public void propertyChange(PropertyChangeEvent event) {
64
						public void propertyChange(PropertyChangeEvent event) {							
56
							
57
							Boolean state = (Boolean) event.getNewValue();
65
							Boolean state = (Boolean) event.getNewValue();
58
							PresentableViewPart.this.busy = state.booleanValue();
66
							PresentableViewPart.this.busy = state.booleanValue();
59
							 for (int i = 0; i < listeners.size(); i++)
67
							firePropertyChange(IPresentablePart.PROP_BUSY);
60
				                ((IPropertyListener) listeners.get(i)).propertyChanged(
61
				                        PresentableViewPart.this, IPresentablePart.PROP_BUSY);
62
						}
68
						}
63
        			});
69
        			});
64
    }
70
    }
65
71
72
    public void firePropertyChange(int propertyId) {
73
		 for (int i = 0; i < listeners.size(); i++)
74
            ((IPropertyListener) listeners.get(i)).propertyChanged(
75
                    this, propertyId);    	
76
    }
77
    
66
    public void addPropertyListener(final IPropertyListener listener) {
78
    public void addPropertyListener(final IPropertyListener listener) {
67
        if (listeners.isEmpty())
79
        if (listeners.isEmpty())
68
                getViewReference().addPropertyListener(propertyListenerProxy);
80
                getViewReference().addPropertyListener(propertyListenerProxy);
Lines 121-126 Link Here
121
	 */
133
	 */
122
	public boolean isBusy() {
134
	public boolean isBusy() {
123
		return busy;
135
		return busy;
136
	}
137
138
	/* (non-Javadoc)
139
	 * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar()
140
	 */
141
	public Control getToolBar() {
142
		ToolBar control = pane.getToolBarManager().getControl();
143
		
144
		if (control.getItemCount() == 0) {
145
			control.setVisible(false);
146
			return null;
147
		}
148
		
149
		control.setVisible(true);
150
		return control;
151
	}
152
153
	/* (non-Javadoc)
154
	 * @see org.eclipse.ui.presentations.IPresentablePart#getPartMenu()
155
	 */
156
	public IPartMenu getMenu() {
157
		if (pane.hasViewMenu()) {
158
			return viewMenu;
159
		}
160
		
161
		return null;
124
	}
162
	}
125
	
163
	
126
	
164
	
(-)Eclipse UI/org/eclipse/ui/internal/ViewPane.java (-45 / +68 lines)
Lines 37-43 Link Here
37
import org.eclipse.swt.widgets.Control;
37
import org.eclipse.swt.widgets.Control;
38
import org.eclipse.swt.widgets.Menu;
38
import org.eclipse.swt.widgets.Menu;
39
import org.eclipse.swt.widgets.MenuItem;
39
import org.eclipse.swt.widgets.MenuItem;
40
import org.eclipse.swt.widgets.Sash;
41
import org.eclipse.swt.widgets.Shell;
40
import org.eclipse.swt.widgets.Shell;
42
import org.eclipse.swt.widgets.Text;
41
import org.eclipse.swt.widgets.Text;
43
import org.eclipse.swt.widgets.ToolBar;
42
import org.eclipse.swt.widgets.ToolBar;
Lines 95-103 Link Here
95
	 */
94
	 */
96
	private boolean showMenuButton = false;
95
	private boolean showMenuButton = false;
97
96
98
	//Created in o.e.ui.Perspective, disposed there.
99
	private Sash fastViewSash;
100
101
	/**
97
	/**
102
	 * Toolbar manager for the ISV toolbar.
98
	 * Toolbar manager for the ISV toolbar.
103
	 */
99
	 */
Lines 110-119 Link Here
110
			toolBarResized(toolBar, newCount);
106
			toolBarResized(toolBar, newCount);
111
			
107
			
112
			toolBar.layout();
108
			toolBar.layout();
113
			Composite parent = toolBar.getParent();
109
//			Composite parent = toolBar.getParent();
114
			parent.layout();
110
//			parent.layout();
115
			if (parent.getParent() != null)
111
//			if (parent.getParent() != null)
116
				parent.getParent().layout();
112
//				parent.getParent().layout();
117
		}
113
		}
118
	}
114
	}
119
115
Lines 289-296 Link Here
289
		// All actions on the System toolbar should be accessible on the pane menu.
285
		// All actions on the System toolbar should be accessible on the pane menu.
290
		if (control.getContent() == null) {
286
		if (control.getContent() == null) {
291
			// content can be null if view creation failed
287
			// content can be null if view creation failed
292
			if (locked)
288
//			if (locked)
293
				control.setTabList(new Control[] { isvToolBar , viewToolBar });
289
//				control.setTabList(new Control[] { isvToolBar , viewToolBar });
294
		} else {
290
		} else {
295
			if (locked)
291
			if (locked)
296
				control.setTabList(new Control[] { viewToolBar, control.getContent()});
292
				control.setTabList(new Control[] { viewToolBar, control.getContent()});
Lines 439-451 Link Here
439
	}
435
	}
440
	
436
	
441
	private void toolBarResized(ToolBar toolBar, int newSize) {
437
	private void toolBarResized(ToolBar toolBar, int newSize) {
442
		if (locked) {
438
		presentableAdapter.firePropertyChange(IPresentablePart.PROP_TOOLBAR);
443
			if (toolBar == viewToolBar) {
444
				((ViewForm)control).setTopRight(newSize == 0 ? null :viewToolBar);
445
			} else if (toolBar == isvToolBar) {
446
				((ViewForm)control).setTopCenter(newSize == 0 ? null : isvToolBar);
447
			}
448
		}
449
	}
439
	}
450
	
440
	
451
	/**
441
	/**
Lines 490-496 Link Here
490
		
480
		
491
		// ISV toolbar.
481
		// ISV toolbar.
492
		//			// 1GD0ISU: ITPUI:ALL - Dbl click on view tool cause zoom
482
		//			// 1GD0ISU: ITPUI:ALL - Dbl click on view tool cause zoom
493
		isvToolBar = new ToolBar(parentControl, barStyle);
483
		isvToolBar = new ToolBar(parentControl.getParent(), barStyle);
494
		
484
		
495
		
485
		
496
		
486
		
Lines 503-509 Link Here
503
				}
493
				}
504
			});
494
			});
505
		} else {
495
		} else {
506
			isvToolBar.setLayoutData(new GridData(GridData.FILL_BOTH));
496
			//isvToolBar.setLayoutData(new GridData(GridData.FILL_BOTH));
507
		}
497
		}
508
		IContributionItem[] isvItems = null;
498
		IContributionItem[] isvItems = null;
509
		if (isvToolBarMgr != null) {
499
		if (isvToolBarMgr != null) {
Lines 521-528 Link Here
521
		// whenever updating the tab colors
511
		// whenever updating the tab colors
522
		if (viewToolBar != null)
512
		if (viewToolBar != null)
523
		    ColorSchemeService.setViewColors(viewToolBar);
513
		    ColorSchemeService.setViewColors(viewToolBar);
524
		ColorSchemeService.setViewColors(isvToolBar);
514
		//ColorSchemeService.setViewColors(isvToolBar);
525
		ColorSchemeService.setViewColors(isvToolBar.getParent());
515
		ColorSchemeService.setViewColors(parentControl);
526
	}
516
	}
527
	
517
	
528
	/**
518
	/**
Lines 664-672 Link Here
664
			viewToolBarMgr.update(true);
654
			viewToolBarMgr.update(true);
665
		}
655
		}
666
	}
656
	}
667
	public void setFastViewSash(Sash s) {
668
		fastViewSash = s;
669
	}
670
657
671
	/* (non-Javadoc)
658
	/* (non-Javadoc)
672
	 * Method declared on PartPane.
659
	 * Method declared on PartPane.
Lines 765-778 Link Here
765
	 * Shows the pane menu (system menu) for this pane.
752
	 * Shows the pane menu (system menu) for this pane.
766
	 */
753
	 */
767
	public void showPaneMenu() {
754
	public void showPaneMenu() {
768
		// If this is a fast view, it may have been minimized. Do nothing in this case.
755
		ILayoutContainer container = getContainer();
769
		if (isFastView() && (page.getActiveFastView() != getViewReference()))
756
		
770
			return;
757
		if (container instanceof PartTabFolder) {
771
		// TODO should position menu relative to tab, as is done
758
			PartTabFolder folder = (PartTabFolder) container;
772
		// with editors.  Also need to take into account view titlebar if present
759
			
773
		Control ref = control.getContent() != null ? control.getContent() : control;
760
			folder.showSystemMenu();
774
		Point pos = ref.toDisplay(ref.getLocation());
761
		}		
775
		showPaneMenu(ref, pos);
776
	}
762
	}
777
	/**
763
	/**
778
	 * Return true if this view is a fast view.
764
	 * Return true if this view is a fast view.
Lines 797-806 Link Here
797
	 */
783
	 */
798
	protected Sashes findSashes() {
784
	protected Sashes findSashes() {
799
		Sashes result = new Sashes();
785
		Sashes result = new Sashes();
800
		if (isFastView()) {
801
			result.right = fastViewSash;
802
			return result;
803
		}
804
		
786
		
805
		ILayoutContainer container = getContainer();
787
		ILayoutContainer container = getContainer();
806
		
788
		
Lines 894-912 Link Here
894
	 * Show the view menu for this window.
876
	 * Show the view menu for this window.
895
	 */
877
	 */
896
	public void showViewMenu() {
878
	public void showViewMenu() {
897
879
		Rectangle bounds = pullDownButton.getBounds();
880
		Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
881
		topLeft = viewToolBar.toDisplay(topLeft);		
882
		
883
		Rectangle parentBounds = getControl().getBounds();
884
		topLeft.x += parentBounds.x;
885
		topLeft.y += parentBounds.y;
886
		
887
		showViewMenu(topLeft);
888
	}
889
	
890
	public void showViewMenu(Point location) {
898
		if (!hasViewMenu())
891
		if (!hasViewMenu())
899
			return;
892
			return;
900
893
	
901
		// If this is a fast view, it may have been minimized. Do nothing in this case.
894
		// If this is a fast view, it may have been minimized. Do nothing in this case.
902
		if (isFastView() && (page.getActiveFastView() != getViewReference()))
895
		if (isFastView() && (page.getActiveFastView() != getViewReference()))
903
			return;
896
			return;
904
897
	
905
		Menu aMenu = isvMenuMgr.createContextMenu(getControl());
898
		Menu aMenu = isvMenuMgr.createContextMenu(getControl().getParent());
906
		Rectangle bounds = pullDownButton.getBounds();
899
		aMenu.setLocation(location.x, location.y);
907
		Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
908
		topLeft = viewToolBar.toDisplay(topLeft);
909
		aMenu.setLocation(topLeft.x, topLeft.y);
910
		aMenu.setVisible(true);
900
		aMenu.setVisible(true);
911
	}
901
	}
912
	
902
	
Lines 933-939 Link Here
933
		IViewReference ref = getViewReference();
923
		IViewReference ref = getViewReference();
934
		
924
		
935
		if (status != null && !status.isDisposed()) {
925
		if (status != null && !status.isDisposed()) {
936
			status.setBackground(status.getParent().getBackground());
926
			ColorSchemeService.setViewColors(status);
927
			//status.setBackground(status.getParent().getBackground());
937
			boolean changed = false;
928
			boolean changed = false;
938
			String text = ref.getTitle();
929
			String text = ref.getTitle();
939
			
930
			
Lines 1085-1088 Link Here
1085
	public IPresentablePart getPresentablePart() {
1076
	public IPresentablePart getPresentablePart() {
1086
		return presentableAdapter;
1077
		return presentableAdapter;
1087
	}
1078
	}
1079
	
1080
	/* (non-Javadoc)
1081
	 * @see org.eclipse.ui.internal.LayoutPart#reparent(org.eclipse.swt.widgets.Composite)
1082
	 */
1083
	public void reparent(Composite newParent) {
1084
		super.reparent(newParent);
1085
		
1086
		if (isvToolBar != null) {
1087
			isvToolBar.setParent(newParent);
1088
		}
1089
	}
1090
	
1091
	/* (non-Javadoc)
1092
	 * @see org.eclipse.ui.internal.LayoutPart#moveAbove(org.eclipse.swt.widgets.Control)
1093
	 */
1094
	public void moveAbove(Control refControl) {
1095
		super.moveAbove(refControl);
1096
		
1097
		isvToolBar.moveAbove(control);
1098
	}
1099
	
1100
	/* (non-Javadoc)
1101
	 * @see org.eclipse.ui.internal.LayoutPart#setVisible(boolean)
1102
	 */
1103
	public void setVisible(boolean makeVisible) {
1104
		super.setVisible(makeVisible);
1105
		
1106
		if (isvToolBar != null) {
1107
			isvToolBar.setVisible(makeVisible);
1108
		}
1109
	}
1110
	
1088
}
1111
}
(-)Eclipse UI/org/eclipse/ui/internal/presentations/BasicStackPresentation.java (-29 / +255 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
11
package org.eclipse.ui.internal.presentations;
12
12
13
import java.util.ArrayList;
14
import java.util.List;
15
13
import org.eclipse.jface.action.IMenuManager;
16
import org.eclipse.jface.action.IMenuManager;
14
import org.eclipse.jface.action.MenuManager;
17
import org.eclipse.jface.action.MenuManager;
18
import org.eclipse.jface.resource.ColorRegistry;
15
import org.eclipse.jface.resource.FontRegistry;
19
import org.eclipse.jface.resource.FontRegistry;
16
import org.eclipse.jface.util.Geometry;
20
import org.eclipse.jface.util.Geometry;
17
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
Lines 24-44 Link Here
24
import org.eclipse.swt.events.MouseAdapter;
28
import org.eclipse.swt.events.MouseAdapter;
25
import org.eclipse.swt.events.MouseEvent;
29
import org.eclipse.swt.events.MouseEvent;
26
import org.eclipse.swt.events.MouseListener;
30
import org.eclipse.swt.events.MouseListener;
31
import org.eclipse.swt.events.SelectionAdapter;
32
import org.eclipse.swt.events.SelectionEvent;
27
import org.eclipse.swt.graphics.Color;
33
import org.eclipse.swt.graphics.Color;
34
import org.eclipse.swt.graphics.Image;
28
import org.eclipse.swt.graphics.Point;
35
import org.eclipse.swt.graphics.Point;
29
import org.eclipse.swt.graphics.Rectangle;
36
import org.eclipse.swt.graphics.Rectangle;
30
import org.eclipse.swt.widgets.Control;
37
import org.eclipse.swt.widgets.Control;
38
import org.eclipse.swt.widgets.Display;
31
import org.eclipse.swt.widgets.Event;
39
import org.eclipse.swt.widgets.Event;
32
import org.eclipse.swt.widgets.Listener;
40
import org.eclipse.swt.widgets.Listener;
33
import org.eclipse.swt.widgets.Menu;
41
import org.eclipse.swt.widgets.Menu;
42
import org.eclipse.swt.widgets.ToolBar;
43
import org.eclipse.swt.widgets.ToolItem;
34
import org.eclipse.ui.IPropertyListener;
44
import org.eclipse.ui.IPropertyListener;
35
import org.eclipse.ui.PlatformUI;
45
import org.eclipse.ui.PlatformUI;
46
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
36
import org.eclipse.ui.internal.IWorkbenchThemeConstants;
47
import org.eclipse.ui.internal.IWorkbenchThemeConstants;
48
import org.eclipse.ui.internal.WorkbenchImages;
49
import org.eclipse.ui.internal.WorkbenchMessages;
50
import org.eclipse.ui.internal.dnd.DragUtil;
37
import org.eclipse.ui.presentations.IPresentablePart;
51
import org.eclipse.ui.presentations.IPresentablePart;
38
import org.eclipse.ui.presentations.IStackPresentationSite;
52
import org.eclipse.ui.presentations.IStackPresentationSite;
39
import org.eclipse.ui.presentations.PresentationUtil;
53
import org.eclipse.ui.presentations.PresentationUtil;
40
import org.eclipse.ui.presentations.StackDropResult;
54
import org.eclipse.ui.presentations.StackDropResult;
41
import org.eclipse.ui.presentations.StackPresentation;
55
import org.eclipse.ui.presentations.StackPresentation;
56
import org.eclipse.ui.themes.ITheme;
42
57
43
/**
58
/**
44
 * Base class for StackPresentations that display IPresentableParts in a CTabFolder. 
59
 * Base class for StackPresentations that display IPresentableParts in a CTabFolder. 
Lines 52-57 Link Here
52
	private boolean activeState = false;
67
	private boolean activeState = false;
53
	private int tabPosition;
68
	private int tabPosition;
54
	private MenuManager systemMenuManager = new MenuManager();
69
	private MenuManager systemMenuManager = new MenuManager();
70
	private TabFolderLayout layout;
71
	
72
	private Color backgroundGradientStart;
73
	private Color backgroundGradientEnd;
74
	private Color background;
75
	
76
	//private ToolBar viewToolBar;
77
	//private ToolBarManager viewToolBarMgr;
78
	
79
	// Controls which will be inserted into the title bar if there is room, or above the client pane
80
	// if not
81
	private List topControls = new ArrayList();
82
	
83
	// Stand-in for the top controls
84
	//private Composite toolbarProxy;
55
	
85
	
56
	private int mousedownState = -1;
86
	private int mousedownState = -1;
57
	
87
	
Lines 128-133 Link Here
128
		}
158
		}
129
	};
159
	};
130
	
160
	
161
	public int getTopTrimStart() {
162
		return layout.getTrimStart();
163
	}
164
	
131
	private Listener resizeListener = new Listener() {
165
	private Listener resizeListener = new Listener() {
132
		public void handleEvent(Event e) {
166
		public void handleEvent(Event e) {
133
			setControlSize();
167
			setControlSize();
Lines 166-176 Link Here
166
			}
200
			}
167
		}
201
		}
168
	};
202
	};
203
	private ToolBar viewToolBar;
169
204
170
	public BasicStackPresentation(CTabFolder control, IStackPresentationSite stackSite) {
205
	public BasicStackPresentation(CTabFolder control, IStackPresentationSite stackSite) {
171
	    super(stackSite);
206
	    super(stackSite);
172
		tabFolder = control;
207
		tabFolder = control;
173
		
208
		
209
		layout = new TabFolderLayout(tabFolder);
210
		
211
		viewToolBar = new ToolBar(control.getParent(), SWT.HORIZONTAL 
212
				| SWT.FLAT | SWT.WRAP);
213
		
214
		ToolItem pullDownButton = new ToolItem(viewToolBar, SWT.PUSH);
215
		//				Image img = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU);
216
		Image hoverImage =
217
			WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU_HOVER);
218
		pullDownButton.setDisabledImage(hoverImage); // TODO: comment this out?
219
		// PR#1GE56QT - Avoid creation of unnecessary image.
220
		pullDownButton.setImage(hoverImage);
221
		//				pullDownButton.setHotImage(hoverImage);
222
		pullDownButton.setToolTipText(WorkbenchMessages.getString("Menu")); //$NON-NLS-1$
223
		pullDownButton.addSelectionListener(new SelectionAdapter() {
224
			public void widgetSelected(SelectionEvent e) {
225
				showViewMenu();
226
			}
227
		});
228
		
174
		// listener to switch between visible tabItems
229
		// listener to switch between visible tabItems
175
		tabFolder.addListener(SWT.Selection, selectionListener);
230
		tabFolder.addListener(SWT.Selection, selectionListener);
176
231
Lines 204-210 Link Here
204
				}
259
				}
205
			}
260
			}
206
		});
261
		});
207
						
262
		
263
		viewToolBar.setVisible(true);
264
		//viewToolBar.moveAbove(null);
265
		
266
		// Insert a bogus composite into the top-right of the tab folder. We do this to keep
267
		// track of where to draw the toolbars.
268
		//toolbarProxy = new Composite(tabFolder, SWT.NONE);
269
		
270
		//tabFolder.setTopRight(toolbarProxy);
271
		
272
		//titleLabel = new Label(control.getParent(), SWT.NONE);
273
		
274
		ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();	    
275
		ColorRegistry colorRegistry = currentTheme.getColorRegistry();
276
		Color endCol = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END); 
277
		
278
		setBackgroundColors(colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START),
279
				endCol, endCol);
280
		
281
		tabFolder.setTabHeight(24);
282
	}
283
284
	/**
285
	 * 
286
	 */
287
	protected void showViewMenu() {
288
		IPartMenu menu = getPartMenu();
289
		
290
		if (menu != null) {
291
			Rectangle bounds = DragUtil.getDisplayBounds(viewToolBar);
292
			menu.showMenu(new Point(bounds.x, bounds.y + bounds.height));
293
		}
208
	}
294
	}
209
295
210
	/**
296
	/**
Lines 268-274 Link Here
268
		
354
		
269
		CTabItem tab = getTab(part);
355
		CTabItem tab = getTab(part);
270
		initTab(tab, part);
356
		initTab(tab, part);
271
		if(property == IPresentablePart.PROP_BUSY){
357
		switch (property) {
358
		 case IPresentablePart.PROP_BUSY:
272
			FontRegistry registry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
359
			FontRegistry registry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
273
			if(part.isBusy())
360
			if(part.isBusy())
274
				tab.setFont(registry.getItalic(IWorkbenchThemeConstants.TAB_TEXT_FONT));
361
				tab.setFont(registry.getItalic(IWorkbenchThemeConstants.TAB_TEXT_FONT));
Lines 277-284 Link Here
277
					tab.setFont(registry.get(IWorkbenchThemeConstants.TAB_TEXT_FONT));
364
					tab.setFont(registry.get(IWorkbenchThemeConstants.TAB_TEXT_FONT));
278
				else
365
				else
279
					tab.setFont(registry.getBold(IWorkbenchThemeConstants.TAB_TEXT_FONT));
366
					tab.setFont(registry.getBold(IWorkbenchThemeConstants.TAB_TEXT_FONT));
280
			}
367
			}			
281
				
368
			break;
369
		 case IPresentablePart.PROP_TOOLBAR:
370
		 	setControlSize();
371
		 	break;
282
		}
372
		}
283
	}
373
	}
284
374
Lines 306-313 Link Here
306
	}
396
	}
307
	
397
	
308
	public void drawGradient(Color fgColor, Color [] bgColors, int [] percentages, boolean vertical) {
398
	public void drawGradient(Color fgColor, Color [] bgColors, int [] percentages, boolean vertical) {
399
		Display display = tabFolder.getDisplay();
400
		//Color c = display.getSystemColor(SWT.COLOR_BLUE);
401
402
		//fgColor = c;
403
//		tabFolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
404
//				 		                           display.getSystemColor(SWT.COLOR_BLUE),
405
//				 		                           display.getSystemColor(SWT.COLOR_WHITE), 
406
//				 		                           display.getSystemColor(SWT.COLOR_WHITE)},
407
//				 		               new int[] {25, 50, 100});
408
		
409
		//tabFolder.setBackground(display.getSystemColor(SWT.COLOR_DARK_BLUE));
410
		
309
		tabFolder.setSelectionForeground(fgColor);
411
		tabFolder.setSelectionForeground(fgColor);
310
		tabFolder.setSelectionBackground(bgColors, percentages, vertical);			    
412
		tabFolder.setSelectionBackground(bgColors, percentages, vertical);	
311
	}
413
	}
312
	
414
	
313
	public boolean isActive() {
415
	public boolean isActive() {
Lines 317-347 Link Here
317
	/**
419
	/**
318
	 * Set the size of a page in the folder.
420
	 * Set the size of a page in the folder.
319
	 */
421
	 */
320
	private void setControlSize() {
422
	protected void setControlSize() {
423
		// Set up the top-right controls
424
		List topRight = new ArrayList(2);
425
				
426
		Control toolbar = getCurrentToolbar();
427
		
428
		if (toolbar != null) {
429
			topRight.add(toolbar);
430
		}
431
		
432
		IPartMenu partMenu = getPartMenu();
433
		
434
		if (partMenu != null) {
435
			viewToolBar.moveAbove(null);
436
			topRight.add(viewToolBar);
437
			viewToolBar.setVisible(true);
438
		} else {
439
			viewToolBar.setVisible(false);
440
		}
441
		
442
		Control[] controls = (Control[])topRight.toArray(new Control[topRight.size()]);
443
		
444
		layout.setTopRight(controls);
445
		
321
		if (current == null || tabFolder == null)
446
		if (current == null || tabFolder == null)
322
			return;
447
			return;
323
//		Rectangle bounds;
448
324
		// @issue as above, the mere presence of a theme should not change the behaviour
449
		layout.layout();
325
//		if ((mapTabToPart.size() > 1)
450
		
326
//			|| ((tabThemeDescriptor != null) && (mapTabToPart.size() >= 1)))
451
		current.setBounds(layout.getClientBounds());
327
//			bounds = calculatePageBounds(tabFolder);
452
		
328
//		else
453
		updateTrimColours();
329
//			bounds = tabFolder.getBounds();
454
	}
330
		current.setBounds(calculatePageBounds(tabFolder));
455
	
331
		//current.moveAbove(tabFolder);
456
	protected IPartMenu getPartMenu() {
332
	}
457
		IPresentablePart part = getCurrentPart();		
333
	
458
		if (part == null) {
334
	public static Rectangle calculatePageBounds(CTabFolder folder) {
459
			return null;
335
		if (folder == null)
460
		}
336
			return new Rectangle(0, 0, 0, 0);
461
337
		Rectangle bounds = folder.getBounds();
462
		return part.getMenu();
338
		Rectangle offset = folder.getClientArea();
463
	}
339
		bounds.x += offset.x;
464
	
340
		bounds.y += offset.y;
465
	/**
341
		bounds.width = offset.width;
466
	 * Update the colours of the trim widgets based on whether they are
342
		bounds.height = offset.height;
467
	 * currently in the title bar or below it.
343
		return bounds;
468
	 */
344
	}	
469
	protected void updateTrimColours() {
470
		Color background = isTrimOnTop() ? backgroundGradientEnd : this.background ;
471
		
472
		Control[] trim = layout.getTopRight();
473
		
474
		for (int idx = 0; idx < trim.length; idx++) {
475
			Control next = trim[idx];
476
			
477
			Color nextCol = next.getBackground();
478
			
479
			if (nextCol != background) {
480
				next.setBackground(background);
481
			}
482
		}
483
		
484
		updateBackgroundColors();
485
	}
486
	
487
	protected boolean isTrimOnTop() {
488
		return layout.isTrimOnTop();
489
	}
490
	
491
//	protected Control[] getTopRight() {
492
//		return layout.getTopRight();
493
//	}
345
	
494
	
346
	/* (non-Javadoc)
495
	/* (non-Javadoc)
347
	 * @see org.eclipse.ui.internal.skins.Presentation#dispose()
496
	 * @see org.eclipse.ui.internal.skins.Presentation#dispose()
Lines 355-360 Link Here
355
		
504
		
356
		tabFolder.dispose();
505
		tabFolder.dispose();
357
		tabFolder = null;
506
		tabFolder = null;
507
		
508
		viewToolBar.dispose();
358
	}
509
	}
359
	
510
	
360
	/* (non-Javadoc)
511
	/* (non-Javadoc)
Lines 446-457 Link Here
446
		}
597
		}
447
	}
598
	}
448
	
599
	
600
	public IPresentablePart getCurrentPart() {
601
		return current;
602
	}
603
	
604
//	protected void setTopRight(List topRight) {
605
//		layout.setTopRight(topRight);
606
//		setControlSize();
607
//	}
608
	
449
	/* (non-Javadoc)
609
	/* (non-Javadoc)
450
	 * @see org.eclipse.ui.internal.skins.Presentation#setBounds(org.eclipse.swt.graphics.Rectangle)
610
	 * @see org.eclipse.ui.internal.skins.Presentation#setBounds(org.eclipse.swt.graphics.Rectangle)
451
	 */
611
	 */
452
	public void setBounds(Rectangle bounds) {
612
	public void setBounds(Rectangle bounds) {
453
		tabFolder.setBounds(bounds);
613
		tabFolder.setBounds(bounds);
454
		setControlSize();
614
		setControlSize();
615
		viewToolBar.moveAbove(getControl());
455
	}
616
	}
456
	
617
	
457
	/* (non-Javadoc)
618
	/* (non-Javadoc)
Lines 469-474 Link Here
469
			current.setVisible(isVisible);
630
			current.setVisible(isVisible);
470
		}
631
		}
471
		tabFolder.setVisible(isVisible);
632
		tabFolder.setVisible(isVisible);
633
		viewToolBar.setVisible(isVisible);
472
	}
634
	}
473
635
474
	/* (non-Javadoc)
636
	/* (non-Javadoc)
Lines 508-514 Link Here
508
	 * @see org.eclipse.ui.internal.skins.StackPresentation#dragOver(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point)
670
	 * @see org.eclipse.ui.internal.skins.StackPresentation#dragOver(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point)
509
	 */
671
	 */
510
	public StackDropResult dragOver(Control currentControl, Point location) {
672
	public StackDropResult dragOver(Control currentControl, Point location) {
511
		
512
		// Determine which tab we're currently dragging over
673
		// Determine which tab we're currently dragging over
513
		Point localPos = tabFolder.toControl(location);
674
		Point localPos = tabFolder.toControl(location);
514
		final CTabItem tabUnderPointer = tabFolder.getItem(localPos);
675
		final CTabItem tabUnderPointer = tabFolder.getItem(localPos);
Lines 521-525 Link Here
521
		
682
		
522
		return new StackDropResult(Geometry.toDisplay(tabFolder, tabUnderPointer.getBounds()),
683
		return new StackDropResult(Geometry.toDisplay(tabFolder, tabUnderPointer.getBounds()),
523
			tabFolder.indexOf(tabUnderPointer));
684
			tabFolder.indexOf(tabUnderPointer));
685
	}
686
	
687
	public int getGradientPercentage() {
688
		Rectangle clientBounds = getTabFolder().getBounds();
689
		
690
		int percentage = clientBounds.width == 0 ? 100 : Math.min(100, 
691
				100 * getTopTrimStart() / clientBounds.width);
692
		
693
		if (percentage < 0) {
694
			percentage = 0;
695
		}
696
		
697
		return percentage;	    
698
	}
699
	
700
	protected Control getCurrentToolbar() {
701
		IPresentablePart part = getCurrentPart();		
702
		if (part == null) {
703
			return null;
704
		}
705
706
		return part.getToolBar();
707
	}
708
	
709
	protected void setBackgroundColors(Color gradientStart, Color gradientEnd, Color background) {
710
		backgroundGradientStart = gradientStart;
711
		backgroundGradientEnd = gradientEnd;
712
		this.background = background;
713
		updateBackgroundColors();
714
		
715
		updateTrimColours();
716
	}
717
	
718
	protected void updateBackgroundColors() {
719
		Color [] c = new Color[3];
720
		c[0] = backgroundGradientStart;
721
		c[1] = backgroundGradientEnd;
722
		c[2] = c[1];
723
	
724
		int[] percents = new int[] {getGradientPercentage(), 100};				
725
	   
726
		getTabFolder().setBackground(c, percents, false);
727
		getTabFolder().setBackground(background);
728
	}
729
730
	/* (non-Javadoc)
731
	 * @see org.eclipse.ui.presentations.StackPresentation#showSystemMenu()
732
	 */
733
	public void showSystemMenu() {
734
		IPresentablePart part = getCurrentPart();
735
		if (part != null) {
736
			Rectangle bounds = DragUtil.getDisplayBounds(tabFolder);
737
			
738
			int idx = tabFolder.getSelectionIndex();
739
			if (idx > -1) {
740
				CTabItem item = tabFolder.getItem(idx);
741
				Rectangle itemBounds = item.getBounds();
742
				
743
				bounds.x += itemBounds.x;
744
				bounds.y += itemBounds.y;
745
			}
746
			
747
			Point location = new Point(bounds.x, bounds.y + tabFolder.getTabHeight());
748
			showPaneMenu(part, location);
749
		}
524
	}
750
	}
525
}
751
}
(-)Eclipse UI/org/eclipse/ui/internal/presentations/EditorPresentation.java (-2 / +2 lines)
Lines 269-276 Link Here
269
            		.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR);           
269
            		.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR);           
270
            bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
270
            bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
271
            bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
271
            bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
272
            percent[0] = currentTheme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT);
272
            percent[0] = getGradientPercentage();
273
            vertical = currentTheme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL);            
273
            vertical = false;            
274
        }
274
        }
275
275
276
        getTabFolder()
276
        getTabFolder()
(-)Eclipse UI/org/eclipse/ui/internal/presentations/NativeStackPresentation.java (+8 lines)
Lines 425-428 Link Here
425
//			tabFolder.indexOf(tabUnderPointer));
425
//			tabFolder.indexOf(tabUnderPointer));
426
		return null;
426
		return null;
427
	}
427
	}
428
429
	/* (non-Javadoc)
430
	 * @see org.eclipse.ui.presentations.StackPresentation#showSystemMenu()
431
	 */
432
	public void showSystemMenu() {
433
		// TODO Auto-generated method stub
434
		
435
	}
428
}
436
}
(-)Eclipse UI/org/eclipse/ui/internal/presentations/PartTabFolderPresentation.java (-2 / +41 lines)
Lines 36-43 Link Here
36
 */
36
 */
37
public class PartTabFolderPresentation extends BasicStackPresentation {
37
public class PartTabFolderPresentation extends BasicStackPresentation {
38
	
38
	
39
	private IPreferenceStore preferenceStore = WorkbenchPlugin.getDefault().getPreferenceStore();
39
	private IPreferenceStore preferenceStore = WorkbenchPlugin.getDefault().getPreferenceStore();	
40
		
40
	
41
	private final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
41
	private final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
42
		public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
42
		public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
43
			if (IPreferenceConstants.VIEW_TAB_POSITION.equals(propertyChangeEvent.getProperty()) && !isDisposed()) {
43
			if (IPreferenceConstants.VIEW_TAB_POSITION.equals(propertyChangeEvent.getProperty()) && !isDisposed()) {
Lines 53-60 Link Here
53
	public PartTabFolderPresentation(Composite parent, IStackPresentationSite newSite, int flags) {
53
	public PartTabFolderPresentation(Composite parent, IStackPresentationSite newSite, int flags) {
54
		
54
		
55
		super(new CTabFolder(parent, SWT.BORDER), newSite);
55
		super(new CTabFolder(parent, SWT.BORDER), newSite);
56
		
56
		CTabFolder tabFolder = getTabFolder();
57
		CTabFolder tabFolder = getTabFolder();
57
		
58
		
59
		tabFolder.setBackground(parent.getBackground());
60
		
58
		preferenceStore.addPropertyChangeListener(propertyChangeListener);
61
		preferenceStore.addPropertyChangeListener(propertyChangeListener);
59
		int tabLocation = preferenceStore.getInt(IPreferenceConstants.VIEW_TAB_POSITION); 
62
		int tabLocation = preferenceStore.getInt(IPreferenceConstants.VIEW_TAB_POSITION); 
60
		
63
		
Lines 75-80 Link Here
75
		
78
		
76
		tabFolder.setMinimizeVisible((flags & SWT.MIN) != 0);
79
		tabFolder.setMinimizeVisible((flags & SWT.MIN) != 0);
77
		tabFolder.setMaximizeVisible((flags & SWT.MAX) != 0);
80
		tabFolder.setMaximizeVisible((flags & SWT.MAX) != 0);
81
		
78
	}
82
	}
79
	
83
	
80
	/**
84
	/**
Lines 117-125 Link Here
117
	        fgColor = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR);
121
	        fgColor = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR);
118
            bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
122
            bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
119
            bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
123
            bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
124
            //percent[0] = getGradientPercentage();
125
            //vertical = false;
120
            percent[0] = currentTheme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT);
126
            percent[0] = currentTheme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT);
121
            vertical = currentTheme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL);
127
            vertical = currentTheme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL);
122
		}	
128
		}	
129
        
123
		drawGradient(fgColor, bgColors, percent, vertical);	
130
		drawGradient(fgColor, bgColors, percent, vertical);	
124
	}
131
	}
125
	
132
	
Lines 131-136 Link Here
131
		
138
		
132
		updateGradient();
139
		updateGradient();
133
	}
140
	}
141
	
134
	/* (non-Javadoc)
142
	/* (non-Javadoc)
135
	 * @see org.eclipse.ui.presentations.StackPresentation#dispose()
143
	 * @see org.eclipse.ui.presentations.StackPresentation#dispose()
136
	 */
144
	 */
Lines 138-141 Link Here
138
		preferenceStore.removePropertyChangeListener(propertyChangeListener);
146
		preferenceStore.removePropertyChangeListener(propertyChangeListener);
139
		super.dispose();
147
		super.dispose();
140
	}
148
	}
149
	
150
//	/* (non-Javadoc)
151
//	 * @see org.eclipse.ui.internal.presentations.BasicStackPresentation#setControlSize()
152
//	 */
153
//	protected void setControlSize() {		
154
//		super.setControlSize();
155
//		
156
//		updateTitleGradient();
157
//	}
158
//		
159
//	/* (non-Javadoc)
160
//	 * @see org.eclipse.ui.presentations.StackPresentation#selectPart(org.eclipse.ui.presentations.IPresentablePart)
161
//	 */
162
//	public void selectPart(IPresentablePart toSelect) {
163
//		super.selectPart(toSelect);
164
//		
165
//		updateTitleGradient();
166
//	}
167
//	
168
//	/**
169
//	 * Updates the title's gradient based on the current size and position of 
170
//	 * the toolbar. 
171
//	 */
172
//	protected void updateTitleGradient() {
173
//		ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();	    
174
//		ColorRegistry colorRegistry = currentTheme.getColorRegistry();
175
//		Color endCol = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END); 
176
//		
177
//		setBackgroundColors(colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START),
178
//				endCol, endCol);
179
//	}
141
}
180
}
(-)Eclipse UI/org/eclipse/ui/internal/themes/WorkbenchPreview.java (-1 / +1 lines)
Lines 148-154 Link Here
148
        Color [] colors = new Color[2];
148
        Color [] colors = new Color[2];
149
        colors[0] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
149
        colors[0] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
150
        colors[1] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
150
        colors[1] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
151
        folder.setBackground(colors, new int [] {theme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT)}, theme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL));
151
        folder.setBackground(colors, new int [] {100}, false);
152
        toolBar.setBackground(colors[1]);
152
        toolBar.setBackground(colors[1]);
153
        viewMessage.setBackground(colors[1]);
153
        viewMessage.setBackground(colors[1]);
154
        viewForm.setBackground(colors[1]);
154
        viewForm.setBackground(colors[1]);
(-)Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java (-3 / +43 lines)
Lines 12-18 Link Here
12
12
13
import org.eclipse.swt.graphics.Image;
13
import org.eclipse.swt.graphics.Image;
14
import org.eclipse.swt.graphics.Rectangle;
14
import org.eclipse.swt.graphics.Rectangle;
15
import org.eclipse.swt.widgets.Control;
16
import org.eclipse.ui.IEditorPart;
15
import org.eclipse.ui.IPropertyListener;
17
import org.eclipse.ui.IPropertyListener;
18
import org.eclipse.ui.IWorkbenchPart;
19
import org.eclipse.ui.internal.presentations.IPartMenu;
16
20
17
/**
21
/**
18
 * This is a skin's interface to the contents of a view or editor. Note that this
22
 * This is a skin's interface to the contents of a view or editor. Note that this
Lines 26-36 Link Here
26
public interface IPresentablePart {
30
public interface IPresentablePart {
27
	
31
	
28
	/**
32
	/**
33
	 * The property id for <code>isDirty</code>.
34
	 */
35
	public static final int PROP_DIRTY = IEditorPart.PROP_DIRTY;
36
37
	/**
38
	 * The property id for <code>getEditorInput</code>.
39
	 */
40
	public static final int PROP_INPUT = IEditorPart.PROP_INPUT;
41
42
	/**
43
	 * The property id for <code>getTitle</code>, <code>getTitleImage</code>
44
	 * and <code>getTitleToolTip</code>.
45
	 */
46
	public static final int PROP_TITLE = IWorkbenchPart.PROP_TITLE;
47
	
48
	/**
29
	 * The property id for <code>isBusy</code>.
49
	 * The property id for <code>isBusy</code>.
30
	 */
50
	 */
31
	public static final int PROP_BUSY = 0x92;
51
	public static final int PROP_BUSY = 0x92;
32
		
52
		
33
	/**
53
	/**
54
	 * The property id for toolbar changes
55
	 */
56
	public static final int PROP_TOOLBAR = 0x93;
57
	/**
34
	 * Sets the bounds of this part.
58
	 * Sets the bounds of this part.
35
	 *  
59
	 *  
36
	 * @param bounds
60
	 * @param bounds
Lines 58-66 Link Here
58
	 * <p>
82
	 * <p>
59
	 * The properties ids are as follows:
83
	 * The properties ids are as follows:
60
	 * <ul>
84
	 * <ul>
61
	 *   <li><code>IWorkbenchPart.PROP_TITLE</code> </li>
85
	 *   <li><code>PROP_TITLE</code> </li>
62
	 *   <li><code>IEditorPart.PROP_INPUT</code> </li>
86
	 *   <li><code>PROP_INPUT</code> </li>
63
	 *   <li><code>IEditorPart.PROP_DIRTY</code> </li>
87
	 *   <li><code>PROP_DIRTY</code> </li>
88
	 *   <li><code>PROP_TOOLBAR</code> </li>
64
	 * </ul>
89
	 * </ul>
65
	 * </p>
90
	 * </p>
66
	 *
91
	 *
Lines 138-142 Link Here
138
	 * @return boolean true if busy
163
	 * @return boolean true if busy
139
	 */
164
	 */
140
	public boolean isBusy();
165
	public boolean isBusy();
166
167
	/**
168
	 * Returns the local toolbar for this part, or null if this part does not
169
	 * have a local toolbar. Callers must not dispose or downcast the return value.
170
	 * 
171
	 * @return the local toolbar for the part, or null if none
172
	 */
173
	public Control getToolBar();
174
	
175
	/**
176
	 * Returns the menu for this part or null if none
177
	 * 
178
	 * @return the menu for this part or null if none
179
	 */
180
	public IPartMenu getMenu();
141
	
181
	
142
}
182
}
(-)Eclipse UI/org/eclipse/ui/presentations/PresentationUtil.java (-4 lines)
Lines 83-93 Link Here
83
			Event de = dragEvent;
83
			Event de = dragEvent;
84
			cancelDrag();
84
			cancelDrag();
85
			if (l != null) {
85
			if (l != null) {
86
				c.setCapture(true);
87
				l.handleEvent(de);
86
				l.handleEvent(de);
88
				if (!c.isDisposed()) {
89
					c.setCapture(false);
90
				}
91
			}
87
			}
92
		}
88
		}
93
	}	
89
	}	
(-)Eclipse UI/org/eclipse/ui/presentations/StackPresentation.java (+6 lines)
Lines 162-165 Link Here
162
	 * a drop target in this location.
162
	 * a drop target in this location.
163
	 */
163
	 */
164
	public abstract StackDropResult dragOver(Control currentControl, Point location);
164
	public abstract StackDropResult dragOver(Control currentControl, Point location);
165
	
166
	/**
167
	 * Instructs the presentation to display the system menu
168
	 *
169
	 */
170
	public abstract void showSystemMenu();
165
}
171
}
(-)Eclipse (+25 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
12
13
import org.eclipse.swt.graphics.Point;
14
15
/**
16
 * @since 3.0
17
 */
18
public interface IPartMenu {
19
	/**
20
	 * Displays the local menu for this part as a popup at the given location.
21
	 * 
22
	 * @param location position to display the menu at (display coordinates, not null)
23
	 */
24
	public void showMenu(Point location);
25
}
(-)Eclipse (+56 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
12
13
import org.eclipse.swt.graphics.Point;
14
import org.eclipse.swt.widgets.Control;
15
16
/**
17
 * Caches the preferred sizes of an array of controls
18
 * 
19
 * @since 3.0
20
 */
21
public class LayoutCache {
22
	private SizeCache[] caches;
23
	
24
	/**
25
	 * Creates a cache for the given array of controls
26
	 * 
27
	 * @param controls
28
	 */
29
	public LayoutCache(Control[] controls) {
30
		caches = new SizeCache[controls.length];
31
		for (int idx = 0; idx < controls.length; idx++) {
32
			caches[idx] = new SizeCache(controls[idx]);
33
		}
34
	}
35
	
36
	/**
37
	 * Computes the preferred size of the nth control
38
	 * 
39
	 * @param controlIndex index of the control whose size will be computed
40
	 * @param widthHint width of the control (or SWT.DEFAULT if unknown)
41
	 * @param heightHint height of the control (or SWT.DEFAULT if unknown)
42
	 * @return the preferred size of the control
43
	 */
44
	public Point computeSize(int controlIndex, int widthHint, int heightHint) {
45
		return caches[controlIndex].computeSize(widthHint, heightHint);
46
	}
47
	
48
	/**
49
	 * Flushes the cache
50
	 */
51
	public void flush() {
52
		for (int idx = 0; idx < caches.length; idx++) {
53
			caches[idx].flush();
54
		}
55
	}
56
}
(-)Eclipse (+119 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
12
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.graphics.Point;
15
import org.eclipse.swt.widgets.Control;
16
17
/**
18
 * Caches the preferred size of an SWT control
19
 * 
20
 * @since 3.0
21
 */
22
public class SizeCache {
23
	private Control control;
24
	
25
	private Point preferredSize;	
26
	private Point cachedWidth;
27
	private Point cachedHeight;
28
29
	/**
30
	 * Creates a cache for size computations on the given control
31
	 * 
32
	 * @param control the control for which 
33
	 */
34
	public SizeCache(Control control) {
35
		this.control = control;		
36
	}
37
	
38
	/**
39
	 * Flush the cache (should be called if the control's contents may have changed since the
40
	 * last query)
41
	 */
42
	public void flush() {
43
		preferredSize = null;
44
		cachedWidth = null;
45
		cachedHeight = null;
46
	}
47
	
48
	/**
49
	 * Computes the preferred size of the control.
50
	 *  
51
	 * @param widthHint the known width of the control (pixels) or SWT.DEFAULT if unknown
52
	 * @param heightHint the known height of the control (pixels) or SWT.DEFAULT if unknown
53
	 * @return the preferred size of the control
54
	 */
55
	public Point computeSize(int widthHint, int heightHint) {
56
		// No hints given -- find the preferred size
57
		if (widthHint == SWT.DEFAULT && heightHint == SWT.DEFAULT) {
58
			if (preferredSize == null) {
59
				preferredSize = computeSize(control, widthHint, heightHint);
60
			}
61
			
62
			return preferredSize;
63
		}
64
		
65
		// Computing a width
66
		if (widthHint == SWT.DEFAULT) {
67
			if (preferredSize != null && heightHint == preferredSize.y) {
68
				return preferredSize;
69
			}
70
71
			if (cachedWidth == null || cachedWidth.y != heightHint) {
72
				cachedWidth = computeSize(control, widthHint, heightHint);
73
			}
74
			
75
			return cachedWidth;
76
		}
77
		
78
		// Computing a height
79
		if (heightHint == SWT.DEFAULT) {
80
			// Check if we're asking about the preferred width
81
			if (preferredSize != null && widthHint == preferredSize.x) {
82
				return preferredSize;
83
			}
84
			
85
			if (cachedHeight == null || cachedHeight.x != widthHint) {
86
				cachedHeight = computeSize(control, widthHint, heightHint);
87
			}
88
			
89
			return cachedHeight;
90
		}
91
		
92
		return computeSize(control, widthHint, heightHint);
93
	}
94
	
95
	/**
96
	 * Compute the control's size, and ensure that non-default hints are returned verbatim
97
	 * (this tries to compensate for SWT's hints, which aren't really the outer width of the
98
	 * control).
99
	 * 
100
	 * @param control
101
	 * @param widthHint
102
	 * @param heightHint
103
	 * @return
104
	 */
105
	private static Point computeSize(Control control, int widthHint, int heightHint) {
106
		Point result = control.computeSize(widthHint, heightHint);
107
		
108
		if (widthHint != SWT.DEFAULT) {
109
			result.x = widthHint;
110
		}
111
		
112
		if (heightHint != SWT.DEFAULT) {
113
			result.y = heightHint;
114
		}
115
		
116
		return result;
117
	}
118
	
119
}
(-)Eclipse (+283 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
12
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.custom.CTabFolder;
15
import org.eclipse.swt.custom.CTabItem;
16
import org.eclipse.swt.graphics.Point;
17
import org.eclipse.swt.graphics.Rectangle;
18
import org.eclipse.swt.widgets.Control;
19
20
/**
21
 * Arranges the contents of a CTabFolder
22
 * 
23
 * @since 3.0
24
 */
25
public class TabFolderLayout {
26
	private CTabFolder tabFolder;
27
	private Control[] topControls;
28
	//private Control upperRightProxy;
29
	private LayoutCache cache;
30
	private Rectangle centerArea = new Rectangle(0,0,0,0);
31
	private int trimStart;
32
	private boolean trimOnTop = false;
33
	
34
	public TabFolderLayout(CTabFolder folder) {
35
		this.tabFolder = folder;
36
		
37
//		Composite cmp = new Composite(folder, SWT.DEFAULT);
38
//		upperRightProxy = cmp;
39
//		upperRightProxy.setVisible(false);
40
//		
41
//		cmp.setLayout(new Layout() {
42
//
43
//			protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
44
//				return new Point(10,10);
45
//			}
46
//
47
//			protected void layout(Composite composite, boolean flushCache) {
48
//				
49
//			}
50
//		});
51
52
		//tabFolder.setTopRight(upperRightProxy);
53
		setTopRight(new Control[0]);
54
	}
55
	
56
	public void dispose() {
57
		//tabFolder.setTopRight(null);
58
		//upperRightProxy.dispose();
59
	}
60
	
61
	public Control[] getTopRight() {
62
		return topControls;
63
	}
64
	
65
	public Rectangle getClientBounds() {
66
		return centerArea;
67
	}
68
	
69
	public int getTrimStart() {
70
		return trimStart;
71
	}
72
	
73
	public boolean isTrimOnTop() {
74
		return trimOnTop;
75
	}
76
	
77
	/**
78
	 * Sets the list of controls to be placed at the top-right of the CTabFolder
79
	 * 
80
	 * @param topRight a list of Control
81
	 */
82
	public void setTopRight(Control[] upperRight) {
83
		topControls = upperRight;
84
		
85
		cache = new LayoutCache(upperRight);
86
		layout();
87
	}
88
	
89
	/**
90
	 * Arranges all the controls in this layout
91
	 */
92
	public void layout() {
93
		cache.flush();		
94
				
95
		Rectangle trimRegion = getTitleTrimRegion();
96
97
		Point trimSize = computeTrimSize();
98
		
99
		Rectangle bounds = tabFolder.getBounds();
100
		
101
		trimStart = bounds.width;
102
		
103
		Rectangle clientBounds = calculatePageBounds(tabFolder);
104
		
105
		trimOnTop = trimSize.x < trimRegion.width && trimSize.y < trimRegion.height; 
106
		// Check if we have room for all our topRight controls on the top border
107
		if (trimOnTop) {
108
			
109
			trimStart -= trimSize.x;
110
			
111
			align(0, topControls.length, trimRegion);
112
113
			centerArea = clientBounds;
114
			
115
			return;
116
		}
117
		
118
		// Else we need to place the controls below the title
119
		
120
		Rectangle currentRect = new Rectangle(clientBounds.x, clientBounds.y, clientBounds.width, 0);
121
		
122
		int idx = 0;
123
		while (idx < topControls.length) {
124
			int startOfRow = idx;
125
			currentRect.height = 0;
126
			int rowWidth = 0;
127
			
128
			int rowCount = 0;
129
			while (idx + rowCount < topControls.length) {
130
				Point nextSize = cache.computeSize(idx + rowCount, SWT.DEFAULT, SWT.DEFAULT);
131
				
132
				rowWidth += nextSize.x;
133
				
134
				if (rowWidth > clientBounds.width) {
135
					break;
136
				}
137
				
138
				currentRect.height = Math.max(currentRect.height, nextSize.y);
139
				
140
				rowCount++;
141
			}
142
			
143
			if (rowCount > 0) {
144
				align(idx, rowCount, currentRect);
145
				idx += rowCount;
146
			} else {
147
				Point size = cache.computeSize(idx, clientBounds.width, SWT.DEFAULT);
148
149
				currentRect.height = size.y;
150
				topControls[idx].setBounds(currentRect);
151
				
152
				idx++;
153
			}
154
			
155
			currentRect.y += currentRect.height;
156
		}
157
		
158
		centerArea = new Rectangle(clientBounds.x, currentRect.y, clientBounds.width, 
159
					clientBounds.height + clientBounds.y - currentRect.y);
160
	}
161
	
162
	/**
163
	 * Right-alignes a subset of the top controls in the given region.
164
	 * 
165
	 * @param firstControl the index of the leftmost control to arrange
166
	 * @param numControls number of controls to arrange
167
	 * @param region region in which to arrange the controls
168
	 */
169
	private void align(int firstControl, int numControls, Rectangle region) {
170
		int last = firstControl + numControls;
171
		int currentPos = region.x + region.width;
172
		
173
		// Arrange controls from right to left
174
		for (int idx = firstControl + numControls - 1; idx >= firstControl; idx--) {
175
			Point size = cache.computeSize(idx, SWT.DEFAULT, SWT.DEFAULT);
176
			
177
			topControls[idx].setBounds(currentPos - size.x, region.y, size.x, size.y);
178
179
			currentPos -= size.x;
180
		}
181
	}
182
	
183
	
184
	/**
185
	 * Returns the region in the title where a toolbar could be rendered in coordinates
186
	 * relative to the tab folder's parent.
187
	 * 
188
	 * @return
189
	 */
190
	protected Rectangle getTitleTrimRegion() {
191
		Rectangle result = new Rectangle(0,0,0,0); 
192
		
193
		int itemCount = tabFolder.getItemCount(); 
194
		if (itemCount > 0) {
195
			CTabItem item = tabFolder.getItem(itemCount - 1);
196
			
197
			Rectangle itemBounds = item.getBounds();
198
			
199
			result.x = itemBounds.x + itemBounds.width;
200
			result.height = itemBounds.height;
201
			result.y = itemBounds.y;
202
			result.width = getAvailableSpace(tabFolder);
203
		}
204
		
205
		Rectangle bounds = tabFolder.getBounds();
206
		
207
		result.x += bounds.x;
208
		result.y += bounds.y;
209
		
210
		int borderSize = 1;
211
		result.y += borderSize;
212
		result.height -= borderSize;
213
		
214
		// Amount to shift to avoid stomping on the curve
215
		int xShift = 3;
216
		result.x += xShift;
217
		result.width -= xShift;
218
		
219
		return result;
220
	}
221
	
222
	/**
223
	 * Computes the maximium size available for the trim controls without causing
224
	 * tabs to disappear.
225
	 * 
226
	 * @param folder
227
	 * @return the amount of empty space to the right of the tabs
228
	 */
229
	protected static int getAvailableSpace(CTabFolder folder) {
230
		int available = folder.getBounds().width;
231
		
232
		available -= 2 * folder.getBorderWidth();
233
		available -= folder.getChevronBounds().width;
234
		available -= folder.getMaximizeBounds().width;
235
		available -= folder.getMinimizeBounds().width;
236
		
237
		// Add a safety margin to avoid stomping on the curve
238
		available -= 10;
239
		
240
		CTabItem[] tabs = folder.getItems();
241
		for (int idx = 0; idx < tabs.length; idx++) {
242
			CTabItem item = tabs[idx];
243
			
244
			if (!item.isShowing()) {
245
				return 0;
246
			}
247
			
248
			available -= item.getBounds().width;
249
		}
250
		
251
		return Math.max(0, available);
252
	}
253
		
254
	/**
255
	 * Returns the total preferred width of the top controls
256
	 * 
257
	 * @return the total preferred width of the top controls
258
	 */
259
	protected Point computeTrimSize() {
260
		int width = 0;
261
		int height = 0;
262
		for (int idx = 0; idx < topControls.length; idx++) {
263
			Point next = cache.computeSize(idx, SWT.DEFAULT, SWT.DEFAULT);
264
			width += next.x;
265
			height = Math.max(height, next.y);
266
		}
267
		
268
		return new Point(width, height);
269
	}
270
	
271
	private static Rectangle calculatePageBounds(CTabFolder folder) {
272
		if (folder == null)
273
			return new Rectangle(0, 0, 0, 0);
274
		Rectangle bounds = folder.getBounds();
275
		Rectangle offset = folder.getClientArea();
276
		bounds.x += offset.x;
277
		bounds.y += offset.y;
278
		bounds.width = offset.width;
279
		bounds.height = offset.height;
280
		return bounds;
281
	}	
282
283
}

Return to bug 55156