/*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.action.ContributionItem#update(java.lang.String)
   */
  public void update(String id) {
    if (widget != null) {
      if (widget instanceof MenuItem) {
        MenuItem item = (MenuItem) widget;

        String text = label;
        if (text == null) {
          if (command != null) {
            try {
              text = command.getCommand().getName();
            } catch (NotDefinedException e) {
              WorkbenchPlugin.log(
                  "Update item failed " //$NON-NLS-1$
                      + getId(),
                  e);
            }
          }
        }
        // TODO: [bm] key bindings
        //				text = updateMnemonic(text);
        //
        //				String keyBindingText = null;
        //				if (command != null) {
        //					TriggerSequence[] bindings = bindingService
        //							.getActiveBindingsFor(command);
        //					if (bindings.length > 0) {
        //						keyBindingText = bindings[0].format();
        //					}
        //				}
        //				if (text != null) {
        //					if (keyBindingText == null) {
        item.setText(text);
        //					} else {
        //						item.setText(text + '\t' + keyBindingText);
        //					}
        //				}

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

        boolean shouldBeEnabled = isEnabled();
        if (item.getEnabled() != shouldBeEnabled) {
          item.setEnabled(shouldBeEnabled);
        }
      } else if (widget instanceof ToolItem) {
        ToolItem item = (ToolItem) widget;

        if (icon != null) {
          updateIcons();
        } else if (label != null) {
          item.setText(label);
        }

        if (tooltip != null) item.setToolTipText(tooltip);
        else {
          String text = label;
          if (text == null) {
            if (command != null) {
              try {
                text = command.getCommand().getName();
              } catch (NotDefinedException e) {
                WorkbenchPlugin.log(
                    "Update item failed " //$NON-NLS-1$
                        + getId(),
                    e);
              }
            }
          }
          if (text != null) {
            item.setToolTipText(text);
          }
        }

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

        boolean shouldBeEnabled = isEnabled();
        if (item.getEnabled() != shouldBeEnabled) {
          item.setEnabled(shouldBeEnabled);
        }
      }
    }
  }