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

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

本文整理了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

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

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

  1. /**
  2. * Returns <code>true</code> if the receiver is enabled and all
  3. * of the receiver's ancestors are enabled, and <code>false</code>
  4. * otherwise. A disabled menu item is typically not selectable from the
  5. * user interface and draws with an inactive or "grayed" look.
  6. *
  7. * @return the receiver's enabled state
  8. *
  9. * @exception SWTException <ul>
  10. * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
  11. * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  12. * </ul>
  13. *
  14. * @see #getEnabled
  15. */
  16. public boolean isEnabled() {
  17. return getEnabled() && parent.isEnabled();
  18. }

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

  1. /**
  2. * Returns <code>true</code> if the receiver is enabled and all
  3. * of the receiver's ancestors are enabled, and <code>false</code>
  4. * otherwise. A disabled menu item is typically not selectable from the
  5. * user interface and draws with an inactive or "grayed" look.
  6. *
  7. * @return the receiver's enabled state
  8. *
  9. * @exception SWTException <ul>
  10. * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
  11. * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  12. * </ul>
  13. *
  14. * @see #getEnabled
  15. */
  16. public boolean isEnabled () {
  17. return getEnabled () && parent.isEnabled ();
  18. }

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

  1. /**
  2. * Returns <code>true</code> if the receiver is enabled and all
  3. * of the receiver's ancestors are enabled, and <code>false</code>
  4. * otherwise. A disabled menu item is typically not selectable from the
  5. * user interface and draws with an inactive or "grayed" look.
  6. *
  7. * @return the receiver's enabled state
  8. *
  9. * @exception SWTException <ul>
  10. * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
  11. * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  12. * </ul>
  13. *
  14. * @see #getEnabled
  15. */
  16. public boolean isEnabled () {
  17. return getEnabled () && parent.isEnabled ();
  18. }

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

  1. /**
  2. * Returns <code>true</code> if the receiver is enabled and all
  3. * of the receiver's ancestors are enabled, and <code>false</code>
  4. * otherwise. A disabled menu item is typically not selectable from the
  5. * user interface and draws with an inactive or "grayed" look.
  6. *
  7. * @return the receiver's enabled state
  8. *
  9. * @exception SWTException <ul>
  10. * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
  11. * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  12. * </ul>
  13. *
  14. * @see #getEnabled
  15. */
  16. public boolean isEnabled () {
  17. return getEnabled () && parent.isEnabled ();
  18. }

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

  1. /**
  2. * Returns <code>true</code> if the receiver is enabled and all
  3. * of the receiver's ancestors are enabled, and <code>false</code>
  4. * otherwise. A disabled menu item is typically not selectable from the
  5. * user interface and draws with an inactive or "grayed" look.
  6. *
  7. * @return the receiver's enabled state
  8. *
  9. * @exception SWTException <ul>
  10. * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
  11. * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  12. * </ul>
  13. *
  14. * @see #getEnabled
  15. */
  16. public boolean isEnabled () {
  17. return getEnabled () && parent.isEnabled ();
  18. }

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

  1. /**
  2. * Returns <code>true</code> if the receiver is enabled and all
  3. * of the receiver's ancestors are enabled, and <code>false</code>
  4. * otherwise. A disabled menu item is typically not selectable from the
  5. * user interface and draws with an inactive or "grayed" look.
  6. *
  7. * @return the receiver's enabled state
  8. *
  9. * @exception SWTException <ul>
  10. * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
  11. * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  12. * </ul>
  13. *
  14. * @see #getEnabled
  15. */
  16. public boolean isEnabled () {
  17. return getEnabled () && parent.isEnabled ();
  18. }

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

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

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

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

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

  1. public void run() {
  2. if("enable".equals(m)){
  3. item.setEnabled(true);
  4. }else if("disable".equals(m)){
  5. item.setEnabled(false);
  6. }else if("reverse".equals(m)){
  7. item.setEnabled(!item.getEnabled());
  8. }
  9. }
  10. });

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

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

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

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

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

  1. void updateAccelerator (int /*long*/ accelGroup, boolean add) {
  2. if (accelerator == 0 || !getEnabled ()) return;
  3. if ((accelerator & SWT.COMMAND) != 0) return;
  4. int mask = 0;
  5. if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
  6. if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
  7. if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
  8. int keysym = accelerator & SWT.KEY_MASK;
  9. int newKey = Display.untranslateKey (keysym);
  10. if (newKey != 0) {
  11. keysym = newKey;
  12. } else {
  13. switch (keysym) {
  14. case '\r': keysym = OS.GDK_Return; break;
  15. default: keysym = Display.wcsToMbcs ((char) keysym);
  16. }
  17. }
  18. /* When accel_key is zero, it causes GTK warnings */
  19. if (keysym != 0) {
  20. if (add) {
  21. OS.gtk_widget_add_accelerator (handle, OS.activate, accelGroup, keysym, mask, OS.GTK_ACCEL_VISIBLE);
  22. } else {
  23. OS.gtk_widget_remove_accelerator (handle, accelGroup, keysym, mask);
  24. }
  25. }
  26. }

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

  1. void updateAccelerator (int /*long*/ accelGroup, boolean add) {
  2. if (accelerator == 0 || !getEnabled ()) return;
  3. if ((accelerator & SWT.COMMAND) != 0) return;
  4. int mask = 0;
  5. if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
  6. if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
  7. if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
  8. int keysym = accelerator & SWT.KEY_MASK;
  9. int newKey = Display.untranslateKey (keysym);
  10. if (newKey != 0) {
  11. keysym = newKey;
  12. } else {
  13. switch (keysym) {
  14. case '\r': keysym = OS.GDK_Return; break;
  15. default: keysym = Display.wcsToMbcs ((char) keysym);
  16. }
  17. }
  18. /* When accel_key is zero, it causes GTK warnings */
  19. if (keysym != 0) {
  20. if (add) {
  21. OS.gtk_widget_add_accelerator (handle, OS.activate, accelGroup, keysym, mask, OS.GTK_ACCEL_VISIBLE);
  22. } else {
  23. OS.gtk_widget_remove_accelerator (handle, accelGroup, keysym, mask);
  24. }
  25. }
  26. }

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

  1. void updateAccelerator (long /*int*/ accelGroup, boolean add) {
  2. if (accelerator == 0 || !getEnabled ()) return;
  3. if ((accelerator & SWT.COMMAND) != 0) return;
  4. int mask = 0;
  5. if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
  6. if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
  7. if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
  8. int keysym = accelerator & SWT.KEY_MASK;
  9. int newKey = Display.untranslateKey (keysym);
  10. if (newKey != 0) {
  11. keysym = newKey;
  12. } else {
  13. switch (keysym) {
  14. case '\r': keysym = OS.GDK_Return; break;
  15. default: keysym = Display.wcsToMbcs ((char) keysym);
  16. }
  17. }
  18. /* When accel_key is zero, it causes GTK warnings */
  19. if (keysym != 0) {
  20. if (add) {
  21. OS.gtk_widget_add_accelerator (handle, OS.activate, accelGroup, keysym, mask, OS.GTK_ACCEL_VISIBLE);
  22. } else {
  23. OS.gtk_widget_remove_accelerator (handle, accelGroup, keysym, mask);
  24. }
  25. }
  26. }

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

  1. /**
  2. * Completely enable/disable the menu.
  3. * @param enabled true: enable, false: disable.
  4. */
  5. protected void setMenuEnabled(boolean enabled) {
  6. if(menuW==null) return;
  7. boolean wasEnabled=menuW.isEnabled();
  8. menuW.setEnabled(enabled);
  9. MenuItem[] items = menuW.getItems();
  10. //disable the items of the shell bar menu
  11. for (int i = 0; i < items.length; i++) {
  12. MenuItem item = items[i];
  13. at.spardat.xma.appshell.MenuItem xmaItem = (at.spardat.xma.appshell.MenuItem) item.getData();
  14. if(wasEnabled) { xmaItem.localEnabled=item.getEnabled(); }
  15. item.setEnabled(enabled&&xmaItem.localEnabled);
  16. }
  17. }

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

  1. /**
  2. * Completely enable/disable the menu.
  3. * @param enabled true: enable, false: disable.
  4. */
  5. protected void setMenuEnabled(boolean enabled) {
  6. if(menuW==null) return;
  7. boolean wasEnabled=menuW.isEnabled();
  8. menuW.setEnabled(enabled);
  9. MenuItem[] items = menuW.getItems();
  10. //disable the items of the shell bar menu
  11. for (int i = 0; i < items.length; i++) {
  12. MenuItem item = items[i];
  13. at.spardat.xma.appshell.MenuItem xmaItem = (at.spardat.xma.appshell.MenuItem) item.getData();
  14. if(wasEnabled) { xmaItem.localEnabled=item.getEnabled(); }
  15. item.setEnabled(enabled&&xmaItem.localEnabled);
  16. }
  17. }

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

  1. @Override
  2. public void preserveValues( MenuItem item ) {
  3. preserveProperty( item, PROP_TEXT, item.getText() );
  4. preserveProperty( item, PROP_IMAGE, item.getImage() );
  5. preserveProperty( item, PROP_MENU, item.getMenu() );
  6. preserveProperty( item, PROP_ENABLED, item.getEnabled() );
  7. preserveProperty( item, PROP_SELECTION, item.getSelection() );
  8. }

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

  1. @Override
  2. public void renderChanges( MenuItem item ) throws IOException {
  3. WidgetLCAUtil.renderCustomVariant( item );
  4. WidgetLCAUtil.renderData( item );
  5. renderText( item );
  6. renderMnemonicIndex( item );
  7. renderProperty( item, PROP_IMAGE, item.getImage(), null );
  8. WidgetLCAUtil.renderMenu( item, item.getMenu() );
  9. renderProperty( item, PROP_ENABLED, item.getEnabled(), true );
  10. renderProperty( item, PROP_SELECTION, item.getSelection(), false );
  11. renderListenSelection( item );
  12. renderListenHelp( item );
  13. }

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

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

相关文章