Search in sources :

Example 1 with VoidResult

use of org.eclipse.swtbot.swt.finder.results.VoidResult in project linuxtools by eclipse.

the class SWTUtils method hideMenu.

/**
 * Hides the menu for the given <code>tree</code>
 *
 * @param tree
 *            the tree whose {@link Menu} should be hidden
 */
public static void hideMenu(final SWTBotTree tree) {
    try {
        final Menu menu = UIThreadRunnable.syncExec((Result<Menu>) () -> tree.widget.getMenu());
        UIThreadRunnable.syncExec(new VoidResult() {

            @Override
            public void run() {
                hide(menu);
            }

            private void hide(final Menu menu) {
                menu.notifyListeners(SWT.Hide, new Event());
                if (menu.getParentMenu() != null) {
                    hide(menu.getParentMenu());
                }
            }
        });
    } catch (WidgetNotFoundException e) {
    // ignore if widget is not found, that's probably because there's no
    // tree in the
    // Docker Explorer view for the test that just ran.
    }
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) VoidResult(org.eclipse.swtbot.swt.finder.results.VoidResult) Event(org.eclipse.swt.widgets.Event) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) Menu(org.eclipse.swt.widgets.Menu)

Example 2 with VoidResult

use of org.eclipse.swtbot.swt.finder.results.VoidResult in project xtext-xtend by eclipse.

the class AbstractSwtBotTest method initialize.

@BeforeClass
public static void initialize() throws Exception {
    TargetPlatformUtil.setTargetPlatform(AbstractSwtBotTest.class);
    IResourcesSetupUtil.cleanWorkspace();
    UIThreadRunnable.syncExec(new VoidResult() {

        @Override
        public void run() {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive();
        }
    });
}
Also used : VoidResult(org.eclipse.swtbot.swt.finder.results.VoidResult) BeforeClass(org.junit.BeforeClass)

Example 3 with VoidResult

use of org.eclipse.swtbot.swt.finder.results.VoidResult in project xtext-xtend by eclipse.

the class AbstractRefactoringSwtBotTest method initialize.

@BeforeClass
public static void initialize() {
    try {
        TargetPlatformUtil.setTargetPlatform(AbstractRefactoringSwtBotTest.class);
        IResourcesSetupUtil.cleanWorkspace();
        SWTWorkbenchBot _sWTWorkbenchBot = new SWTWorkbenchBot();
        AbstractRefactoringSwtBotTest.bot = _sWTWorkbenchBot;
        UIThreadRunnable.syncExec(new VoidResult() {

            @Override
            public void run() {
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive();
            }
        });
        SwtBotProjectHelper.newXtendProject(AbstractRefactoringSwtBotTest.bot, "test");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) VoidResult(org.eclipse.swtbot.swt.finder.results.VoidResult) BeforeClass(org.junit.BeforeClass)

Aggregations

VoidResult (org.eclipse.swtbot.swt.finder.results.VoidResult)3 BeforeClass (org.junit.BeforeClass)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 Event (org.eclipse.swt.widgets.Event)1 Menu (org.eclipse.swt.widgets.Menu)1 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)1 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)1 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)1