org.eclipse.swt.widgets.MenuItem.getEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中org.eclipse.swt.widgets.MenuItem.getEnabled()方法的一些代码示例,展示了MenuItem.getEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.getEnabled()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.MenuItem
类名称:MenuItem
方法名:getEnabled

[英]Returns true if the receiver is enabled, and false otherwise. A disabled menu item is typically not selectable from the user interface and draws with an inactive or "grayed" look.
[中]如果接收器已启用,则返回true,否则返回false。禁用的菜单项通常无法从用户界面中选择,并以非活动或“灰色”外观绘制。

代码示例

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.databinding

@Override
public boolean doGetBooleanValue(Object source) {
  return ((MenuItem) source).getEnabled();
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

/**
 * Returns <code>true</code> if the receiver is enabled and all
 * of the receiver's ancestors are enabled, and <code>false</code>
 * otherwise. A disabled menu item is typically not selectable from the
 * user interface and draws with an inactive or "grayed" look.
 *
 * @return the receiver's enabled state
 *
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 *
 * @see #getEnabled
 */
public boolean isEnabled() {
 return getEnabled() && parent.isEnabled();
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

/**
 * Returns <code>true</code> if the receiver is enabled and all
 * of the receiver's ancestors are enabled, and <code>false</code>
 * otherwise. A disabled menu item is typically not selectable from the
 * user interface and draws with an inactive or "grayed" look.
 *
 * @return the receiver's enabled state
 *
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 *
 * @see #getEnabled
 */
public boolean isEnabled () {
  return getEnabled () && parent.isEnabled ();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

/**
 * Returns <code>true</code> if the receiver is enabled and all
 * of the receiver's ancestors are enabled, and <code>false</code>
 * otherwise. A disabled menu item is typically not selectable from the
 * user interface and draws with an inactive or "grayed" look.
 *
 * @return the receiver's enabled state
 *
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 *
 * @see #getEnabled
 */
public boolean isEnabled () {
  return getEnabled () && parent.isEnabled ();
}

代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64

/**
 * Returns <code>true</code> if the receiver is enabled and all
 * of the receiver's ancestors are enabled, and <code>false</code>
 * otherwise. A disabled menu item is typically not selectable from the
 * user interface and draws with an inactive or "grayed" look.
 *
 * @return the receiver's enabled state
 *
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 * 
 * @see #getEnabled
 */
public boolean isEnabled () {
  return getEnabled () && parent.isEnabled ();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x

/**
 * Returns <code>true</code> if the receiver is enabled and all
 * of the receiver's ancestors are enabled, and <code>false</code>
 * otherwise. A disabled menu item is typically not selectable from the
 * user interface and draws with an inactive or "grayed" look.
 *
 * @return the receiver's enabled state
 *
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 *
 * @see #getEnabled
 */
public boolean isEnabled () {
  return getEnabled () && parent.isEnabled ();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

/**
 * Returns <code>true</code> if the receiver is enabled and all
 * of the receiver's ancestors are enabled, and <code>false</code>
 * otherwise. A disabled menu item is typically not selectable from the
 * user interface and draws with an inactive or "grayed" look.
 *
 * @return the receiver's enabled state
 *
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 *
 * @see #getEnabled
 */
public boolean isEnabled () {
  return getEnabled () && parent.isEnabled ();
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07

static void writeEnabled( final MenuItem menuItem ) throws IOException {
 Boolean newValue = Boolean.valueOf( menuItem.getEnabled() );
 JSWriter writer = JSWriter.getWriterFor( menuItem );
 Boolean defValue = Boolean.TRUE;
 writer.set( PROP_ENABLED, JSConst.QX_FIELD_ENABLED, newValue, defValue );
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07

static void preserveEnabled( final MenuItem menuItem ) {
 IWidgetAdapter adapter = WidgetUtil.getAdapter( menuItem );
 adapter.preserve( Props.ENABLED, Boolean.valueOf( menuItem.getEnabled() ) );
}

代码示例来源:origin: org.xworker/xworker_swt

public void run() {
    if("enable".equals(m)){
      item.setEnabled(true);
    }else if("disable".equals(m)){
      item.setEnabled(false);
    }else if("reverse".equals(m)){
      item.setEnabled(!item.getEnabled());
    }
  }
});

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

private static boolean isAccessible( MenuItem menuItem ) {
 return menuItem.getEnabled() && isShellAccessible( menuItem.getParent().getShell() );
}

代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64

item.nsItem.setEnabled (enabled && item.getEnabled ());

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

void updateAccelerator (int /*long*/ accelGroup, boolean add) {
  if (accelerator == 0 || !getEnabled ()) return;
  if ((accelerator & SWT.COMMAND) != 0) return;
  int mask = 0;
  if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
  if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
  if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
  int keysym = accelerator & SWT.KEY_MASK;
  int newKey = Display.untranslateKey (keysym);
  if (newKey != 0) {
    keysym = newKey;
  } else {
    switch (keysym) {
      case '\r': keysym = OS.GDK_Return; break;
      default: keysym = Display.wcsToMbcs ((char) keysym);
    }
  }
  /* When accel_key is zero, it causes GTK warnings */
  if (keysym != 0) {
    if (add) {
      OS.gtk_widget_add_accelerator (handle, OS.activate, accelGroup, keysym, mask, OS.GTK_ACCEL_VISIBLE);
    } else {
      OS.gtk_widget_remove_accelerator (handle, accelGroup, keysym, mask);
    }
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

void updateAccelerator (int /*long*/ accelGroup, boolean add) {
  if (accelerator == 0 || !getEnabled ()) return;
  if ((accelerator & SWT.COMMAND) != 0) return;
  int mask = 0;
  if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
  if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
  if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
  int keysym = accelerator & SWT.KEY_MASK;
  int newKey = Display.untranslateKey (keysym);
  if (newKey != 0) {
    keysym = newKey;
  } else {
    switch (keysym) {
      case '\r': keysym = OS.GDK_Return; break;
      default: keysym = Display.wcsToMbcs ((char) keysym);
    }
  }
  /* When accel_key is zero, it causes GTK warnings */
  if (keysym != 0) {
    if (add) {
      OS.gtk_widget_add_accelerator (handle, OS.activate, accelGroup, keysym, mask, OS.GTK_ACCEL_VISIBLE);
    } else {
      OS.gtk_widget_remove_accelerator (handle, accelGroup, keysym, mask);
    }
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x

void updateAccelerator (long /*int*/ accelGroup, boolean add) {
  if (accelerator == 0 || !getEnabled ()) return;
  if ((accelerator & SWT.COMMAND) != 0) return;
  int mask = 0;
  if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
  if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
  if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
  int keysym = accelerator & SWT.KEY_MASK;
  int newKey = Display.untranslateKey (keysym);
  if (newKey != 0) {
    keysym = newKey;
  } else {
    switch (keysym) {
      case '\r': keysym = OS.GDK_Return; break;
      default: keysym = Display.wcsToMbcs ((char) keysym);
    }
  }
  /* When accel_key is zero, it causes GTK warnings */
  if (keysym != 0) {
    if (add) {
      OS.gtk_widget_add_accelerator (handle, OS.activate, accelGroup, keysym, mask, OS.GTK_ACCEL_VISIBLE);
    } else {
      OS.gtk_widget_remove_accelerator (handle, accelGroup, keysym, mask);
    }
  }
}

代码示例来源:origin: org.codehaus.openxma/xmartserver

/**
 * Completely enable/disable the menu.
 * @param enabled true: enable, false: disable.
 */
protected void setMenuEnabled(boolean enabled) {
  if(menuW==null) return;
  boolean wasEnabled=menuW.isEnabled();
  menuW.setEnabled(enabled);
  MenuItem[] items = menuW.getItems();
  //disable the items of the shell bar menu
  for (int i = 0; i < items.length; i++) {
    MenuItem item = items[i];
    at.spardat.xma.appshell.MenuItem xmaItem = (at.spardat.xma.appshell.MenuItem) item.getData();
    if(wasEnabled) { xmaItem.localEnabled=item.getEnabled(); }
    item.setEnabled(enabled&&xmaItem.localEnabled);
  }
}

代码示例来源:origin: org.codehaus.openxma/xmartclient

/**
 * Completely enable/disable the menu.
 * @param enabled true: enable, false: disable.
 */
protected void setMenuEnabled(boolean enabled) {
  if(menuW==null) return;
  boolean wasEnabled=menuW.isEnabled();
  menuW.setEnabled(enabled);
  MenuItem[] items = menuW.getItems();
  //disable the items of the shell bar menu
  for (int i = 0; i < items.length; i++) {
    MenuItem item = items[i];
    at.spardat.xma.appshell.MenuItem xmaItem = (at.spardat.xma.appshell.MenuItem) item.getData();
    if(wasEnabled) { xmaItem.localEnabled=item.getEnabled(); }
    item.setEnabled(enabled&&xmaItem.localEnabled);
  }
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

@Override
public void preserveValues( MenuItem item ) {
 preserveProperty( item, PROP_TEXT, item.getText() );
 preserveProperty( item, PROP_IMAGE, item.getImage() );
 preserveProperty( item, PROP_MENU, item.getMenu() );
 preserveProperty( item, PROP_ENABLED, item.getEnabled() );
 preserveProperty( item, PROP_SELECTION, item.getSelection() );
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

@Override
public void renderChanges( MenuItem item ) throws IOException {
 WidgetLCAUtil.renderCustomVariant( item );
 WidgetLCAUtil.renderData( item );
 renderText( item );
 renderMnemonicIndex( item );
 renderProperty( item, PROP_IMAGE, item.getImage(), null );
 WidgetLCAUtil.renderMenu( item, item.getMenu() );
 renderProperty( item, PROP_ENABLED, item.getEnabled(), true );
 renderProperty( item, PROP_SELECTION, item.getSelection(), false );
 renderListenSelection( item );
 renderListenHelp( item );
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

LRESULT wmDrawChild (int /*long*/ wParam, int /*long*/ lParam) {
  DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
  OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
  if (image != null) {
    GCData data = new GCData();
    data.device = display;
    GC gc = GC.win32_new (struct.hDC, data);
    /*
    * Bug in Windows.  When a bitmap is included in the
    * menu bar, the HDC seems to already include the left
    * coordinate.  The fix is to ignore this value when
    * the item is in a menu bar.
    */
    int x = (parent.style & SWT.BAR) != 0 ? MARGIN_WIDTH * 2 : struct.left;
    Image image = getEnabled () ? this.image : new Image (display, this.image, SWT.IMAGE_DISABLE);
    gc.drawImage (image, DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(struct.top + MARGIN_HEIGHT));
    if (this.image != image) image.dispose ();
    gc.dispose ();
  }
  if (parent.foreground != -1) OS.SetTextColor (struct.hDC, parent.foreground);
  return null;
}

相关文章