Index: EditorArea.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorArea.java,v retrieving revision 1.17 diff -u -r1.17 EditorArea.java --- EditorArea.java 21 Mar 2004 17:57:21 -0000 1.17 +++ EditorArea.java 14 Apr 2004 23:02:24 -0000 @@ -227,10 +227,19 @@ String partID = childMem.getString(IWorkbenchConstants.TAG_PART); String relativeID = childMem.getString(IWorkbenchConstants.TAG_RELATIVE); int relationship = 0; - float ratio = 0.0f; + int left = 0, right = 0; + float ratio = 0.5f; if (relativeID != null) { relationship = childMem.getInteger(IWorkbenchConstants.TAG_RELATIONSHIP).intValue(); - ratio = childMem.getFloat(IWorkbenchConstants.TAG_RATIO).floatValue(); + Float Ratio = childMem.getFloat(IWorkbenchConstants.TAG_RATIO); + Integer Left = childMem.getInteger(IWorkbenchConstants.TAG_RATIO_LEFT); + Integer Right = childMem.getInteger(IWorkbenchConstants.TAG_RATIO_RIGHT); + if (Left != null) { + left = Left.intValue(); + right = Right.intValue(); + } else if (Ratio != null) { + ratio = Ratio.floatValue(); + } } // Create the part. @@ -245,7 +254,11 @@ } else { LayoutPart refPart = (LayoutPart)mapIDtoPart.get(relativeID); if (refPart != null) { - add(workbook, relationship, ratio, refPart); + //$TODO pass in left and right + if (left == 0 || right == 0) + add(workbook, relationship, ratio, refPart); + else + add(workbook, relationship, left, right, refPart); } else { WorkbenchPlugin.log("Unable to find part for ID: " + relativeID);//$NON-NLS-1$ } @@ -271,7 +284,9 @@ if (info.relative != null) { childMem.putString(IWorkbenchConstants.TAG_RELATIVE, info.relative.getID()); childMem.putInteger(IWorkbenchConstants.TAG_RELATIONSHIP, info.relationship); - childMem.putFloat(IWorkbenchConstants.TAG_RATIO, info.ratio); + childMem.putInteger(IWorkbenchConstants.TAG_RATIO_LEFT, info.left); + childMem.putInteger(IWorkbenchConstants.TAG_RATIO_RIGHT, info.right); + //childMem.putFloat(IWorkbenchConstants.TAG_RATIO, info.ratio); } } return new Status(IStatus.OK,PlatformUI.PLUGIN_ID,0,"",null); //$NON-NLS-1$ @@ -344,7 +359,13 @@ /* package */ DropTarget getDropTarget() { return dropTarget; } - + /** + * @see org.eclipse.ui.internal.LayoutPart#getImportance() + */ + public boolean isCompressible() { + //Added for bug 19524 + return true; + } /* (non-Javadoc) * @see org.eclipse.ui.internal.ILayoutContainer#allowsAutoFocus() */ Index: IWorkbenchConstants.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java,v retrieving revision 1.38 diff -u -r1.38 IWorkbenchConstants.java --- IWorkbenchConstants.java 9 Apr 2004 19:48:41 -0000 1.38 +++ IWorkbenchConstants.java 14 Apr 2004 23:02:24 -0000 @@ -106,6 +106,9 @@ public static final String TAG_RELATIVE = "relative"; //$NON-NLS-1$ public static final String TAG_RELATIONSHIP = "relationship"; //$NON-NLS-1$ public static final String TAG_RATIO = "ratio"; //$NON-NLS-1$ + public static final String TAG_RATIO_LEFT = "ratioLeft"; //$NON-NLS-1$ + public static final String TAG_RATIO_RIGHT = "ratioRight"; //$NON-NLS-1$ + public static final String TAG_ACTIVE_PAGE_ID = "activePageID"; //$NON-NLS-1$ public static final String TAG_EXPANDED = "expanded"; //$NON-NLS-1$ public static final String TAG_PAGE = "page"; //$NON-NLS-1$ Index: LayoutPart.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPart.java,v retrieving revision 1.20 diff -u -r1.20 LayoutPart.java --- LayoutPart.java 8 Apr 2004 00:04:05 -0000 1.20 +++ LayoutPart.java 14 Apr 2004 23:02:24 -0000 @@ -115,6 +115,9 @@ public String getID() { return id; } + public boolean isCompressible() { + return false; + } /** * Return the preference store for layout parts. */ Index: LayoutPartSash.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPartSash.java,v retrieving revision 1.7 diff -u -r1.7 LayoutPartSash.java --- LayoutPartSash.java 30 Mar 2004 02:52:05 -0000 1.7 +++ LayoutPartSash.java 14 Apr 2004 23:02:24 -0000 @@ -9,6 +9,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Randy Hudson + * - Fix for bug 19524 - Resizing WorkbenchWindow resizes Views * Cagatay Kavukcuoglu * - Fix for bug 10025 - Resizing views should not use height ratios **********************************************************************/ @@ -28,7 +30,8 @@ private LayoutPartSash postLimit; SelectionListener selectionListener; - private float ratio = 0.5f; + private float ratio; //legacy + private int left = 300, right = 300; /* Optimize limit checks by calculating minimum * and maximum ratios once per drag @@ -138,9 +141,19 @@ LayoutPartSash getPreLimit() { return preLimit; } + +int getLeft() { + return left; +} + float getRatio() { return ratio; } + +int getRight() { + return right; +} + boolean isHorizontal() { return ((style & SWT.HORIZONTAL) == SWT.HORIZONTAL); } @@ -153,8 +166,15 @@ void setPreLimit(LayoutPartSash newPreLimit) { preLimit = newPreLimit; } + +void setSizes(int left, int right) { + this.left = left; + this.right = right; +} + void setRatio(float newRatio) { - if (newRatio < 0.0 || newRatio > 1.0) return; + if (newRatio < 0.0 || newRatio > 1.0) + return; ratio = newRatio; } @@ -163,12 +183,16 @@ LayoutTreeNode node = root.findSash(this); Rectangle nodeBounds = node.getBounds(); //Recompute ratio + x -= nodeBounds.x; + y -= nodeBounds.y; if(style == SWT.VERTICAL) { - setRatio((float)(x - nodeBounds.x)/(float)nodeBounds.width); + setSizes(x, nodeBounds.width - x); + //setRatio((float)(x - nodeBounds.x)/(float)nodeBounds.width); } else { - setRatio((float)(y - nodeBounds.y)/(float)nodeBounds.height); + setSizes(y, nodeBounds.height - y); + //setRatio((float)(y - nodeBounds.y)/(float)nodeBounds.height); } - + node.setBounds(nodeBounds); initDragRatios(); } Index: LayoutTree.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutTree.java,v retrieving revision 1.7 diff -u -r1.7 LayoutTree.java --- LayoutTree.java 8 Apr 2004 00:04:05 -0000 1.7 +++ LayoutTree.java 14 Apr 2004 23:02:24 -0000 @@ -9,6 +9,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Randy Hudson + * - Fix for bug 19524 - Resizing WorkbenchWindow resizes Views * Cagatay Kavukcuoglu * - Fix for bug 10025 - Resizing views should not use height ratios **********************************************************************/ @@ -141,6 +143,14 @@ oldParent.replaceChild(relativeChild,node); return this; } +} +/** + * Returns true if this tree can be compressed and expanded. + * @return true if springy + */ +public boolean isCompressible() { + //Added for bug 19524 + return part.isCompressible(); } /** * Returns true if this tree has visible parts otherwise returns false. Index: LayoutTreeNode.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutTreeNode.java,v retrieving revision 1.9 diff -u -r1.9 LayoutTreeNode.java --- LayoutTreeNode.java 8 Apr 2004 00:04:05 -0000 1.9 +++ LayoutTreeNode.java 14 Apr 2004 23:02:24 -0000 @@ -9,13 +9,14 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Randy Hudson + * - Fix for bug 19524 - Resizing WorkbenchWindow resizes Views * Cagatay Kavukcuoglu * - Fix for bug 10025 - Resizing views should not use height ratios **********************************************************************/ import java.util.ArrayList; -import org.eclipse.jface.util.Geometry; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; @@ -61,7 +62,7 @@ Rectangle bounds = sash.getBounds(); - int relativePos = Geometry.getRelativePosition(bounds, toFind); + //int relativePos = Geometry.getRelativePosition(bounds, toFind); if(sash.isVertical()) { if (toFind.x < bounds.x + (bounds.width / 2)) { @@ -90,7 +91,8 @@ PartSashContainer.RelationshipInfo r = new PartSashContainer.RelationshipInfo(); r.relative = children[0].computeRelation(relations); r.part = children[1].computeRelation(relations); - r.ratio = getSash().getRatio(); + r.left = getSash().getLeft(); + r.right = getSash().getRight(); r.relationship = getSash().isVertical()?IPageLayout.RIGHT:IPageLayout.BOTTOM; relations.add(0,r); return r.relative; @@ -227,6 +229,7 @@ public boolean isVisible() { return children[0].isVisible() || children[1].isVisible(); } + /** * Recompute the ratios in this tree. The ratio for a node is the width * (or height if the sash is horizontal) of the left child's bounds @@ -307,6 +310,8 @@ * Resize the parts on this tree to fit in bounds. */ public void setBounds(Rectangle bounds) { +// if (bounds.isEmpty()) +// return; if(!children[0].isVisible()) { children[1].setBounds(bounds); return; @@ -321,11 +326,42 @@ Rectangle sashBounds = new Rectangle(bounds.x,bounds.y,bounds.width,bounds.height); float ratio = getSash().getRatio(); + if (ratio != 0.0) { + int length = getSash().isVertical() + ? bounds.width : bounds.height; + getSash().setSizes((int)(length * ratio), length - (int)(length * ratio)); + getSash().setRatio(0.0f); + } + int left = getSash().getLeft(); + int right = getSash().getRight(); + int total = left+right; + + //At first I was going to have a more elaborate weighting system, but all-or-non is + // sufficient + double wLeft = left, wRight = right; + switch (getCompressionBias()) { + case -1: + wLeft = 0.0; + break; + case 1: + wRight = 0.0; + break; + default: + break; + } + double wTotal = wLeft + wRight; if(getSash().isVertical()) { //Work on x and width - leftBounds.width = (int)(ratio * bounds.width); + leftBounds.width = left; + rightBounds.width = right; + + int redistribute = bounds.width - SASH_WIDTH - total; + + leftBounds.x = bounds.x; + leftBounds.width += Math.round(redistribute * wLeft / wTotal); + sashBounds.x = leftBounds.x + leftBounds.width; sashBounds.width = SASH_WIDTH; @@ -334,7 +370,7 @@ } rightBounds.x = sashBounds.x + sashBounds.width; - rightBounds.width = bounds.width - leftBounds.width - sashBounds.width; + rightBounds.width = bounds.x + bounds.width - rightBounds.x; if (children[1].fixedHeight()) { rightBounds.height = children[1].getBounds().height; @@ -343,15 +379,14 @@ adjustWidths(bounds, leftBounds, rightBounds, sashBounds); } else { //Work on y and height + int redistribute = bounds.height - SASH_WIDTH - total; + if (children[0].fixedHeight()) { leftBounds.height = children[0].getBounds().height; + } else if (children[1].fixedHeight()) { + leftBounds.height = bounds.height - children[1].getBounds().height - SASH_WIDTH; } else { - - if (children[1].fixedHeight()) { - leftBounds.height = bounds.height - children[1].getBounds().height - SASH_WIDTH; - } else { - leftBounds.height = (int)(ratio * bounds.height); - } + leftBounds.height = left + (int)Math.round(redistribute * wLeft / wTotal); } sashBounds.y = leftBounds.y + leftBounds.height; sashBounds.height = SASH_WIDTH; @@ -360,7 +395,7 @@ if (children[1].fixedHeight()) { rightBounds.height = children[1].getBounds().height; } else { - rightBounds.height = bounds.height - leftBounds.height - sashBounds.height; + rightBounds.height = bounds.y + bounds.height - rightBounds.y; } adjustHeights(bounds, leftBounds, rightBounds, sashBounds); } @@ -471,7 +506,28 @@ return (part != 0 ) ? part / whole : IPageLayout.RATIO_MIN; } -// getMaximumRatioFor added by cagatayk@acm.org + +//Added by hudsonr@us.ibm.com - bug 19524 + +public boolean isCompressible() { + return children[0].isCompressible() || children[1].isCompressible(); +} + +/** + * Returns 0 if there is no bias. Returns -1 if the first child should be of + * fixed size, and the second child should be compressed. Returns 1 if the + * second child should be of fixed size. + * @return the bias + */ +public int getCompressionBias() { + boolean left = children[0].isCompressible(); + boolean right = children[1].isCompressible(); + if (left == right) + return 0; + if (right) + return -1; + return 1; +}// getMaximumRatioFor added by cagatayk@acm.org /** * Obtain the maximum ratio required to display the control on the "right" * using its minimum dimensions. Index: PartSashContainer.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java,v retrieving revision 1.17 diff -u -r1.17 PartSashContainer.java --- PartSashContainer.java 9 Apr 2004 19:48:41 -0000 1.17 +++ PartSashContainer.java 14 Apr 2004 23:02:24 -0000 @@ -56,6 +56,8 @@ protected LayoutPart relative; protected int relationship; protected float ratio; + protected int left; + protected int right; } private class SashContainerDropTarget extends AbstractDropTarget { @@ -173,7 +175,7 @@ * @param relationship one of PageLayout.TOP, PageLayout.BOTTOM, PageLayout.LEFT, or PageLayout.RIGHT * @param ratio a value between 0.0 and 1.0, indicating how much space will be allocated to the UPPER-LEFT pane * @param relative part where the new part will be attached - * + * @deprecated need to pass in two ints instead of ratio */ public void add(LayoutPart child, int relationship, float ratio, LayoutPart relative) { if (isZoomed()) @@ -207,6 +209,7 @@ boolean left = info.relationship == IPageLayout.LEFT || info.relationship == IPageLayout.TOP; LayoutPartSash sash = new LayoutPartSash(this,vertical); sash.setRatio(info.ratio); + sash.setSizes(info.left, info.right); if((parent != null) && !(child instanceof PartPlaceholder)) sash.createControl(parent); root = root.insert(child,left,sash,info.relative); @@ -354,12 +357,13 @@ return null; return root.findBottomRight(); } + /** * Find a initial position for a new part. */ private void findPosition(RelationshipInfo info) { - info.ratio = (float)0.5; + info.ratio = 0.5f; info.relationship = IPageLayout.RIGHT; info.relative = root.findBottomRight(); @@ -449,6 +453,7 @@ public boolean isZoomed() { return (unzoomRoot != null); } + /** * Move a part to a new position and keep the bounds when possible, ie, * when the new relative part has the same higth or width as the part @@ -828,6 +833,27 @@ root.describeLayout(buf); buf.append(")"); } +} + +public void add(LayoutPart child, int relationship, int left, int right, LayoutPart relative) { + if (isZoomed()) + zoomOut(); + + if (child == null) + return; + if (relative != null && !isChild(relative)) + return; + if (relationship < IPageLayout.LEFT || relationship > IPageLayout.BOTTOM) + relationship = IPageLayout.LEFT; + + // store info about relative positions + RelationshipInfo info = new RelationshipInfo(); + info.part = child; + info.relationship = relationship; + info.left = left; + info.right = right; + info.relative = relative; + addChild(info); } } Index: RootLayoutContainer.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/RootLayoutContainer.java,v retrieving revision 1.12 diff -u -r1.12 RootLayoutContainer.java --- RootLayoutContainer.java 31 Mar 2004 23:46:18 -0000 1.12 +++ RootLayoutContainer.java 14 Apr 2004 23:02:24 -0000 @@ -96,9 +96,14 @@ String relativeID = childMem.getString(IWorkbenchConstants.TAG_RELATIVE); int relationship = 0; float ratio = 0.0f; + int left = 0, right = 0; if (relativeID != null) { relationship = childMem.getInteger(IWorkbenchConstants.TAG_RELATIONSHIP).intValue(); - ratio = childMem.getFloat(IWorkbenchConstants.TAG_RATIO).floatValue(); + Float Ratio = childMem.getFloat(IWorkbenchConstants.TAG_RATIO); + if (Ratio == null) { + left = childMem.getInteger(IWorkbenchConstants.TAG_RATIO_LEFT).intValue(); + right = childMem.getInteger(IWorkbenchConstants.TAG_RATIO_RIGHT).intValue(); + } } String strFolder = childMem.getString(IWorkbenchConstants.TAG_FOLDER); @@ -123,7 +128,10 @@ } else { LayoutPart refPart = (LayoutPart)mapIDtoPart.get(relativeID); if (refPart != null) { - add(part, relationship, ratio, refPart); + if (left != 0) + add(part, relationship, left, right, refPart); + else + add(part, relationship, ratio, refPart); } else { WorkbenchPlugin.log("Unable to find part for ID: " + relativeID);//$NON-NLS-1$ } @@ -155,7 +163,9 @@ if (info.relative != null) { childMem.putString(IWorkbenchConstants.TAG_RELATIVE, info.relative.getID()); childMem.putInteger(IWorkbenchConstants.TAG_RELATIONSHIP, info.relationship); - childMem.putFloat(IWorkbenchConstants.TAG_RATIO, info.ratio); + childMem.putInteger(IWorkbenchConstants.TAG_RATIO_LEFT, info.left); + childMem.putInteger(IWorkbenchConstants.TAG_RATIO_RIGHT, info.right); + //childMem.putFloat(IWorkbenchConstants.TAG_RATIO, info.ratio); } // Is this part a folder or a placeholder for one?