Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 8652 Details for
Bug 55156
[RCP] Need access to view toolbar from presentation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Replacement patch where the theme reaction code works property (including the toolbar change)
presentation_toolbar_patch2.txt (text/plain), 40.49 KB, created by
Kim Horne
on 2004-03-18 09:02:12 EST
(
hide
)
Description:
Replacement patch where the theme reaction code works property (including the toolbar change)
Filename:
MIME Type:
Creator:
Kim Horne
Created:
2004-03-18 09:02:12 EST
Size:
40.49 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/internal/ColorSchemeService.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ColorSchemeService.java,v >retrieving revision 1.8 >diff -u -r1.8 ColorSchemeService.java >--- Eclipse UI/org/eclipse/ui/internal/ColorSchemeService.java 18 Mar 2004 01:30:05 -0000 1.8 >+++ Eclipse UI/org/eclipse/ui/internal/ColorSchemeService.java 18 Mar 2004 13:55:29 -0000 >@@ -126,9 +126,10 @@ > c[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START); > c[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END); > >- percent[0] = theme.getInt(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT); >- vertical = theme.getBoolean(IWorkbenchThemeConstants.ACTIVE_TAB_VERTICAL); >- >+ percent[0] = presentation.getGradientPercentage(); >+ vertical = false; >+ >+ // Note: This is currently being overridden in PartTabFolderPresentation > control.setBackground(c, percent, vertical); > > if (presentation.isActive()) { >Index: Eclipse UI/org/eclipse/ui/internal/IWorkbenchThemeConstants.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IWorkbenchThemeConstants.java,v >retrieving revision 1.2 >diff -u -r1.2 IWorkbenchThemeConstants.java >--- Eclipse UI/org/eclipse/ui/internal/IWorkbenchThemeConstants.java 17 Mar 2004 19:12:31 -0000 1.2 >+++ Eclipse UI/org/eclipse/ui/internal/IWorkbenchThemeConstants.java 18 Mar 2004 13:55:29 -0000 >@@ -30,8 +30,5 @@ > public static final String INACTIVE_TAB_BG_END = "org.eclipse.ui.workbench.INACTIVE_TAB_BG_END"; //$NON-NLS-1$ > > public static final String ACTIVE_TAB_PERCENT = "org.eclipse.ui.workbench.ACTIVE_TAB_PERCENT"; //$NON-NLS-1$ >- public static final String INACTIVE_TAB_PERCENT = "org.eclipse.ui.workbench.INACTIVE_TAB_PERCENT"; //$NON-NLS-1$ >- >- public static final String ACTIVE_TAB_VERTICAL = "org.eclipse.ui.workbench.ACTIVE_TAB_VERTICAL"; //$NON-NLS-1$ >- public static final String INACTIVE_TAB_VERTICAL = "org.eclipse.ui.workbench.INACTIVE_TAB_VERTICAL"; //$NON-NLS-1$ >+ public static final String ACTIVE_TAB_VERTICAL = "org.eclipse.ui.workbench.ACTIVE_TAB_VERTICAL"; //$NON-NLS-1$ > } >Index: Eclipse UI/org/eclipse/ui/internal/PartTabFolder.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartTabFolder.java,v >retrieving revision 1.49 >diff -u -r1.49 PartTabFolder.java >--- Eclipse UI/org/eclipse/ui/internal/PartTabFolder.java 17 Mar 2004 21:07:12 -0000 1.49 >+++ Eclipse UI/org/eclipse/ui/internal/PartTabFolder.java 18 Mar 2004 13:55:30 -0000 >@@ -40,6 +40,16 @@ > import org.eclipse.ui.presentations.StackDropResult; > import org.eclipse.ui.presentations.StackPresentation; > >+/** >+ * Manages a set of ViewPanes that are docked into the workbench window. The container for a PartTabFolder >+ * is always a PartSashContainer (or null), and its children are always either PartPlaceholders or PartPanes. >+ * >+ * TODO: write a common base class for EditorWorkbook and PartTabFolder. >+ * TODO: remove the LayoutPart superclass. All code can either refer to PartPane, >+ * PartPlaceholder, PartSashContainer, or the common base class for EditorWorkbook and PartTabFolder. >+ * The frequent downcasting is due to the fact that much of the code tries to use LayoutPart >+ * or ILayoutContainer references for many different purposes. >+ */ > public class PartTabFolder extends LayoutPart implements ILayoutContainer { > > private boolean active = false; >@@ -537,20 +547,6 @@ > DragUtil > .performDrag(part, DragUtil.getDisplayBounds(part.getControl())); > } >- >- /** >- * Returns the current presentable part, or null if there is no current >- * selection >- * >- * @return the current presentable part, or null if there is no current >- * selection >- */ >- /* >- * not used private IPresentablePart getCurrentPresentablePart() { if >- * (current != null) { return current.getPresentablePart(); } >- * >- * return null; } >- */ > > private void presentationSelectionChanged(IPresentablePart newSelection) { > setSelection(getLayoutPart(newSelection)); >Index: Eclipse UI/org/eclipse/ui/internal/PresentableEditorPart.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PresentableEditorPart.java,v >retrieving revision 1.5 >diff -u -r1.5 PresentableEditorPart.java >--- Eclipse UI/org/eclipse/ui/internal/PresentableEditorPart.java 17 Mar 2004 17:37:06 -0000 1.5 >+++ Eclipse UI/org/eclipse/ui/internal/PresentableEditorPart.java 18 Mar 2004 13:55:30 -0000 >@@ -15,6 +15,7 @@ > > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.IEditorReference; > import org.eclipse.ui.IPropertyListener; > import org.eclipse.ui.presentations.IPresentablePart; >@@ -97,5 +98,12 @@ > public boolean isBusy() { > // editors do not support busy currently > return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar() >+ */ >+ public Control getToolBar() { >+ return null; > } > } >Index: Eclipse UI/org/eclipse/ui/internal/PresentableViewPart.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PresentableViewPart.java,v >retrieving revision 1.7 >diff -u -r1.7 PresentableViewPart.java >--- Eclipse UI/org/eclipse/ui/internal/PresentableViewPart.java 17 Mar 2004 17:37:06 -0000 1.7 >+++ Eclipse UI/org/eclipse/ui/internal/PresentableViewPart.java 18 Mar 2004 13:55:30 -0000 >@@ -17,6 +17,7 @@ > import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.IPropertyListener; > import org.eclipse.ui.IViewReference; > import org.eclipse.ui.IWorkbenchPartSite; >@@ -27,7 +28,6 @@ > > private final List listeners = new ArrayList(); > >- > private ViewPane pane; > > private boolean busy = false; >@@ -121,6 +121,13 @@ > */ > public boolean isBusy() { > return busy; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar() >+ */ >+ public Control getToolBar() { >+ return pane.getToolBarManager().getControl(); > } > > >Index: Eclipse UI/org/eclipse/ui/internal/ViewPane.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewPane.java,v >retrieving revision 1.51 >diff -u -r1.51 ViewPane.java >--- Eclipse UI/org/eclipse/ui/internal/ViewPane.java 17 Mar 2004 11:36:11 -0000 1.51 >+++ Eclipse UI/org/eclipse/ui/internal/ViewPane.java 18 Mar 2004 13:55:30 -0000 >@@ -289,8 +289,8 @@ > // All actions on the System toolbar should be accessible on the pane menu. > if (control.getContent() == null) { > // content can be null if view creation failed >- if (locked) >- control.setTabList(new Control[] { isvToolBar , viewToolBar }); >+// if (locked) >+// control.setTabList(new Control[] { isvToolBar , viewToolBar }); > } else { > if (locked) > control.setTabList(new Control[] { viewToolBar, control.getContent()}); >@@ -440,11 +440,12 @@ > > private void toolBarResized(ToolBar toolBar, int newSize) { > if (locked) { >- if (toolBar == viewToolBar) { >- ((ViewForm)control).setTopRight(newSize == 0 ? null :viewToolBar); >- } else if (toolBar == isvToolBar) { >- ((ViewForm)control).setTopCenter(newSize == 0 ? null : isvToolBar); >- } >+ //if (toolBar == viewToolBar) { >+ // ((ViewForm)control).setTopRight(newSize == 0 ? null :viewToolBar); >+ //} >+// else if (toolBar == isvToolBar) { >+ //((ViewForm)control).setTopCenter(newSize == 0 ? null : isvToolBar); >+ //} > } > } > >@@ -490,7 +491,7 @@ > > // ISV toolbar. > // // 1GD0ISU: ITPUI:ALL - Dbl click on view tool cause zoom >- isvToolBar = new ToolBar(parentControl, barStyle); >+ isvToolBar = new ToolBar(parentControl.getParent(), barStyle); > > > >@@ -503,7 +504,7 @@ > } > }); > } else { >- isvToolBar.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ //isvToolBar.setLayoutData(new GridData(GridData.FILL_BOTH)); > } > IContributionItem[] isvItems = null; > if (isvToolBarMgr != null) { >@@ -521,8 +522,8 @@ > // whenever updating the tab colors > if (viewToolBar != null) > ColorSchemeService.setViewColors(viewToolBar); >- ColorSchemeService.setViewColors(isvToolBar); >- ColorSchemeService.setViewColors(isvToolBar.getParent()); >+ //ColorSchemeService.setViewColors(isvToolBar); >+ //ColorSchemeService.setViewColors(isvToolBar.getParent()); > } > > /** >@@ -1081,4 +1082,60 @@ > public IPresentablePart getPresentablePart() { > return presentableAdapter; > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.LayoutPart#reparent(org.eclipse.swt.widgets.Composite) >+ */ >+ public void reparent(Composite newParent) { >+ super.reparent(newParent); >+ >+ if (isvToolBar != null) { >+ isvToolBar.setParent(newParent); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.LayoutPart#moveAbove(org.eclipse.swt.widgets.Control) >+ */ >+ public void moveAbove(Control refControl) { >+ super.moveAbove(refControl); >+ >+ isvToolBar.moveAbove(control); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.LayoutPart#setVisible(boolean) >+ */ >+ public void setVisible(boolean makeVisible) { >+ super.setVisible(makeVisible); >+ >+ if (isvToolBar != null) { >+ isvToolBar.setVisible(makeVisible); >+ } >+ } >+ >+ /** >+ * @param bounds >+ */ >+ public void setToolbarBounds(Rectangle bounds) { >+ if (isvToolBar != null) { >+ isvToolBar.update(); >+ isvToolBar.setBounds(bounds); >+ } >+ } >+ >+ /** >+ * @param hint >+ * @param hint2 >+ * @return >+ */ >+ public Point computePreferredToolbarSize(int hint, int hint2) { >+ if (isvToolBar != null) { >+ isvToolBar.update(); >+ return isvToolBar.computeSize(hint, hint2); >+ } >+ >+ return new Point(0,0); >+ } >+ > } >Index: Eclipse UI/org/eclipse/ui/internal/presentations/BasicStackPresentation.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/BasicStackPresentation.java,v >retrieving revision 1.12 >diff -u -r1.12 BasicStackPresentation.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/BasicStackPresentation.java 18 Mar 2004 00:53:35 -0000 1.12 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/BasicStackPresentation.java 18 Mar 2004 13:55:31 -0000 >@@ -10,6 +10,9 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.presentations; > >+import java.util.ArrayList; >+import java.util.List; >+ > import org.eclipse.jface.action.IMenuManager; > import org.eclipse.jface.action.MenuManager; > import org.eclipse.jface.resource.FontRegistry; >@@ -28,6 +31,7 @@ > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Menu; >@@ -52,6 +56,14 @@ > private boolean activeState = false; > private int tabPosition; > private MenuManager systemMenuManager = new MenuManager(); >+ private TabFolderLayout layout; >+ >+ // Controls which will be inserted into the title bar if there is room, or above the client pane >+ // if not >+ private List topControls = new ArrayList(); >+ >+ // Stand-in for the top controls >+ //private Composite toolbarProxy; > > private int mousedownState = -1; > >@@ -128,6 +140,10 @@ > } > }; > >+ public int getTopTrimStart() { >+ return layout.getTrimStart(); >+ } >+ > private Listener resizeListener = new Listener() { > public void handleEvent(Event e) { > setControlSize(); >@@ -170,6 +186,7 @@ > public BasicStackPresentation(CTabFolder control, IStackPresentationSite stackSite) { > super(stackSite); > tabFolder = control; >+ layout = new TabFolderLayout(tabFolder); > > // listener to switch between visible tabItems > tabFolder.addListener(SWT.Selection, selectionListener); >@@ -204,7 +221,12 @@ > } > } > }); >- >+ >+ // Insert a bogus composite into the top-right of the tab folder. We do this to keep >+ // track of where to draw the toolbars. >+ //toolbarProxy = new Composite(tabFolder, SWT.NONE); >+ >+ //tabFolder.setTopRight(toolbarProxy); > } > > /** >@@ -306,6 +328,18 @@ > } > > public void drawGradient(Color fgColor, Color [] bgColors, int [] percentages, boolean vertical) { >+ Display display = tabFolder.getDisplay(); >+ Color c = display.getSystemColor(SWT.COLOR_BLUE); >+ >+ //fgColor = c; >+// tabFolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), >+// display.getSystemColor(SWT.COLOR_BLUE), >+// display.getSystemColor(SWT.COLOR_WHITE), >+// display.getSystemColor(SWT.COLOR_WHITE)}, >+// new int[] {25, 50, 100}); >+ >+ //tabFolder.setBackground(display.getSystemColor(SWT.COLOR_DARK_BLUE)); >+ > tabFolder.setSelectionForeground(fgColor); > tabFolder.setSelectionBackground(bgColors, percentages, vertical); > } >@@ -317,7 +351,7 @@ > /** > * Set the size of a page in the folder. > */ >- private void setControlSize() { >+ protected void setControlSize() { > if (current == null || tabFolder == null) > return; > // Rectangle bounds; >@@ -327,22 +361,12 @@ > // bounds = calculatePageBounds(tabFolder); > // else > // bounds = tabFolder.getBounds(); >- current.setBounds(calculatePageBounds(tabFolder)); >+ layout.layout(); >+ current.setBounds(layout.getClientBounds()); >+ > //current.moveAbove(tabFolder); > } > >- public static Rectangle calculatePageBounds(CTabFolder folder) { >- if (folder == null) >- return new Rectangle(0, 0, 0, 0); >- Rectangle bounds = folder.getBounds(); >- Rectangle offset = folder.getClientArea(); >- bounds.x += offset.x; >- bounds.y += offset.y; >- bounds.width = offset.width; >- bounds.height = offset.height; >- return bounds; >- } >- > /* (non-Javadoc) > * @see org.eclipse.ui.internal.skins.Presentation#dispose() > */ >@@ -443,6 +467,15 @@ > } > } > >+ public IPresentablePart getCurrentPart() { >+ return current; >+ } >+ >+ protected void setTopRight(Control[] topRight) { >+ layout.setTopRight(topRight); >+ setControlSize(); >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.ui.internal.skins.Presentation#setBounds(org.eclipse.swt.graphics.Rectangle) > */ >@@ -505,7 +538,6 @@ > * @see org.eclipse.ui.internal.skins.StackPresentation#dragOver(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point) > */ > public StackDropResult dragOver(Control currentControl, Point location) { >- > // Determine which tab we're currently dragging over > Point localPos = tabFolder.toControl(location); > final CTabItem tabUnderPointer = tabFolder.getItem(localPos); >@@ -519,4 +551,18 @@ > return new StackDropResult(Geometry.toDisplay(tabFolder, tabUnderPointer.getBounds()), > tabFolder.indexOf(tabUnderPointer)); > } >+ >+ public int getGradientPercentage() { >+ Rectangle clientBounds = getTabFolder().getBounds(); >+ >+ int percentage = clientBounds.width == 0 ? 100 : Math.min(100, >+ 100 * getTopTrimStart() / clientBounds.width); >+ >+ if (percentage < 0) { >+ percentage = 0; >+ } >+ >+ return percentage; >+ } >+ > } >Index: Eclipse UI/org/eclipse/ui/internal/presentations/EditorPresentation.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/EditorPresentation.java,v >retrieving revision 1.8 >diff -u -r1.8 EditorPresentation.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/EditorPresentation.java 18 Mar 2004 01:30:05 -0000 1.8 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/EditorPresentation.java 18 Mar 2004 13:55:31 -0000 >@@ -264,8 +264,8 @@ > .get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR); > bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START); > bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END); >- percent[0] = currentTheme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT); >- vertical = currentTheme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL); >+ percent[0] = getGradientPercentage(); >+ vertical = false; > } > > getTabFolder() >Index: Eclipse UI/org/eclipse/ui/internal/presentations/PartTabFolderPresentation.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PartTabFolderPresentation.java,v >retrieving revision 1.8 >diff -u -r1.8 PartTabFolderPresentation.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/PartTabFolderPresentation.java 18 Mar 2004 01:30:05 -0000 1.8 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/PartTabFolderPresentation.java 18 Mar 2004 13:55:31 -0000 >@@ -21,11 +21,13 @@ > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Font; > import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.internal.ColorSchemeService; > import org.eclipse.ui.internal.IPreferenceConstants; > import org.eclipse.ui.internal.IWorkbenchThemeConstants; > import org.eclipse.ui.internal.WorkbenchPlugin; >+import org.eclipse.ui.presentations.IPresentablePart; > import org.eclipse.ui.presentations.IStackPresentationSite; > import org.eclipse.ui.themes.ITheme; > >@@ -36,8 +38,8 @@ > */ > public class PartTabFolderPresentation extends BasicStackPresentation { > >- private IPreferenceStore preferenceStore = WorkbenchPlugin.getDefault().getPreferenceStore(); >- >+ private IPreferenceStore preferenceStore = WorkbenchPlugin.getDefault().getPreferenceStore(); >+ > private final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { > public void propertyChange(PropertyChangeEvent propertyChangeEvent) { > if (IPreferenceConstants.VIEW_TAB_POSITION.equals(propertyChangeEvent.getProperty()) && !isDisposed()) { >@@ -53,6 +55,7 @@ > public PartTabFolderPresentation(Composite parent, IStackPresentationSite newSite, int flags) { > > super(new CTabFolder(parent, SWT.BORDER), newSite); >+ > CTabFolder tabFolder = getTabFolder(); > > preferenceStore.addPropertyChangeListener(propertyChangeListener); >@@ -117,9 +120,10 @@ > fgColor = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR); > bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START); > bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END); >- percent[0] = currentTheme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT); >- vertical = currentTheme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL); >+ percent[0] = getGradientPercentage(); >+ vertical = false; > } >+ > drawGradient(fgColor, bgColors, percent, vertical); > } > >@@ -138,4 +142,66 @@ > preferenceStore.removePropertyChangeListener(propertyChangeListener); > super.dispose(); > } >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.presentations.BasicStackPresentation#setControlSize() >+ */ >+ protected void setControlSize() { >+ super.setControlSize(); >+ >+ updateTitleGradient(); >+ } >+ >+ protected Control getCurrentToolbar() { >+ IPresentablePart part = getCurrentPart(); >+ if (part == null) { >+ return null; >+ } >+ >+ return part.getToolBar(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.presentations.StackPresentation#selectPart(org.eclipse.ui.presentations.IPresentablePart) >+ */ >+ public void selectPart(IPresentablePart toSelect) { >+ super.selectPart(toSelect); >+ >+ Control toolbar = getCurrentToolbar(); >+ >+ if (toolbar == null) { >+ setTopRight(new Control[0]); >+ } else { >+ ColorSchemeService.setViewColors(toolbar); >+ setTopRight(new Control[] {toolbar}); >+ >+ ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); >+ ColorRegistry colorRegistry = currentTheme.getColorRegistry(); >+ >+ Color c = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END); >+ >+ toolbar.setBackground(c); >+ } >+ >+ //getTabFolder().redraw(); >+ //updateToolbar(); >+ updateTitleGradient(); >+ } >+ >+ /** >+ * Updates the title's gradient based on the current size and position of >+ * the toolbar. >+ */ >+ protected void updateTitleGradient() { >+ ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); >+ ColorRegistry colorRegistry = currentTheme.getColorRegistry(); >+ >+ Color [] c = new Color[2]; >+ c[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START); >+ c[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END); >+ >+ int[] percents = new int[] {getGradientPercentage()}; >+ >+ getTabFolder().setBackground(c, percents, false); >+ } >+ > } >Index: Eclipse UI/org/eclipse/ui/internal/themes/WorkbenchPreview.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/WorkbenchPreview.java,v >retrieving revision 1.6 >diff -u -r1.6 WorkbenchPreview.java >--- Eclipse UI/org/eclipse/ui/internal/themes/WorkbenchPreview.java 18 Mar 2004 00:10:38 -0000 1.6 >+++ Eclipse UI/org/eclipse/ui/internal/themes/WorkbenchPreview.java 18 Mar 2004 13:55:31 -0000 >@@ -148,7 +148,7 @@ > Color [] colors = new Color[2]; > colors[0] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START); > colors[1] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END); >- folder.setBackground(colors, new int [] {theme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT)}, theme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL)); >+ folder.setBackground(colors, new int [] {100}, false); > toolBar.setBackground(colors[1]); > viewMessage.setBackground(colors[1]); > viewForm.setBackground(colors[1]); >Index: Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java,v >retrieving revision 1.6 >diff -u -r1.6 IPresentablePart.java >--- Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java 18 Mar 2004 00:53:46 -0000 1.6 >+++ Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java 18 Mar 2004 13:55:32 -0000 >@@ -12,6 +12,7 @@ > > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.IPropertyListener; > > /** >@@ -61,6 +62,7 @@ > * <li><code>IWorkbenchPart.PROP_TITLE</code> </li> > * <li><code>IEditorPart.PROP_INPUT</code> </li> > * <li><code>IEditorPart.PROP_DIRTY</code> </li> >+ * <li><code>IWorkbenchPart.PROP_TOOLBAR</code> </li> > * </ul> > * </p> > * >@@ -138,5 +140,13 @@ > * @return boolean true if busy > */ > public boolean isBusy(); >+ >+ /** >+ * Returns the local toolbar for this part, or null if this part does not >+ * have a local toolbar. Callers must not dispose or downcast the return value. >+ * >+ * @return the local toolbar for the part, or null if none >+ */ >+ public Control getToolBar(); > > } >Index: Eclipse UI/org/eclipse/ui/internal/ProxyControl.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/ProxyControl.java >diff -N Eclipse UI/org/eclipse/ui/internal/ProxyControl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/ProxyControl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,90 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Layout; >+import org.eclipse.swt.widgets.Listener; >+ >+/** >+ * This class creates an invisible SWT control that can be inserted as a placeholder into >+ * a layout. This object can be subclassed in order to track sizing events. >+ * >+ * @since 3.0 >+ */ >+public class ProxyControl { >+ >+ private Composite proxy; >+ >+ /** >+ * Creates a proxy control in the given parent. >+ * >+ * @param parent the parent of the invisible proxy >+ * @param beingDragged a control whose size and position will always match that of the >+ * invisible proxy. >+ */ >+ public ProxyControl(Composite parent) { >+ proxy = new Composite(parent, SWT.NONE); >+ >+ proxy.setLayout(new Layout() { >+ protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { >+ return ProxyControl.this.computeSize(wHint, hHint, flushCache); >+ } >+ >+ protected void layout(Composite composite, boolean flushCache) { >+ setBounds(composite.getBounds()); >+ } >+ }); >+ >+ Listener boundsListener = new Listener() { >+ public void handleEvent(Event e) { >+ setBounds(proxy.getBounds()); >+ } >+ }; >+ >+ proxy.addListener(SWT.Resize, boundsListener); >+ proxy.addListener(SWT.Move, boundsListener); >+ } >+ >+ public void dispose() { >+ proxy.dispose(); >+ } >+ >+ public Control getControl() { >+ return proxy; >+ } >+ >+ /** >+ * Subclasses can override to return the preferred size of the proxy >+ * >+ * @param composite >+ * @param wHint >+ * @param hHint >+ * @param flushCache >+ * @return >+ */ >+ public Point computeSize(int wHint, int hHint, boolean flushCache) { >+ return new Point(0,0); >+ } >+ >+ /** >+ * Subclasses can override to capture resize events. >+ * >+ * @param bounds >+ */ >+ public void setBounds(Rectangle bounds) { >+ } >+} >Index: Eclipse UI/org/eclipse/ui/internal/presentations/LayoutCache.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/presentations/LayoutCache.java >diff -N Eclipse UI/org/eclipse/ui/internal/presentations/LayoutCache.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/LayoutCache.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.presentations; >+ >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.widgets.Control; >+ >+/** >+ * Caches the preferred sizes of an array of controls >+ * >+ * @since 3.0 >+ */ >+public class LayoutCache { >+ private SizeCache[] caches; >+ >+ /** >+ * Creates a cache for the given array of controls >+ * >+ * @param controls >+ */ >+ public LayoutCache(Control[] controls) { >+ caches = new SizeCache[controls.length]; >+ for (int idx = 0; idx < controls.length; idx++) { >+ caches[idx] = new SizeCache(controls[idx]); >+ } >+ } >+ >+ /** >+ * Computes the preferred size of the nth control >+ * >+ * @param controlIndex index of the control whose size will be computed >+ * @param widthHint width of the control (or SWT.DEFAULT if unknown) >+ * @param heightHint height of the control (or SWT.DEFAULT if unknown) >+ * @return the preferred size of the control >+ */ >+ public Point computeSize(int controlIndex, int widthHint, int heightHint) { >+ return caches[controlIndex].computeSize(widthHint, heightHint); >+ } >+ >+ /** >+ * Flushes the cache >+ */ >+ public void flush() { >+ for (int idx = 0; idx < caches.length; idx++) { >+ caches[idx].flush(); >+ } >+ } >+} >Index: Eclipse UI/org/eclipse/ui/internal/presentations/SizeCache.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/presentations/SizeCache.java >diff -N Eclipse UI/org/eclipse/ui/internal/presentations/SizeCache.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/SizeCache.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,119 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.presentations; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.widgets.Control; >+ >+/** >+ * Caches the preferred size of an SWT control >+ * >+ * @since 3.0 >+ */ >+public class SizeCache { >+ private Control control; >+ >+ private Point preferredSize; >+ private Point cachedWidth; >+ private Point cachedHeight; >+ >+ /** >+ * Creates a cache for size computations on the given control >+ * >+ * @param control the control for which >+ */ >+ public SizeCache(Control control) { >+ this.control = control; >+ } >+ >+ /** >+ * Flush the cache (should be called if the control's contents may have changed since the >+ * last query) >+ */ >+ public void flush() { >+ preferredSize = null; >+ cachedWidth = null; >+ cachedHeight = null; >+ } >+ >+ /** >+ * Computes the preferred size of the control. >+ * >+ * @param widthHint the known width of the control (pixels) or SWT.DEFAULT if unknown >+ * @param heightHint the known height of the control (pixels) or SWT.DEFAULT if unknown >+ * @return the preferred size of the control >+ */ >+ public Point computeSize(int widthHint, int heightHint) { >+ // No hints given -- find the preferred size >+ if (widthHint == SWT.DEFAULT && heightHint == SWT.DEFAULT) { >+ if (preferredSize == null) { >+ preferredSize = computeSize(control, widthHint, heightHint); >+ } >+ >+ return preferredSize; >+ } >+ >+ // Computing a width >+ if (widthHint == SWT.DEFAULT) { >+ if (preferredSize != null && heightHint == preferredSize.y) { >+ return preferredSize; >+ } >+ >+ if (cachedWidth == null || cachedWidth.y != heightHint) { >+ cachedWidth = computeSize(control, widthHint, heightHint); >+ } >+ >+ return cachedWidth; >+ } >+ >+ // Computing a height >+ if (heightHint == SWT.DEFAULT) { >+ // Check if we're asking about the preferred width >+ if (preferredSize != null && widthHint == preferredSize.x) { >+ return preferredSize; >+ } >+ >+ if (cachedHeight == null || cachedHeight.x != widthHint) { >+ cachedHeight = computeSize(control, widthHint, heightHint); >+ } >+ >+ return cachedHeight; >+ } >+ >+ return computeSize(control, widthHint, heightHint); >+ } >+ >+ /** >+ * Compute the control's size, and ensure that non-default hints are returned verbatim >+ * (this tries to compensate for SWT's hints, which aren't really the outer width of the >+ * control). >+ * >+ * @param control >+ * @param widthHint >+ * @param heightHint >+ * @return >+ */ >+ private static Point computeSize(Control control, int widthHint, int heightHint) { >+ Point result = control.computeSize(widthHint, heightHint); >+ >+ if (widthHint != SWT.DEFAULT) { >+ result.x = widthHint; >+ } >+ >+ if (heightHint != SWT.DEFAULT) { >+ result.y = heightHint; >+ } >+ >+ return result; >+ } >+ >+} >Index: Eclipse UI/org/eclipse/ui/internal/presentations/TabFolderLayout.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/presentations/TabFolderLayout.java >diff -N Eclipse UI/org/eclipse/ui/internal/presentations/TabFolderLayout.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/TabFolderLayout.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,232 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.presentations; >+ >+import org.eclipse.jface.util.Geometry; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.CTabFolder; >+import org.eclipse.swt.custom.CTabItem; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Control; >+ >+/** >+ * Arranges the contents of a CTabFolder >+ * >+ * @since 3.0 >+ */ >+public class TabFolderLayout { >+ private CTabFolder tabFolder; >+ private Control[] topControls; >+ //private Control upperRightProxy; >+ private LayoutCache cache; >+ private Rectangle centerArea = new Rectangle(0,0,0,0); >+ private int trimStart; >+ >+ public TabFolderLayout(CTabFolder folder) { >+ this.tabFolder = folder; >+ >+// Composite cmp = new Composite(folder, SWT.DEFAULT); >+// upperRightProxy = cmp; >+// upperRightProxy.setVisible(false); >+// >+// cmp.setLayout(new Layout() { >+// >+// protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { >+// return new Point(10,10); >+// } >+// >+// protected void layout(Composite composite, boolean flushCache) { >+// >+// } >+// }); >+ >+ //tabFolder.setTopRight(upperRightProxy); >+ setTopRight(new Control[0]); >+ } >+ >+ public void dispose() { >+ //tabFolder.setTopRight(null); >+ //upperRightProxy.dispose(); >+ } >+ >+ public Rectangle getClientBounds() { >+ return centerArea; >+ } >+ >+ public int getTrimStart() { >+ return trimStart; >+ } >+ >+ /** >+ * Sets the list of controls to be placed at the top-right of the CTabFolder >+ * >+ * @param topRight a list of Control >+ */ >+ public void setTopRight(Control[] upperRight) { >+ topControls = upperRight; >+ >+ cache = new LayoutCache(upperRight); >+ layout(); >+ } >+ >+ /** >+ * Arranges all the controls in this layout >+ */ >+ public void layout() { >+ cache.flush(); >+ >+ if (topControls.length == 0) { >+ tabFolder.setTopRight(null); >+ } >+ >+// DragUtil.getDisplayBounds(tabFolder); >+// >+// displayBounds.height = tabFolder.getTabHeight(); >+// displayBounds.x = displayBounds.x + displayBounds.width - 30; >+// displayBounds.width = 30; >+ >+ int trimWidth = computeTrimWidth(); >+ int available = getAvailableSpace(tabFolder); >+ >+ Rectangle clientBounds = calculatePageBounds(tabFolder); >+ >+ Rectangle bounds = tabFolder.getBounds(); >+ trimStart = bounds.x + bounds.width; >+ >+ // Check if we have room for all our topRight controls on the top border >+ if (available >= trimWidth) { >+ //upperRightProxy.setSize(0, 0); >+ //tabFolder.setTopRight(upperRightProxy); >+ >+ Rectangle displayBounds = //DragUtil.getDisplayBounds(upperRightProxy); >+ Geometry.toDisplay(tabFolder, tabFolder.getMinimizeBounds()); >+ >+ //displayBounds.height = tabFolder.getTabHeight(); >+ displayBounds.width = 0; >+ displayBounds.y --; >+ displayBounds.height += 2; >+ Rectangle targetBounds = Geometry.toControl(tabFolder.getParent(), displayBounds); >+ >+ targetBounds.x = targetBounds.x + targetBounds.width - trimWidth; >+ >+ Rectangle currentRectangle = new Rectangle(targetBounds.x, targetBounds.y, 0, targetBounds.height); >+ >+ trimStart = targetBounds.x; >+ >+ for (int idx = 0; idx < topControls.length; idx++) { >+ Point nextSize = cache.computeSize(idx, SWT.DEFAULT, SWT.DEFAULT); >+ >+ currentRectangle.width = nextSize.x; >+ //currentRectangle.height = nextSize.y; >+ >+ //topControls[idx].moveAbove(null); >+ topControls[idx].setBounds(currentRectangle); >+ >+ currentRectangle.x += currentRectangle.width; >+ } >+ >+ centerArea = Geometry.copy(clientBounds); >+ >+ return; >+ } >+ >+ //tabFolder.setTopRight(null); >+ >+ // Else we need to place the controls below the title >+ int y = clientBounds.y; >+ int x = clientBounds.x + clientBounds.width; >+ >+ int rowHeight = 0; >+ for (int idx = 0; idx < topControls.length; idx++) { >+ Point nextSize = cache.computeSize(idx, SWT.DEFAULT, SWT.DEFAULT); >+ >+ if (nextSize.x < clientBounds.width) { >+ topControls[idx].setBounds(x - nextSize.x, y, nextSize.x, nextSize.y); >+ rowHeight = Math.max(rowHeight, nextSize.y); >+ x -= nextSize.x; >+ } else { >+ y += rowHeight; >+ x = clientBounds.x; >+ rowHeight = 0; >+ >+ nextSize = cache.computeSize(idx, clientBounds.width, SWT.DEFAULT); >+ topControls[idx].setBounds(x, y, nextSize.x, nextSize.y); >+ >+ y += nextSize.y; >+ } >+ } >+ >+ y += rowHeight; >+ >+ centerArea = new Rectangle(clientBounds.x, y, clientBounds.width, >+ clientBounds.height + clientBounds.y - y); >+ } >+ >+ /** >+ * Computes the maximium size available for the trim controls without causing >+ * tabs to disappear. >+ * >+ * @param folder >+ * @return the amount of empty space to the right of the tabs >+ */ >+ protected static int getAvailableSpace(CTabFolder folder) { >+ int available = folder.getBounds().width; >+ >+ available -= 2 * folder.getBorderWidth(); >+ available -= folder.getChevronBounds().width; >+ available -= folder.getMaximizeBounds().width; >+ available -= folder.getMinimizeBounds().width; >+ >+ // Add a safety margin to avoid stomping on the curve >+ available -= 10; >+ >+ CTabItem[] tabs = folder.getItems(); >+ for (int idx = 0; idx < tabs.length; idx++) { >+ CTabItem item = tabs[idx]; >+ >+ if (!item.isShowing()) { >+ return 0; >+ } >+ >+ available -= item.getBounds().width; >+ } >+ >+ return Math.max(0, available); >+ } >+ >+ /** >+ * Returns the total preferred width of the top controls >+ * >+ * @return the total preferred width of the top controls >+ */ >+ protected int computeTrimWidth() { >+ int width = 0; >+ for (int idx = 0; idx < topControls.length; idx++) { >+ width += cache.computeSize(idx, SWT.DEFAULT, SWT.DEFAULT).x; >+ } >+ >+ return width; >+ } >+ >+ private static Rectangle calculatePageBounds(CTabFolder folder) { >+ if (folder == null) >+ return new Rectangle(0, 0, 0, 0); >+ Rectangle bounds = folder.getBounds(); >+ Rectangle offset = folder.getClientArea(); >+ bounds.x += offset.x; >+ bounds.y += offset.y; >+ bounds.width = offset.width; >+ bounds.height = offset.height; >+ return bounds; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 55156
:
8649
|
8650
|
8652
|
8722
|
8730
|
8731
|
8732
|
8733