View | Details | Raw Unified | Return to bug 51580 | Differences between
and this patch

Collapse All | Expand All

(-)org/eclipse/ui/IWorkbenchPage.java (+10 lines)
Lines 715-718 Link Here
715
	 * @since 3.0
715
	 * @since 3.0
716
	 */
716
	 */
717
	IViewPart [] getViewStack(IViewPart part);
717
	IViewPart [] getViewStack(IViewPart part);
718
	
719
	/**
720
	 * Resizes the specified view part.
721
	 * 
722
	 * @param part the view part to resize
723
	 * @param width 
724
	 * @param height 
725
	 * @since 3.0
726
	 */
727
	public void resizeView(IViewPart part, int width, int height);
718
}
728
}
(-)org/eclipse/ui/internal/WorkbenchPage.java (+105 lines)
Lines 45-50 Link Here
45
import org.eclipse.swt.events.ControlAdapter;
45
import org.eclipse.swt.events.ControlAdapter;
46
import org.eclipse.swt.events.ControlEvent;
46
import org.eclipse.swt.events.ControlEvent;
47
import org.eclipse.swt.events.ControlListener;
47
import org.eclipse.swt.events.ControlListener;
48
import org.eclipse.swt.graphics.Rectangle;
48
import org.eclipse.swt.widgets.Composite;
49
import org.eclipse.swt.widgets.Composite;
49
import org.eclipse.swt.widgets.Control;
50
import org.eclipse.swt.widgets.Control;
50
import org.eclipse.swt.widgets.Display;
51
import org.eclipse.swt.widgets.Display;
Lines 3457-3461 Link Here
3457
		}
3458
		}
3458
		
3459
		
3459
		return new IViewPart [] {part};
3460
		return new IViewPart [] {part};
3461
	}
3462
	/* (non-Javadoc)
3463
	 * @see org.eclipse.ui.IWorkbenchPage#resizeView(org.eclipse.ui.IViewPart, int, int)
3464
	 */
3465
	public void resizeView(IViewPart part, int width, int height) {
3466
		SashInfo sashInfo = new SashInfo();
3467
		PartPane pane = ((PartSite)part.getSite()).getPane();
3468
		ILayoutContainer container = pane.getContainer();
3469
		LayoutTree tree = getPerspectivePresentation().getLayout().root.find(((PartTabFolder)container));
3470
		
3471
		// retrieve our layout sashes from the layout tree
3472
		findSashParts(tree, pane.findSashes(), sashInfo);
3473
		
3474
		// first set the width
3475
		float deltaWidth = width - pane.getBounds().width;
3476
		if (sashInfo.right != null) {
3477
			Rectangle rightBounds = sashInfo.rightNode.getBounds();
3478
			// set the new ratio 
3479
			sashInfo.right.setRatio(
3480
				((float) ((deltaWidth + sashInfo.right.getBounds().x) - rightBounds.x))
3481
					/ ((float) rightBounds.width));		
3482
			// complete the resize
3483
			sashInfo.rightNode.setBounds(rightBounds);	
3484
		}
3485
		else if (sashInfo.left != null) {
3486
			Rectangle leftBounds = sashInfo.leftNode.getBounds();
3487
			// set the ratio
3488
			sashInfo.left.setRatio(
3489
				(float) ((sashInfo.left.getBounds().x - deltaWidth) - leftBounds.x)
3490
					/ ((float) leftBounds.width));			
3491
			// complete the resize
3492
			sashInfo.leftNode.setBounds(sashInfo.leftNode.getBounds());
3493
		}
3494
3495
		// next set the height
3496
		float deltaHeight = height - pane.getBounds().height;
3497
		if (sashInfo.bottom != null) {
3498
			Rectangle bottomBounds = sashInfo.bottomNode.getBounds();
3499
			// set the new ratio 
3500
			sashInfo.bottom.setRatio(
3501
				((float) ((deltaHeight + sashInfo.bottom.getBounds().y) - bottomBounds.y))
3502
					/ ((float) bottomBounds.height));		
3503
			// complete the resize
3504
			sashInfo.bottomNode.setBounds(bottomBounds);	
3505
		}
3506
		else if (sashInfo.top != null) {
3507
			Rectangle topBounds = sashInfo.topNode.getBounds();
3508
			// set the ratio
3509
			sashInfo.top.setRatio(
3510
				(float) ((sashInfo.top.getBounds().y - deltaHeight) - topBounds.y)
3511
					/ ((float) topBounds.height));			
3512
			// complete the resize
3513
			sashInfo.topNode.setBounds(topBounds);
3514
		}	
3515
3516
	}
3517
	// provides sash information for the given pane
3518
	private class SashInfo {
3519
		private LayoutPartSash right;
3520
		private LayoutPartSash left;
3521
		private LayoutPartSash top;
3522
		private LayoutPartSash bottom;
3523
		private LayoutTreeNode rightNode;
3524
		private LayoutTreeNode leftNode;
3525
		private LayoutTreeNode topNode;
3526
		private LayoutTreeNode bottomNode;
3527
	}
3528
	private void findSashParts(LayoutTree tree, PartPane.Sashes sashes, SashInfo info) {
3529
		LayoutTree parent = tree.getParent();
3530
		if (parent == null)
3531
			return;
3532
3533
		if (parent.part instanceof LayoutPartSash) {
3534
			// get the layout part sash from this tree node
3535
			LayoutPartSash sash = (LayoutPartSash) parent.part;			
3536
			// make sure it has a sash control
3537
			Control control = sash.getControl();
3538
			if (control != null) {
3539
				// check for a vertical sash
3540
				if (sash.isVertical()) {
3541
					if (sashes.left == control) {
3542
						info.left = sash;
3543
						info.leftNode = parent.findSash(sash);
3544
					}
3545
					else if (sashes.right == control) {
3546
						info.right = sash;
3547
						info.rightNode = parent.findSash(sash);
3548
					}
3549
				}				
3550
				// check for a horizontal sash
3551
				else {
3552
					if (sashes.top == control) {
3553
						info.top = sash;
3554
						info.topNode = parent.findSash(sash);	
3555
					}
3556
					else if (sashes.bottom == control) {
3557
						info.bottom = sash;
3558
						info.bottomNode = parent.findSash(sash);
3559
					}
3560
				}
3561
			}
3562
		}
3563
		// recursive call to continue up the tree
3564
		findSashParts(parent, sashes, info);		
3460
	}
3565
	}
3461
}
3566
}

Return to bug 51580