Take the 2-minute tour ×

I realise that this is somewhat of an unusual request, since most ViewParts layed out by the workspace and may be in stacks and not have unilateral access to their own size.

However, what i am trying to do is slightly different. I am extending a find-replace bar for eclipse that is reminiscent of the one you see in firefox (and much less obtrusive than the default).

So the desire for this is for it to be a fixed size at the bottom of the editor pane. However, I have not succeeded in setting the size of my view. I have tried

using an ISizeProvider:

public int getSizeFlags(boolean width) {
    if (width) {
        return SWT.FILL;
    return SWT.MIN | SWT.MAX;

public int computePreferredSize(boolean width, int availableParallel,
        int availablePerpendicular, int preferredResult) {
    if (width) {
        return preferredResult;
    return fixedHeight;

calling setSize() on my root pane and on its parent pane (NB it is not surprising this doesn't work because the parent's layout manager will likely override it).

Using the internal PartPane class to get the bordering sashes to attempt to move IT programattically. (Don't flame me for doing this, I am just trying to explore the possibilities).

private void updateSize(IWorkbenchPartReference pPartRef) {
    // FIXME -- this is all internal stuff. is there a public way to do this?
    if (pPartRef instanceof WorkbenchPartReference) {
        PartPane lPane = ((WorkbenchPartReference) pPartRef).getPane();
        Sashes sashes = new Sashes();
        if (lPane.getContainer() != null) {
            lPane.getContainer().findSashes(lPane, sashes );
            Sash topSash = sashes.top;
            if (okToUse(topSash)) {
                Rectangle parentBounds = topSash.getParent().getBounds();
                int topSashTop = parentBounds.height - fixedHeight - topSash.getSize().y;
                sashes.top.setLocation(sashes.top.getLocation().x, topSashTop);
                System.out.println("sashtop = " + topSashTop);

I've also tried calling PartPane.flushLayout() and PartPane.getContainer.resizeChild() and none of these do anything. None of this works. Is there a way to achieve what I want?

Regards, Joe.;

share|improve this question
Have you tried the obvious route of just adding your view to a specific part of your perspective? –  katsharp Jan 23 '12 at 20:59
add comment


Your Answer



Browse other questions tagged or ask your own question.