Showing posts with label maximize. Show all posts
Showing posts with label maximize. Show all posts

Sunday, August 18, 2013

VoidResult and its use

asyncExec method of UIThreadRunnable takes a VoidResult parameter.

It's useful for running code in UIThread which involves inter thread communication.

VoidResult interface has a method run().
Put the code in run() you want to execute in UI Thread.
for example you want to call setMaximized(..) method on a Shell you can do this.

Maximize Eclipse active window from SWTBot

Here's a simple way of achieving above
   
private void maximizeActiveWindow() {
        final Shell activeShell = bot.activeShell().widget;
        VoidResult maximizeShell = new VoidResult() {
            @Override
            public void run() {
                    activeShell.setMaximized(true);
            }
        };
        syncExec(maximizeShell);
    }

There's another way of doing above here.