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 76462 Details for
Bug 51580
[RCP][Views] Need the ability to resize views programmatically
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
updated patch
patch-51580.txt (text/plain), 36.07 KB, created by
Boris Bokowski
on 2007-08-20 11:39:11 EDT
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Boris Bokowski
Created:
2007-08-20 11:39:11 EDT
Size:
36.07 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.tests.performance >Index: src/org/eclipse/ui/tests/performance/presentations/TestPresentablePart.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/presentations/TestPresentablePart.java,v >retrieving revision 1.4 >diff -u -r1.4 TestPresentablePart.java >--- src/org/eclipse/ui/tests/performance/presentations/TestPresentablePart.java 16 Mar 2007 18:00:14 -0000 1.4 >+++ src/org/eclipse/ui/tests/performance/presentations/TestPresentablePart.java 20 Aug 2007 15:36:58 -0000 >@@ -204,5 +204,20 @@ > public void removePartPropertyListener(IPropertyChangeListener listener) { > partPropertyListeners.remove(listener); > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISizeProvider#computePreferredSize(boolean, int, int, int) >+ */ >+ public int computePreferredSize(boolean width, int availableParallel, >+ int availablePerpendicular, int preferredResult) { >+ return preferredResult; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISizeProvider#getSizeFlags(boolean) >+ */ >+ public int getSizeFlags(boolean width) { >+ return 0; >+ } > > } >#P org.eclipse.ui.tests >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/plugin.xml,v >retrieving revision 1.233 >diff -u -r1.233 plugin.xml >--- plugin.xml 12 Jul 2007 18:38:28 -0000 1.233 >+++ plugin.xml 20 Aug 2007 15:36:59 -0000 >@@ -453,6 +453,12 @@ > id="org.eclipse.ui.tests.manual.ViewWithSaveables" > name="View Owning Saveables"> > </view> >+ <view >+ allowMultiple="true" >+ class="org.eclipse.ui.tests.layout.constraints.LayoutConstraintsView" >+ id="org.eclipse.ui.tests.layout.constraints.LayoutConstraintsView" >+ name="Layout Constraints Test"> >+ </view> > > </extension> > <extension >Index: Eclipse UI Tests/org/eclipse/ui/tests/layout/constraints/LayoutConstraintsView.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/layout/constraints/LayoutConstraintsView.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/layout/constraints/LayoutConstraintsView.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/layout/constraints/LayoutConstraintsView.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,278 @@ >+package org.eclipse.ui.tests.layout.constraints; >+ >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.layout.GridDataFactory; >+import org.eclipse.jface.layout.GridLayoutFactory; >+import org.eclipse.jface.layout.LayoutConstants; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.ui.ISizeProvider; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchPartConstants; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.part.ViewPart; >+ >+public class LayoutConstraintsView extends ViewPart implements ISizeProvider { >+ >+ private Control control; >+ >+ private int minWidth = ISizeProvider.INFINITE; >+ private int maxWidth = ISizeProvider.INFINITE; >+ private int minHeight = ISizeProvider.INFINITE; >+ private int maxHeight = ISizeProvider.INFINITE; >+ private int quantizedWidth = ISizeProvider.INFINITE; >+ private int quantizedHeight = ISizeProvider.INFINITE; >+ private int fixedArea = ISizeProvider.INFINITE; >+ private Text minWidthText; >+ private Text maxWidthText; >+ private Text quantizedWidthText; >+ private Text minHeightText; >+ private Text maxHeightText; >+ private Text quantizedHeightText; >+ private Text fixedAreaText; >+ >+ public void createPartControl(Composite parent) { >+ control = parent; >+ >+ Composite buttonBar = new Composite(parent, SWT.NONE); >+ { >+ GridDataFactory buttonData = GridDataFactory.fillDefaults().grab(true, false); >+ >+ Button applyButton = new Button(buttonBar, SWT.PUSH); >+ applyButton.setText("Apply"); >+ applyButton.addSelectionListener(new SelectionAdapter() { >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ applyPressed(); >+ } >+ }); >+ buttonData.applyTo(applyButton); >+ >+ Button clearButton = new Button(buttonBar, SWT.PUSH); >+ clearButton.setText("Reset"); >+ clearButton.addSelectionListener(new SelectionAdapter() { >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ minWidthText.setText(""); >+ maxWidthText.setText(""); >+ quantizedWidthText.setText(""); >+ minHeightText.setText(""); >+ maxHeightText.setText(""); >+ quantizedHeightText.setText(""); >+ fixedAreaText.setText(""); >+ applyPressed(); >+ } >+ }); >+ buttonData.applyTo(clearButton); >+ >+ Button newViewButton = new Button(buttonBar, SWT.PUSH); >+ newViewButton.setText("New View"); >+ newViewButton.addSelectionListener(new SelectionAdapter() { >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ try { >+ getSite().getPage().showView("org.eclipse.ui.tests.layout.constraints.LayoutConstraintsView", >+ "" + System.currentTimeMillis(), IWorkbenchPage.VIEW_ACTIVATE); >+ } catch (PartInitException e1) { >+ MessageDialog.openError(getSite().getShell(), "Error opening view", "Unable to open view."); >+ } >+ } >+ }); >+ buttonData.applyTo(newViewButton); >+ >+ GridLayoutFactory.fillDefaults().equalWidth(true).numColumns(3).applyTo(buttonBar); >+ } >+ GridDataFactory.fillDefaults().grab(true, false).span(2,1).applyTo(buttonBar); >+ >+ new Label(parent, SWT.NONE).setText("Min Width"); >+ minWidthText = createText(parent); >+ >+ new Label(parent, SWT.NONE).setText("Max Width (blank = unbounded)"); >+ maxWidthText = createText(parent); >+ >+ new Label(parent, SWT.NONE).setText("Quantized Width (blank = none)"); >+ quantizedWidthText = createText(parent); >+ >+ new Label(parent, SWT.NONE).setText("Min Height"); >+ minHeightText = createText(parent); >+ >+ new Label(parent, SWT.NONE).setText("Max Height (blank = unbounded)"); >+ maxHeightText = createText(parent); >+ >+ new Label(parent, SWT.NONE).setText("Quantized Height (blank = none)"); >+ quantizedHeightText = createText(parent); >+ >+ new Label(parent, SWT.NONE).setText("Fixed Area (blank = none"); >+ fixedAreaText = createText(parent); >+ >+ >+ GridLayoutFactory.fillDefaults().numColumns(2).margins(LayoutConstants.getMargins()).generateLayout(parent); >+ } >+ >+ /** >+ * >+ */ >+ protected void applyPressed() { >+ // Copy the values from the text boxes >+ minWidth = getInt(minWidthText); >+ maxWidth = getInt(maxWidthText); >+ quantizedWidth = getInt(quantizedWidthText); >+ minHeight = getInt(minHeightText); >+ maxHeight = getInt(maxHeightText); >+ quantizedHeight = getInt(quantizedHeightText); >+ fixedArea = getInt(fixedAreaText); >+ >+ // Trigger a workbench layout >+ updateLayout(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISizeProvider#getSizeFlags(boolean) >+ */ >+ public int getSizeFlags(boolean width) { >+ int flags = 0; >+ if (width) { >+ if (minWidth != ISizeProvider.INFINITE) { >+ flags |= SWT.MIN; >+ } >+ if (maxWidth != ISizeProvider.INFINITE) { >+ flags |= SWT.MAX; >+ } >+ if (quantizedWidth != ISizeProvider.INFINITE || fixedArea != ISizeProvider.INFINITE) { >+ flags |= SWT.FILL; >+ } >+ if (fixedArea != ISizeProvider.INFINITE) { >+ flags |= SWT.WRAP; >+ } >+ } else { >+ if (minHeight != ISizeProvider.INFINITE) { >+ flags |= SWT.MIN; >+ } >+ if (maxHeight != ISizeProvider.INFINITE) { >+ flags |= SWT.MAX; >+ } >+ if (quantizedHeight != ISizeProvider.INFINITE || fixedArea != ISizeProvider.INFINITE) { >+ flags |= SWT.FILL; >+ } >+ if (fixedArea != ISizeProvider.INFINITE) { >+ flags |= SWT.WRAP; >+ } >+ } >+ >+ return flags; >+ } >+ >+ /** >+ * @param minWidth2 >+ * @return >+ */ >+ private int getInt(Text text) { >+ if (text.getText().equals("")) { >+ return ISizeProvider.INFINITE; >+ } >+ >+ try { >+ return Integer.parseInt(text.getText()); >+ } catch (NumberFormatException e) { >+ return ISizeProvider.INFINITE; >+ } >+ } >+ >+ /** >+ * >+ */ >+ protected void updateLayout() { >+ firePropertyChange(IWorkbenchPartConstants.PROP_PREFERRED_SIZE); >+ } >+ >+ /** >+ * @param parent >+ */ >+ private Text createText(Composite parent) { >+ return new Text(parent, SWT.BORDER); >+ } >+ >+ public void setFocus() { >+ control.setFocus(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISizeProvider#computePreferredSize(boolean, int, int, int) >+ */ >+ public int computePreferredSize(boolean width, int availableParallel, >+ int availablePerpendicular, int preferredResult) { >+ >+ int area = fixedArea; >+ int result = preferredResult; >+ // If we're trying to maintain a fixed area, compute the preferred width in terms >+ // of the available height or vise-versa. A view that is trying to exactly fit a wrapping >+ // widget would use similar logic >+ if (area != ISizeProvider.INFINITE) { >+ if (availablePerpendicular == 0) { >+ result = 0; >+ } else { >+ result = area / availablePerpendicular; >+ } >+ >+ if (result < 30) { >+ result = 30; >+ } >+ } >+ >+ // Get the user-entered minimum, maximum, and quantized sizes for this dimension >+ int min; >+ int max; >+ int quant; >+ >+ if (width) { >+ min = minWidth; >+ max = maxWidth; >+ quant = quantizedWidth; >+ } else { >+ min = minHeight; >+ max = maxHeight; >+ quant = quantizedHeight; >+ } >+ >+ // If we're using quantized sizes, jump to the nearest multiple >+ // of the quantized size >+ if (quant != ISizeProvider.INFINITE && quant != 0) { >+ result = Math.min(result + quant / 2, availableParallel); >+ result = result - (result % quant); >+ } >+ >+ // Ensure we go no smaller than the minimum size >+ if (min != ISizeProvider.INFINITE && result < min) { >+ result = min; >+ } >+ >+ // Ensure we go no larger than the maximum size >+ if (result > max) { >+ result = max; >+ } >+ >+ // Ensure that we don't use more than the available space >+ if (result > availableParallel) { >+ result = availableParallel; >+ } >+ >+ if (result < 0) { >+ result = 0; >+ } >+ >+ return result; >+ } >+ >+} >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java,v >retrieving revision 1.12 >diff -u -r1.12 PresentablePart.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java 16 Mar 2007 18:00:35 -0000 1.12 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java 20 Aug 2007 15:36:59 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580 > *******************************************************************************/ > package org.eclipse.ui.internal.presentations; > >@@ -397,4 +398,22 @@ > return getPartReference().getPartProperty(key); > } > >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISizeProvider#computePreferredSize(boolean, int, int, int) >+ */ >+ public int computePreferredSize(boolean width, int availableParallel, >+ int availablePerpendicular, int preferredResult) { >+ >+ return getPane().computePreferredSize(width, availableParallel, >+ availablePerpendicular, preferredResult); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISizeProvider#getSizeFlags(boolean) >+ */ >+ public int getSizeFlags(boolean width) { >+ return getPane().getSizeFlags(width); >+ } >+ >+ > } >Index: Eclipse UI/org/eclipse/ui/internal/presentations/util/PresentablePartFolder.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/PresentablePartFolder.java,v >retrieving revision 1.18 >diff -u -r1.18 PresentablePartFolder.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/util/PresentablePartFolder.java 8 May 2006 20:55:52 -0000 1.18 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/util/PresentablePartFolder.java 20 Aug 2007 15:36:59 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580 > *******************************************************************************/ > package org.eclipse.ui.internal.presentations.util; > >@@ -327,6 +328,9 @@ > layout(true); > } > break; >+ case IPresentablePart.PROP_PREFERRED_SIZE: >+ folder.fireEvent(new TabFolderEvent(TabFolderEvent.EVENT_PREFERRED_SIZE, tab, 0, 0 )); >+ break; > default: > initTab(tab, part); > } >Index: Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java,v >retrieving revision 1.16 >diff -u -r1.16 TabbedStackPresentation.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java 22 May 2007 16:31:01 -0000 1.16 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java 20 Aug 2007 15:36:59 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580 > *******************************************************************************/ > package org.eclipse.ui.internal.presentations.util; > >@@ -144,7 +145,13 @@ > } > break; > } >- >+ case TabFolderEvent.EVENT_PREFERRED_SIZE: { >+ IPresentablePart part = folder.getPartForTab(e.tab); >+ if (part == getSite().getSelectedPart()) { >+ getSite().flushLayout(); >+ } >+ break; >+ } > } > } > }; >@@ -225,21 +232,53 @@ > return folder.getTabFolder().computeSize(SWT.DEFAULT, SWT.DEFAULT); > } > >+ /** >+ * Returns the minimum size for this stack, taking into account >+ * the available perpendicular space. >+ * @param width indicates whether a width (=true) or a height (=false) is being computed >+ * @param availablePerpendicular available space perpendicular to the direction being measured >+ * or INFINITE if unbounded (pixels). >+ * @return returns the preferred minimum size (pixels). >+ * This is a width if width == true or a height if width == false. >+ */ >+ private int computePreferredMinimumSize(boolean width, int availablePerpendicular) { >+ int minSize; >+ int hint = availablePerpendicular == INFINITE ? SWT.DEFAULT : availablePerpendicular; >+ if (width) { >+ minSize = folder.getTabFolder().computeSize(SWT.DEFAULT, hint).x; >+ } else { >+ minSize = folder.getTabFolder().computeSize(hint, SWT.DEFAULT).y; >+ } >+ return minSize; >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.ui.ISizeProvider#computePreferredSize(boolean, int, int, int) > */ > public int computePreferredSize(boolean width, int availableParallel, > int availablePerpendicular, int preferredResult) { >- >+ >+ // If there is exactly one part in the stack, this just returns the >+ // preferred size of the part as the preferred size of the stack. >+ IPresentablePart[] parts = getSite().getPartList(); >+ if (parts.length == 1 && parts[0] != null) { >+ int partSize = parts[0].computePreferredSize(width, >+ availableParallel, availablePerpendicular, preferredResult); >+ >+ // Adjust preferred size to take into account tab and border trim. >+ int minSize = computePreferredMinimumSize(width, availablePerpendicular); >+ if (width) { >+ // PaneFolder adds some bogus tab spacing, so just find the maximum width. >+ partSize = Math.max(minSize, partSize); >+ } else { >+ partSize += minSize; >+ } >+ >+ return partSize; >+ } >+ > if (preferredResult != INFINITE || getSite().getState() == IStackPresentationSite.STATE_MINIMIZED) { >- int minSize = 0; >- if (width) { >- int heightHint = availablePerpendicular == INFINITE ? SWT.DEFAULT : availablePerpendicular; >- minSize = folder.getTabFolder().computeSize(SWT.DEFAULT, heightHint).x; >- } else { >- int widthHint = availablePerpendicular == INFINITE ? SWT.DEFAULT : availablePerpendicular; >- minSize = folder.getTabFolder().computeSize(widthHint, SWT.DEFAULT).y; >- } >+ int minSize = computePreferredMinimumSize(width, availablePerpendicular); > > if (getSite().getState() == IStackPresentationSite.STATE_MINIMIZED) { > return minSize; >@@ -251,6 +290,22 @@ > return INFINITE; > } > >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.presentations.StackPresentation#getSizeFlags(boolean) >+ */ >+ public int getSizeFlags(boolean width) { >+ int flags = 0; >+ // If there is exactly one part in the stack, >+ // then take into account the size flags of the part. >+ IPresentablePart[] parts = getSite().getPartList(); >+ if (parts.length == 1 && parts[0] != null) { >+ flags |= parts[0].getSizeFlags(width); >+ } >+ >+ return flags | super.getSizeFlags(width); >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.ui.presentations.StackPresentation#showPartList() > */ >@@ -359,6 +414,12 @@ > } finally { > ignoreSelectionChanges--; > } >+ >+ if (tabs.getPartList().length == 1) { >+ if (newPart.getSizeFlags(true) != 0 || newPart.getSizeFlags(false) != 0) { >+ getSite().flushLayout(); >+ } >+ } > } > > /* (non-Javadoc) >Index: Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderEvent.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderEvent.java,v >retrieving revision 1.4 >diff -u -r1.4 TabFolderEvent.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderEvent.java 15 Jun 2005 18:41:21 -0000 1.4 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderEvent.java 20 Aug 2007 15:36:59 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580 > *******************************************************************************/ > package org.eclipse.ui.internal.presentations.util; > >@@ -29,6 +30,7 @@ > public static final int EVENT_DRAG_START = 10; > public static final int EVENT_SHOW_LIST = 11; > public static final int EVENT_SYSTEM_MENU = 12; >+ public static final int EVENT_PREFERRED_SIZE = 13; > > public static int eventIdToStackState(int eventId) { > switch(eventId) { >Index: Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java,v >retrieving revision 1.21 >diff -u -r1.21 IPresentablePart.java >--- Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java 16 Mar 2007 18:00:37 -0000 1.21 >+++ Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java 20 Aug 2007 15:36:59 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580 > *******************************************************************************/ > package org.eclipse.ui.presentations; > >@@ -15,6 +16,7 @@ > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.IPropertyListener; >+import org.eclipse.ui.ISizeProvider; > import org.eclipse.ui.IWorkbenchPartConstants; > > /** >@@ -25,8 +27,9 @@ > * Not intended to be implemented by clients. > * > * @since 3.0 >+ * @since 3.4 now extends {@link org.eclipse.ui.ISizeProvider} > */ >-public interface IPresentablePart { >+public interface IPresentablePart extends ISizeProvider { > > /** > * The property id for <code>isDirty</code>. >@@ -76,6 +79,12 @@ > public static final int PROP_PANE_MENU = 0x302; > > /** >+ * The property id for preferred size changes >+ * @since 3.4 >+ */ >+ public static final int PROP_PREFERRED_SIZE = IWorkbenchPartConstants.PROP_PREFERRED_SIZE; >+ >+ /** > * Sets the bounds of this part. > * > * @param bounds bounding rectangle (not null) >Index: Eclipse UI/org/eclipse/ui/IWorkbenchPartConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPartConstants.java,v >retrieving revision 1.6 >diff -u -r1.6 IWorkbenchPartConstants.java >--- Eclipse UI/org/eclipse/ui/IWorkbenchPartConstants.java 15 Jun 2005 18:41:21 -0000 1.6 >+++ Eclipse UI/org/eclipse/ui/IWorkbenchPartConstants.java 20 Aug 2007 15:36:59 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580 > *******************************************************************************/ > package org.eclipse.ui; > >@@ -43,4 +44,10 @@ > */ > int PROP_CONTENT_DESCRIPTION = 0x105; > >+ /** >+ * The property id for any method on the optional <code>ISizeProvider</code> interface >+ * @since 3.4 >+ */ >+ int PROP_PREFERRED_SIZE = 0x303; >+ > } >Index: Eclipse UI/org/eclipse/ui/IViewPart.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IViewPart.java,v >retrieving revision 1.10 >diff -u -r1.10 IViewPart.java >--- Eclipse UI/org/eclipse/ui/IViewPart.java 19 Mar 2005 00:36:32 -0000 1.10 >+++ Eclipse UI/org/eclipse/ui/IViewPart.java 20 Aug 2007 15:36:59 -0000 >@@ -12,34 +12,45 @@ > > > /** >- * A view is a visual component within a workbench page. It is typically used to >- * navigate a hierarchy of information (like the workspace), open an editor, >- * or display properties for the active editor. Modifications made in a view are >- * saved immediately (in contrast to an editor part, which conforms to a more >+ * A view is a visual component within a workbench page. It is typically used to >+ * navigate a hierarchy of information (like the workspace), open an editor, or >+ * display properties for the active editor. Modifications made in a view are >+ * saved immediately (in contrast to an editor part, which conforms to a more > * elaborate open-save-close lifecycle). > * <p> >- * Only one instance of a particular view type may exist within a workbench page. >- * This policy is designed to simplify part management for a user. >- * </p><p> >- * This interface may be implemented directly. For convenience, a base >+ * Only one instance of a particular view type may exist within a workbench >+ * page. This policy is designed to simplify part management for a user. >+ * </p> >+ * <p> >+ * This interface may be implemented directly. For convenience, a base > * implementation is defined in <code>ViewPart</code>. > * </p> > * <p> > * A view is added to the workbench in two steps: > * <ol> >- * <li>A view extension is contributed to the workbench registry. This >- * extension defines the extension id and extension class.</li> >- * <li>The view is included in the default layout for a perspective. >- * Alternatively, the user may open the view from the Perspective menu.</li> >+ * <li>A view extension is contributed to the workbench registry. This >+ * extension defines the extension id and extension class.</li> >+ * <li>The view is included in the default layout for a perspective. >+ * Alternatively, the user may open the view from the Perspective menu.</li> > * </ol> > * </p> > * <p> >- * Views implement the <code>IAdaptable</code> interface; extensions >- * are managed by the platform's adapter manager. >+ * Views implement the <code>IAdaptable</code> interface; extensions are >+ * managed by the platform's adapter manager. >+ * </p> >+ * <p> >+ * As of 3.4, views may optionally implement {@link ISizeProvider} if they have >+ * a preferred size. The default presentation will make a best effort to >+ * allocate the preferred size to a view if it is the only part in a stack. If >+ * there is more than one part in the stack, the constraints will be disabled >+ * for that stack. The size constraints are adjusted for the size of the tab and >+ * border trim. Note that this is considered to be a hint to the presentation, >+ * and not all presentations may honor size constraints. > * </p> >- * >+ * > * @see IWorkbenchPage#showView > * @see org.eclipse.ui.part.ViewPart >+ * @see ISizeProvider > */ > public interface IViewPart extends IWorkbenchPart, IPersistable { > /** >Index: Eclipse UI/org/eclipse/ui/internal/PartPane.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartPane.java,v >retrieving revision 1.88 >diff -u -r1.88 PartPane.java >--- Eclipse UI/org/eclipse/ui/internal/PartPane.java 16 Mar 2007 18:00:32 -0000 1.88 >+++ Eclipse UI/org/eclipse/ui/internal/PartPane.java 20 Aug 2007 15:36:59 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580 > *******************************************************************************/ > package org.eclipse.ui.internal; > >@@ -632,4 +633,22 @@ > public void propertyChange(PropertyChangeEvent event) { > firePartPropertyChange(event); > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.LayoutPart#computePreferredSize(boolean, int, int, int) >+ */ >+ public int computePreferredSize(boolean width, int availableParallel, >+ int availablePerpendicular, int preferredParallel) { >+ >+ return ((WorkbenchPartReference)partReference).computePreferredSize(width, >+ availableParallel, availablePerpendicular, preferredParallel); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.LayoutPart#getSizeFlags(boolean) >+ */ >+ public int getSizeFlags(boolean horizontal) { >+ return ((WorkbenchPartReference)partReference).getSizeFlags(horizontal); >+ } >+ > } >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java,v >retrieving revision 1.46 >diff -u -r1.46 WorkbenchPartReference.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java 16 Mar 2007 18:00:32 -0000 1.46 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java 20 Aug 2007 15:36:59 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580 > *******************************************************************************/ > package org.eclipse.ui.internal; > >@@ -32,6 +33,7 @@ > import org.eclipse.ui.ISaveablePart; > import org.eclipse.ui.ISaveablesLifecycleListener; > import org.eclipse.ui.ISharedImages; >+import org.eclipse.ui.ISizeProvider; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.IWorkbenchPart2; > import org.eclipse.ui.IWorkbenchPart3; >@@ -46,7 +48,7 @@ > /** > * > */ >-public abstract class WorkbenchPartReference implements IWorkbenchPartReference { >+public abstract class WorkbenchPartReference implements IWorkbenchPartReference, ISizeProvider { > > /** > * Internal property ID: Indicates that the underlying part was created >@@ -605,6 +607,14 @@ > releaseReferences(); > > fireInternalPropertyChange(INTERNAL_PROPERTY_OPENED); >+ >+ if (part instanceof ISizeProvider) { >+ ISizeProvider sp = (ISizeProvider)part; >+ // If this part has a preferred size, indicate that the preferred size may have changed at this point >+ if (sp.getSizeFlags(true) != 0 || sp.getSizeFlags(false) != 0) { >+ fireInternalPropertyChange(IWorkbenchPartConstants.PROP_PREFERRED_SIZE); >+ } >+ } > } > } finally { > state = STATE_CREATED; >@@ -793,4 +803,32 @@ > workbenchPart.setPartProperty((String) e.getKey(), (String) e.getValue()); > } > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISizeProvider#computePreferredSize(boolean, int, int, int) >+ */ >+ public int computePreferredSize(boolean width, int availableParallel, >+ int availablePerpendicular, int preferredResult) { >+ >+ if (part instanceof ISizeProvider) { >+ ISizeProvider sp = (ISizeProvider) part; >+ >+ return sp.computePreferredSize(width, availableParallel, availablePerpendicular, preferredResult); >+ } >+ >+ return preferredResult; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISizeProvider#getSizeFlags(boolean) >+ */ >+ public int getSizeFlags(boolean width) { >+ if (part instanceof ISizeProvider) { >+ ISizeProvider sp = (ISizeProvider) part; >+ >+ return sp.getSizeFlags(width); >+ } >+ return 0; >+ } >+ > } >Index: Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java,v >retrieving revision 1.46 >diff -u -r1.46 DetachedWindow.java >--- Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java 10 Aug 2007 14:16:29 -0000 1.46 >+++ Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java 20 Aug 2007 15:36:59 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580 > *******************************************************************************/ > > package org.eclipse.ui.internal; >@@ -41,7 +42,8 @@ > import org.eclipse.ui.internal.dnd.IDropTarget; > import org.eclipse.ui.internal.presentations.PresentationFactoryUtil; > import org.eclipse.ui.internal.presentations.util.AbstractTabFolder; >-import org.eclipse.ui.internal.presentations.util.AbstractTabItem; >+import org.eclipse.ui.internal.presentations.util.TabFolderEvent; >+import org.eclipse.ui.internal.presentations.util.TabFolderListener; > import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation; > import org.eclipse.ui.presentations.StackDropResult; > >@@ -53,6 +55,8 @@ > */ > public class DetachedWindow implements IDragOverListener { > >+ public static final int INFINITE = Integer.MAX_VALUE; >+ > private PartStack folder; > > private WorkbenchPage page; >@@ -130,6 +134,29 @@ > } > } > >+ /** >+ * Ensure that the shell's minimum size is equal to the minimum size >+ * of the first part added to the shell. >+ */ >+ private void updateMinimumSize() { >+ // We can only do this for 'Tabbed' stacked presentations. >+ if (folder.getPresentation() instanceof TabbedStackPresentation) { >+ TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation(); >+ >+ if (stack.getPartList().length == 1) { >+ // Get the minimum space required for the part >+ int width = stack.computePreferredSize(true, INFINITE, INFINITE, 0); >+ int height = stack.computePreferredSize(false, INFINITE, INFINITE, 0); >+ >+ // Take the current shell 'trim' into account >+ int shellHeight = windowShell.getBounds().height - windowShell.getClientArea().height; >+ int shellWidth = windowShell.getBounds().width - windowShell.getClientArea().width; >+ >+ windowShell.setMinimumSize(width + shellWidth, height + shellHeight); >+ } >+ } >+ } >+ > private static IWorkbenchPartReference getPartReference(PartPane pane) { > > if (pane == null) { >@@ -177,25 +204,7 @@ > part.reparent(shell); > } > folder.add(part); >- >- // Ensure that the shell's minimum size is capable of showing the initial first tab >- // We can only do this for 'Tabbed' stacked presentations... >- if (folder.getPresentation() instanceof TabbedStackPresentation) { >- TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation(); >- >- AbstractTabFolder tabFolder = stack.getTabFolder(); >- if (tabFolder.getItemCount() == 1) { >- // Get the space that we need to show the tab >- AbstractTabItem firstItem = tabFolder.getItem(0); >- Rectangle tabRect = firstItem.getBounds(); >- >- // Take the current shell 'trim' into account >- int shellHeight = windowShell.getBounds().height - windowShell.getClientArea().height; >- int shellWidth = windowShell.getBounds().width - windowShell.getClientArea().width; >- >- windowShell.setMinimumSize(tabRect.width + shellWidth, tabRect.height + shellHeight); >- } >- } >+ updateMinimumSize(); > } > > public boolean belongsToWorkbenchPage(IWorkbenchPage workbenchPage) { >@@ -330,6 +339,25 @@ > LayoutPart part = (LayoutPart) itr.nextElement(); > part.reparent(parent); > } >+ >+ if (folder.getPresentation() instanceof TabbedStackPresentation) { >+ TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation(); >+ AbstractTabFolder tabFolder = stack.getTabFolder(); >+ tabFolder.addListener(new TabFolderListener() { >+ public void handleEvent(TabFolderEvent e) { >+ switch (e.type) { >+ case TabFolderEvent.EVENT_CLOSE: { >+ updateMinimumSize(); >+ break; >+ } >+ case TabFolderEvent.EVENT_PREFERRED_SIZE: { >+ updateMinimumSize(); >+ break; >+ } >+ } >+ } >+ }); >+ } > > // Return tab folder control. > return folder.getControl();
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 51580
:
8564
|
8565
|
59221
|
59222
|
76344
|
76347
| 76462 |
76508