Lines 20-26
Link Here
|
20 |
import java.util.Iterator; |
20 |
import java.util.Iterator; |
21 |
import java.util.List; |
21 |
import java.util.List; |
22 |
import java.util.Set; |
22 |
import java.util.Set; |
23 |
|
|
|
24 |
import org.eclipse.core.runtime.IAdaptable; |
23 |
import org.eclipse.core.runtime.IAdaptable; |
25 |
import org.eclipse.core.runtime.IProgressMonitor; |
24 |
import org.eclipse.core.runtime.IProgressMonitor; |
26 |
import org.eclipse.core.runtime.IStatus; |
25 |
import org.eclipse.core.runtime.IStatus; |
Lines 45-51
Link Here
|
45 |
import org.eclipse.swt.events.ControlAdapter; |
44 |
import org.eclipse.swt.events.ControlAdapter; |
46 |
import org.eclipse.swt.events.ControlEvent; |
45 |
import org.eclipse.swt.events.ControlEvent; |
47 |
import org.eclipse.swt.events.ControlListener; |
46 |
import org.eclipse.swt.events.ControlListener; |
48 |
import org.eclipse.swt.graphics.Rectangle; |
|
|
49 |
import org.eclipse.swt.widgets.Composite; |
47 |
import org.eclipse.swt.widgets.Composite; |
50 |
import org.eclipse.swt.widgets.Control; |
48 |
import org.eclipse.swt.widgets.Control; |
51 |
import org.eclipse.swt.widgets.Display; |
49 |
import org.eclipse.swt.widgets.Display; |
Lines 3471-3587
Link Here
|
3471 |
|
3469 |
|
3472 |
return new IViewPart [] {part}; |
3470 |
return new IViewPart [] {part}; |
3473 |
} |
3471 |
} |
3474 |
/** |
3472 |
// /** |
3475 |
* Allow for programmatically resizing a part. |
3473 |
// * Allow for programmatically resizing a part. |
3476 |
* <p> |
3474 |
// * <p> |
3477 |
* <em>EXPERIMENTAL</em> |
3475 |
// * <em>EXPERIMENTAL</em> |
3478 |
* </p> |
3476 |
// * </p> |
3479 |
* <p> |
3477 |
// * <p> |
3480 |
* Known limitations: |
3478 |
// * Known limitations: |
3481 |
* <ul> |
3479 |
// * <ul> |
3482 |
* <li>currently applies only to views</li> |
3480 |
// * <li>currently applies only to views</li> |
3483 |
* <li>has no effect when view is zoomed</li> |
3481 |
// * <li>has no effect when view is zoomed</li> |
3484 |
* </ul> |
3482 |
// * </ul> |
3485 |
*/ |
3483 |
// */ |
3486 |
public void resizeView(IViewPart part, int width, int height) { |
3484 |
// public void resizeView(IViewPart part, int width, int height) { |
3487 |
SashInfo sashInfo = new SashInfo(); |
3485 |
// SashInfo sashInfo = new SashInfo(); |
3488 |
PartPane pane = ((PartSite)part.getSite()).getPane(); |
3486 |
// PartPane pane = ((PartSite)part.getSite()).getPane(); |
3489 |
ILayoutContainer container = pane.getContainer(); |
3487 |
// ILayoutContainer container = pane.getContainer(); |
3490 |
LayoutTree tree = getPerspectivePresentation().getLayout().root.find(((PartTabFolder)container)); |
3488 |
// LayoutTree tree = getPerspectivePresentation().getLayout().root.find(((PartTabFolder)container)); |
3491 |
|
3489 |
// |
3492 |
// retrieve our layout sashes from the layout tree |
3490 |
// // retrieve our layout sashes from the layout tree |
3493 |
findSashParts(tree, pane.findSashes(), sashInfo); |
3491 |
// findSashParts(tree, pane.findSashes(), sashInfo); |
3494 |
|
3492 |
// |
3495 |
// first set the width |
3493 |
// // first set the width |
3496 |
float deltaWidth = width - pane.getBounds().width; |
3494 |
// float deltaWidth = width - pane.getBounds().width; |
3497 |
if (sashInfo.right != null) { |
3495 |
// if (sashInfo.right != null) { |
3498 |
Rectangle rightBounds = sashInfo.rightNode.getBounds(); |
3496 |
// Rectangle rightBounds = sashInfo.rightNode.getBounds(); |
3499 |
// set the new ratio |
3497 |
// // set the new ratio |
3500 |
sashInfo.right.setRatio( |
3498 |
// sashInfo.right.setRatio( |
3501 |
((float) ((deltaWidth + sashInfo.right.getBounds().x) - rightBounds.x)) |
3499 |
// ((float) ((deltaWidth + sashInfo.right.getBounds().x) - rightBounds.x)) |
3502 |
/ ((float) rightBounds.width)); |
3500 |
// / ((float) rightBounds.width)); |
3503 |
// complete the resize |
3501 |
// // complete the resize |
3504 |
sashInfo.rightNode.setBounds(rightBounds); |
3502 |
// sashInfo.rightNode.setBounds(rightBounds); |
3505 |
} |
3503 |
// } |
3506 |
else if (sashInfo.left != null) { |
3504 |
// else if (sashInfo.left != null) { |
3507 |
Rectangle leftBounds = sashInfo.leftNode.getBounds(); |
3505 |
// Rectangle leftBounds = sashInfo.leftNode.getBounds(); |
3508 |
// set the ratio |
3506 |
// // set the ratio |
3509 |
sashInfo.left.setRatio( |
3507 |
// sashInfo.left.setRatio( |
3510 |
(float) ((sashInfo.left.getBounds().x - deltaWidth) - leftBounds.x) |
3508 |
// (float) ((sashInfo.left.getBounds().x - deltaWidth) - leftBounds.x) |
3511 |
/ ((float) leftBounds.width)); |
3509 |
// / ((float) leftBounds.width)); |
3512 |
// complete the resize |
3510 |
// // complete the resize |
3513 |
sashInfo.leftNode.setBounds(sashInfo.leftNode.getBounds()); |
3511 |
// sashInfo.leftNode.setBounds(sashInfo.leftNode.getBounds()); |
3514 |
} |
3512 |
// } |
3515 |
|
3513 |
// |
3516 |
// next set the height |
3514 |
// // next set the height |
3517 |
float deltaHeight = height - pane.getBounds().height; |
3515 |
// float deltaHeight = height - pane.getBounds().height; |
3518 |
if (sashInfo.bottom != null) { |
3516 |
// if (sashInfo.bottom != null) { |
3519 |
Rectangle bottomBounds = sashInfo.bottomNode.getBounds(); |
3517 |
// Rectangle bottomBounds = sashInfo.bottomNode.getBounds(); |
3520 |
// set the new ratio |
3518 |
// // set the new ratio |
3521 |
sashInfo.bottom.setRatio( |
3519 |
// sashInfo.bottom.setRatio( |
3522 |
((float) ((deltaHeight + sashInfo.bottom.getBounds().y) - bottomBounds.y)) |
3520 |
// ((float) ((deltaHeight + sashInfo.bottom.getBounds().y) - bottomBounds.y)) |
3523 |
/ ((float) bottomBounds.height)); |
3521 |
// / ((float) bottomBounds.height)); |
3524 |
// complete the resize |
3522 |
// // complete the resize |
3525 |
sashInfo.bottomNode.setBounds(bottomBounds); |
3523 |
// sashInfo.bottomNode.setBounds(bottomBounds); |
3526 |
} |
3524 |
// } |
3527 |
else if (sashInfo.top != null) { |
3525 |
// else if (sashInfo.top != null) { |
3528 |
Rectangle topBounds = sashInfo.topNode.getBounds(); |
3526 |
// Rectangle topBounds = sashInfo.topNode.getBounds(); |
3529 |
// set the ratio |
3527 |
// // set the ratio |
3530 |
sashInfo.top.setRatio( |
3528 |
// sashInfo.top.setRatio( |
3531 |
(float) ((sashInfo.top.getBounds().y - deltaHeight) - topBounds.y) |
3529 |
// (float) ((sashInfo.top.getBounds().y - deltaHeight) - topBounds.y) |
3532 |
/ ((float) topBounds.height)); |
3530 |
// / ((float) topBounds.height)); |
3533 |
// complete the resize |
3531 |
// // complete the resize |
3534 |
sashInfo.topNode.setBounds(topBounds); |
3532 |
// sashInfo.topNode.setBounds(topBounds); |
3535 |
} |
3533 |
// } |
3536 |
|
3534 |
// |
3537 |
} |
3535 |
// } |
3538 |
// provides sash information for the given pane |
3536 |
// // provides sash information for the given pane |
3539 |
private class SashInfo { |
3537 |
// private class SashInfo { |
3540 |
private LayoutPartSash right; |
3538 |
// private LayoutPartSash right; |
3541 |
private LayoutPartSash left; |
3539 |
// private LayoutPartSash left; |
3542 |
private LayoutPartSash top; |
3540 |
// private LayoutPartSash top; |
3543 |
private LayoutPartSash bottom; |
3541 |
// private LayoutPartSash bottom; |
3544 |
private LayoutTreeNode rightNode; |
3542 |
// private LayoutTreeNode rightNode; |
3545 |
private LayoutTreeNode leftNode; |
3543 |
// private LayoutTreeNode leftNode; |
3546 |
private LayoutTreeNode topNode; |
3544 |
// private LayoutTreeNode topNode; |
3547 |
private LayoutTreeNode bottomNode; |
3545 |
// private LayoutTreeNode bottomNode; |
3548 |
} |
3546 |
// } |
3549 |
private void findSashParts(LayoutTree tree, PartPane.Sashes sashes, SashInfo info) { |
3547 |
// private void findSashParts(LayoutTree tree, PartPane.Sashes sashes, SashInfo info) { |
3550 |
LayoutTree parent = tree.getParent(); |
3548 |
// LayoutTree parent = tree.getParent(); |
3551 |
if (parent == null) |
3549 |
// if (parent == null) |
3552 |
return; |
3550 |
// return; |
3553 |
|
3551 |
// |
3554 |
if (parent.part instanceof LayoutPartSash) { |
3552 |
// if (parent.part instanceof LayoutPartSash) { |
3555 |
// get the layout part sash from this tree node |
3553 |
// // get the layout part sash from this tree node |
3556 |
LayoutPartSash sash = (LayoutPartSash) parent.part; |
3554 |
// LayoutPartSash sash = (LayoutPartSash) parent.part; |
3557 |
// make sure it has a sash control |
3555 |
// // make sure it has a sash control |
3558 |
Control control = sash.getControl(); |
3556 |
// Control control = sash.getControl(); |
3559 |
if (control != null) { |
3557 |
// if (control != null) { |
3560 |
// check for a vertical sash |
3558 |
// // check for a vertical sash |
3561 |
if (sash.isVertical()) { |
3559 |
// if (sash.isVertical()) { |
3562 |
if (sashes.left == control) { |
3560 |
// if (sashes.left == control) { |
3563 |
info.left = sash; |
3561 |
// info.left = sash; |
3564 |
info.leftNode = parent.findSash(sash); |
3562 |
// info.leftNode = parent.findSash(sash); |
3565 |
} |
3563 |
// } |
3566 |
else if (sashes.right == control) { |
3564 |
// else if (sashes.right == control) { |
3567 |
info.right = sash; |
3565 |
// info.right = sash; |
3568 |
info.rightNode = parent.findSash(sash); |
3566 |
// info.rightNode = parent.findSash(sash); |
3569 |
} |
3567 |
// } |
3570 |
} |
3568 |
// } |
3571 |
// check for a horizontal sash |
3569 |
// // check for a horizontal sash |
3572 |
else { |
3570 |
// else { |
3573 |
if (sashes.top == control) { |
3571 |
// if (sashes.top == control) { |
3574 |
info.top = sash; |
3572 |
// info.top = sash; |
3575 |
info.topNode = parent.findSash(sash); |
3573 |
// info.topNode = parent.findSash(sash); |
3576 |
} |
3574 |
// } |
3577 |
else if (sashes.bottom == control) { |
3575 |
// else if (sashes.bottom == control) { |
3578 |
info.bottom = sash; |
3576 |
// info.bottom = sash; |
3579 |
info.bottomNode = parent.findSash(sash); |
3577 |
// info.bottomNode = parent.findSash(sash); |
3580 |
} |
3578 |
// } |
3581 |
} |
3579 |
// } |
3582 |
} |
3580 |
// } |
3583 |
} |
3581 |
// } |
3584 |
// recursive call to continue up the tree |
3582 |
// // recursive call to continue up the tree |
3585 |
findSashParts(parent, sashes, info); |
3583 |
// findSashParts(parent, sashes, info); |
3586 |
} |
3584 |
// } |
3587 |
} |
3585 |
} |