Java Code Examples for org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable#asyncExec()
The following examples show how to use
org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable#asyncExec() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContextActionUiTestUtil.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Clicks on the {@link MenuItem}. * * @param menuItem * the {@link MenuItem} to click on */ private static void click(final MenuItem menuItem) { final Event event = new Event(); event.time = (int) System.currentTimeMillis(); event.widget = menuItem; event.display = menuItem.getDisplay(); event.type = SWT.Selection; UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() { @Override public void run() { if (SWTUtils.hasStyle(menuItem, SWT.CHECK) || SWTUtils.hasStyle(menuItem, SWT.RADIO)) { menuItem.setSelection(!menuItem.getSelection()); } menuItem.notifyListeners(SWT.Selection, event); } }); }
Example 2
Source File: StandardImportAndReadSmokeTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private static void openImportWizard() { fWizard = new ImportTraceWizard(); UIThreadRunnable.asyncExec(new VoidResult() { @Override public void run() { final IWorkbench workbench = PlatformUI.getWorkbench(); // Fire the Import Trace Wizard if (workbench != null) { final IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); Shell shell = activeWorkbenchWindow.getShell(); assertNotNull(shell); ((ImportTraceWizard) fWizard).init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); WizardDialog dialog = new WizardDialog(shell, fWizard); dialog.open(); } } }); fBot.waitUntil(ConditionHelpers.isWizardReady(fWizard)); }
Example 3
Source File: AbstractStandardImportWizardTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Open the import wizard */ public void openImportWizard() { fWizard = new ImportTraceWizard(); UIThreadRunnable.asyncExec(new VoidResult() { @Override public void run() { final IWorkbench workbench = PlatformUI.getWorkbench(); // Fire the Import Trace Wizard if (workbench != null) { final IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); Shell shell = activeWorkbenchWindow.getShell(); assertNotNull(shell); ((ImportTraceWizard) fWizard).init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); WizardDialog dialog = new WizardDialog(shell, fWizard); dialog.open(); } } }); fBot.waitUntil(ConditionHelpers.isWizardReady(fWizard)); }
Example 4
Source File: LamiChartViewerTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Reset the current perspective */ @After public void resetPerspective() { SWTBotView viewBot = fViewBot; if (viewBot != null) { viewBot.close(); } /* * UI Thread executes the reset perspective action, which opens a shell * to confirm the action. The current thread will click on the 'Yes' * button */ Runnable runnable = () -> SWTBotUtils.anyButtonOf(fBot, "Yes", "Reset Perspective").click(); UIThreadRunnable.asyncExec(() -> { IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getWorkbenchWindows()[0]; ActionFactory.RESET_PERSPECTIVE.create(activeWorkbenchWindow).run(); }); runnable.run(); }
Example 5
Source File: ContextMenuHelper.java From saros with GNU General Public License v2.0 | 6 votes |
private static void click(final MenuItem menuItem) { final Event event = new Event(); event.time = (int) System.currentTimeMillis(); event.widget = menuItem; event.display = menuItem.getDisplay(); event.type = SWT.Selection; UIThreadRunnable.asyncExec( menuItem.getDisplay(), new VoidResult() { @Override public void run() { menuItem.notifyListeners(SWT.Selection, event); } }); }
Example 6
Source File: NetworkManipulatorImpl.java From saros with GNU General Public License v2.0 | 4 votes |
@Override public void synchronizeOnActivityQueue(JID jid, long timeout) throws RemoteException { ISarosSession session = this.session; IActivityListener listener = this.listener; // this is too lazy, but ok for testing purposes if (session == null) throw new IllegalStateException("no session running"); if (listener == null) throw new IllegalStateException("no session running"); final CountDownLatch swtThreadSync = new CountDownLatch(1); UIThreadRunnable.asyncExec( new VoidResult() { @Override public void run() { swtThreadSync.countDown(); } }); try { if (!swtThreadSync.await( SarosSWTBotPreferences.SAROS_DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)) { log.warn("could not synchronize on the SWT EDT"); } } catch (InterruptedException e1) { Thread.currentThread().interrupt(); } int id = RANDOM.nextInt(); NOPActivity activity = new NOPActivity(session.getLocalUser(), session.getUser(jid), id); CountDownLatch latch = new CountDownLatch(1); synchronizeRequests.put(id, latch); listener.created(activity); try { if (!latch.await(timeout, TimeUnit.MILLISECONDS)) throw new TimeoutException("no reply from " + jid); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { synchronizeRequests.remove(id); } }