spt025
spt025

Reputation: 2304

How to Programatically resize Detached Viewpart Window in Eclipse RCP?

I have a Viewpart in Eclipse RCP which I am detaching using inbuild method. Now I have a button on that Detached ViewPart and Upon Clicking it window Size of Windows (in Which detached Viewpart is there) should increase but I can't find any API for the Same. Can Anyone Please Help ?

There is this one Question I found but still don't know how to do this Resize Eclipse RCP Part

Upvotes: 1

Views: 414

Answers (1)

greg-449
greg-449

Reputation: 111217

You just need to set the size of the Shell containing the part.

For example, this command handler increases the size of the shell containing the active part by 100 pixels in each direction:

public class ResizeHandler extends AbstractHandler
{
  @Override
  public Object execute(final ExecutionEvent event) throws ExecutionException
  {
    // Get the active part

    IWorkbenchPart part = HandlerUtil.getActivePart(event);

    // Get the shell from the part site

    Shell shell = part.getSite().getShell();

    Point size = shell.getSize();

    // Set new size

    shell.setSize(size.x + 100, size.y + 100);

    return null;
  }  
}

Note: The question you linked to is talking about the new 'e4' API. Since you are asking about ViewPart you are using the 3.x compatibility API.

Upvotes: 2

Related Questions