Java Code Examples for org.eclipse.swt.widgets.MenuItem#getDisplay()

The following examples show how to use org.eclipse.swt.widgets.MenuItem#getDisplay() . 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 vote down vote up
/**
 * 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: ContextMenuHelper.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
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);
        }
      });
}