private void updateToolItem() {
    final ToolItem item = (ToolItem) this.widget;

    final boolean shouldBeEnabled = isEnabled();

    // disabled command + visibility follows enablement == disposed
    if (item.isDisposed()) {
      return;
    }

    final String text = this.label;
    if ((this.icon == null || (this.mode & MODE_FORCE_TEXT) == MODE_FORCE_TEXT) && text != null) {
      item.setText(text);
    }

    final String toolTipText = getToolTipText(text);
    item.setToolTipText(toolTipText);

    if (item.getSelection() != this.checkedState) {
      item.setSelection(this.checkedState);
    }

    if (item.getEnabled() != shouldBeEnabled) {
      item.setEnabled(shouldBeEnabled);
    }
  }
示例#2
0
 @Override
 void releaseChildren(boolean destroy) {
   ToolItem[] items = getItems();
   for (int i = 0; i < items.length; i++) {
     ToolItem item = items[i];
     if (item != null && !item.isDisposed()) {
       item.release(false);
     }
   }
   super.releaseChildren(destroy);
 }
示例#3
0
 /*public*/ void setTabItemList(ToolItem[] tabList) {
   checkWidget();
   if (tabList != null) {
     for (int i = 0; i < tabList.length; i++) {
       ToolItem item = tabList[i];
       if (item == null) error(SWT.ERROR_INVALID_ARGUMENT);
       if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
       if (item.parent != this) error(SWT.ERROR_INVALID_PARENT);
     }
     ToolItem[] newList = new ToolItem[tabList.length];
     System.arraycopy(tabList, 0, newList, 0, tabList.length);
     tabList = newList;
   }
   this.tabItemList = tabList;
 }
 private void disposeToolItems() {
   for (int i = 0; i < toolItemList.size(); i++) {
     ToolItem item = (ToolItem) toolItemList.get(i);
     if (!item.isDisposed()) {
       Object data = item.getData();
       if (data != null && data instanceof Menu) {
         Menu menu = (Menu) data;
         if (!menu.isDisposed()) {
           menu.dispose();
         }
       }
       item.dispose();
     }
   }
 }
示例#5
0
 private void setCancelEnabled(boolean enabled) {
   if (fStopButton != null && !fStopButton.isDisposed()) {
     fStopButton.setEnabled(enabled);
     if (enabled) fToolBar.setFocus();
   }
 }
示例#6
0
 public void menuHidden(final MenuEvent e) {
   if (e.getSource() == menu && !toolItem.isDisposed()) {
     toolItem.setSelection(false);
   }
 }