本文整理汇总了Java中org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncExec方法的典型用法代码示例。如果您正苦于以下问题:Java UIThreadRunnable.syncExec方法的具体用法?Java UIThreadRunnable.syncExec怎么用?Java UIThreadRunnable.syncExec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable
的用法示例。
在下文中一共展示了UIThreadRunnable.syncExec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeClass
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
public static void beforeClass() {
UIThreadRunnable.syncExec(new VoidResult() {
public void run() {
resetWorkbench();
resetToolbox();
// close browser-based welcome screen (if open)
SWTWorkbenchBot bot = new SWTWorkbenchBot();
try {
SWTBotView welcomeView = bot.viewByTitle("Welcome");
welcomeView.close();
} catch (WidgetNotFoundException e) {
return;
}
}
});
}
示例2: baseBeforeTest
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
@Before
public void baseBeforeTest() {
// Sets codenvy fake API
CodenvyAPI.setClient(new FakeCodenvyClient());
UIThreadRunnable.syncExec(new VoidResult() {
@Override
public void run() {
final Shell eclipseShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
eclipseShell.forceFocus();
}
});
try {
final SWTBotView welcomeView = bot.viewByTitle("Welcome");
welcomeView.close();
} catch (WidgetNotFoundException e) {
// ignore the exception
}
}
示例3: selectTab
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
protected void selectTab(SWTBotGefEditPart part, String label) {
selectPart(part);
Matcher<TabbedPropertyList> matcher = new BaseMatcher<TabbedPropertyList>() {
@Override
public boolean matches(Object item) {
if (item instanceof TabbedPropertyList) {
return true;
}
return false;
}
@Override
public void describeTo(Description description) {
}
};
List<TabbedPropertyList> allWidgets = widget(matcher);
UIThreadRunnable.syncExec(Display.getDefault(), new VoidResult() {
@Override
public void run() {
for (final TabbedPropertyList tabbedProperty : allWidgets) {
final ListElement tabItem = getTabItem(label, tabbedProperty);
if (tabItem != null) {
final Event mouseEvent = createEvent(tabItem);
tabItem.notifyListeners(SWT.MouseUp, mouseEvent);
tabItem.setFocus();
return;
}
}
throw new IllegalStateException("Unable to select the tab " + label);
}
});
}
示例4: setInit
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
public void setInit(SWTBotGefEditPart part, String script) {
selectPart(part);
selectTab(part, INIT);
SWTBotStyledText st = bot.styledTextWithId( WIDGET_ID, WIDGET_SCRIPT);
st.setText(script);
UIThreadRunnable.syncExec(Display.getDefault(), new VoidResult() {
@Override
public void run() {
st.widget.notifyListeners(SWT.FocusOut, null);
editor.setFocus();
}
});
}
示例5: syncWithUIThread
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
protected void syncWithUIThread() {
UIThreadRunnable.syncExec(new VoidResult() {
public void run() {
while (PlatformUI.getWorkbench().getDisplay().readAndDispatch()) {
}
}
});
}
示例6: setGuard
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
public void setGuard(SWTBotGefEditPart part, String script) {
selectPart(part);
selectTab(part, GUARD);
SWTBotStyledText st = bot.styledTextWithId(WIDGET_ID, WIDGET_GUARD_SCRIPT);
st.setText(script);
UIThreadRunnable.syncExec(Display.getDefault(), new VoidResult() {
@Override
public void run() {
st.widget.notifyListeners(SWT.FocusOut, null);
editor.setFocus();
}
});
}
示例7: setAction
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
public void setAction(SWTBotGefEditPart part, String script) {
selectPart(part);
selectTab(part, ACTION);
SWTBotStyledText st = bot.styledTextWithId(WIDGET_ID, WIDGET_ACTION_SCRIPT);
st.setText(script);
UIThreadRunnable.syncExec(Display.getDefault(), new VoidResult() {
@Override
public void run() {
st.widget.notifyListeners(SWT.FocusOut, null);
editor.setFocus();
}
});
}
示例8: absoluteLocation
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
@Override
protected Rectangle absoluteLocation() {
return UIThreadRunnable.syncExec(new Result<Rectangle>() {
@Override
public Rectangle run() {
return display.map(widget.getParent(), null, widget.getBounds());
}
});
}
示例9: resetActivePerspective
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
/**
* Reset active perspective.
*
* @return the fixed default workbench
*/
FixedDefaultWorkbench resetActivePerspective() {
UIThreadRunnable.syncExec(new VoidResult() {
@Override
public void run() {
activePage().resetPerspective();
}
});
return this;
}
示例10: getDisabledContextMenuItems
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
/**
* Returns the disabled {@link SWTBotMenu}s on the given widget bot.
*
* @param widgetBot
* the bot representing the widget, whose disabled {@link SWTBotMenu}s should be returned
* @return the disabled {@link SWTBotMenu}s on the given widget bot
*/
public static List<SWTBotMenu> getDisabledContextMenuItems(final AbstractSWTBot<? extends Control> widgetBot) {
return UIThreadRunnable.syncExec(new Result<List<SWTBotMenu>>() {
@Override
public List<SWTBotMenu> run() {
List<SWTBotMenu> disabledMenuItems = Lists.newArrayList();
for (MenuItem menuItem : new ContextMenuFinder(widgetBot.widget).findMenus(widgetBot.widget.getShell(), WidgetMatcherFactory.widgetOfType(MenuItem.class), true)) {
if (!menuItem.isEnabled()) {
disabledMenuItems.add(new SWTBotMenu(menuItem));
}
}
return disabledMenuItems;
}
});
}
示例11: getTreeItem
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
/**
* Gets the item matching the given name from a tree item.
*
* @param widget the tree item to search
* @param nodeText the text on the node
* @return the child tree item with the specified text
*/
public static TreeItem getTreeItem(final TreeItem widget, final String nodeText) {
return UIThreadRunnable.syncExec(new WidgetResult<TreeItem>() {
@Override
public TreeItem run() {
TreeItem[] items = widget.getItems();
for (TreeItem item : items) {
if (item.getText().equals(nodeText)) {
return item;
}
}
return null;
}
});
}
示例12: findMatches
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
@Override
protected List<TreeItem> findMatches() {
return UIThreadRunnable.syncExec(new ListResult<TreeItem>() {
@Override
public List<TreeItem> run() {
return new ArrayList<TreeItem>(Arrays.asList(parent.getItems()));
}
});
}
示例13: getStyleRange
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
/**
* Retrieves the {@link StyleRange} found at a given offset in the given {@link XtextEditor}.
*
* @param editor
* the {@link XtextEditor}
* @param offset
* the position for which to retrieve the {@link StyleRange}
* @return the {@link StyleRange} found at the given offset
*/
public static StyleRange getStyleRange(final XtextEditor editor, final int offset) {
StyleRange styleRange = UIThreadRunnable.syncExec(new Result<StyleRange>() {
@Override
public StyleRange run() {
StyledText styledText = editor.getInternalSourceViewer().getTextWidget();
return styledText.getStyleRangeAtOffset(offset);
}
});
if (styleRange == null) {
// if no style range was found, then the default style is used
return createStyleRange(offset, 1, createTextAttribute(TEXT_STYLE_DEFAULT));
}
return styleRange;
}
示例14: getContextMenuItem
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
/**
* Returns the context menu item identified by the given labels.
* When a context menu 'Compile' exists with the sub context menu 'All Invalids',
* then the context menu 'All Invalids' is returned when giving the labels 'Compile' and 'All Invalids'.
*
* @param bot
* the {@link AbstractSWTBot} on which to infer the context menu
* @param labels
* the labels on the context menus
* @return the context menu item, {@code null} if the context menu item could not be found
*/
private static MenuItem getContextMenuItem(final AbstractSWTBot<? extends Control> bot, final String... labels) {
return UIThreadRunnable.syncExec(new WidgetResult<MenuItem>() {
@Override
public MenuItem run() {
MenuItem menuItem = null;
Control control = bot.widget;
// MenuDetectEvent
Event event = new Event();
control.notifyListeners(SWT.MenuDetect, event);
if (event.doit) {
Menu menu = control.getMenu();
for (String text : labels) {
Matcher<?> matcher = allOf(instanceOf(MenuItem.class), withMnemonic(text));
menuItem = show(menu, matcher);
if (menuItem != null) {
menu = menuItem.getMenu();
} else {
hide(menu);
break;
}
}
return menuItem;
} else {
return null;
}
}
});
}
示例15: getClipboardContent
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; //导入方法依赖的package包/类
/**
* Get text content from the clipboard.
*
* @param bot
* to work with, must not be {@code null}
* @return clipboard text content, or {@code null} if no text data is available
*/
public static String getClipboardContent(final SWTWorkbenchBot bot) {
Assert.isNotNull(bot, ARGUMENT_BOT);
return UIThreadRunnable.syncExec(new Result<String>() {
@Override
public String run() {
final Clipboard clipboard = new Clipboard(bot.getDisplay());
return (String) clipboard.getContents(TextTransfer.getInstance());
}
});
}