コード例 #1
0
 public void propertyChange(PropertyChangeEvent evt) {
   String propertyName = evt.getPropertyName();
   if (Presentation.PROP_TEXT.equals(propertyName)) {
     setText((String) evt.getNewValue());
     updateButtonSize();
   } else if (Presentation.PROP_DESCRIPTION.equals(propertyName)) {
     updateTooltipText((String) evt.getNewValue());
   } else if (Presentation.PROP_ICON.equals(propertyName)) {
     setIcon((Icon) evt.getNewValue());
     updateButtonSize();
   } else if (Presentation.PROP_ENABLED.equals(propertyName)) {
     setEnabled(((Boolean) evt.getNewValue()).booleanValue());
   }
 }
コード例 #2
0
    @Override
    public void propertyChange(PropertyChangeEvent e) {
      boolean queueForDispose = getParent() == null;

      String name = e.getPropertyName();
      if (mySynchronized.contains(name)) return;

      mySynchronized.add(name);

      try {
        if (Presentation.PROP_VISIBLE.equals(name)) {
          final boolean visible = myPresentation.isVisible();
          if (!visible && SystemInfo.isMacSystemMenu && myPlace.equals(ActionPlaces.MAIN_MENU)) {
            setEnabled(false);
          } else {
            setVisible(visible);
          }
        } else if (Presentation.PROP_ENABLED.equals(name)) {
          setEnabled(myPresentation.isEnabled());
          updateIcon(myAction.getAction());
        } else if (Presentation.PROP_MNEMONIC_KEY.equals(name)) {
          setMnemonic(myPresentation.getMnemonic());
        } else if (Presentation.PROP_MNEMONIC_INDEX.equals(name)) {
          setDisplayedMnemonicIndex(myPresentation.getDisplayedMnemonicIndex());
        } else if (Presentation.PROP_TEXT.equals(name)) {
          setText(myPresentation.getText());
        } else if (Presentation.PROP_ICON.equals(name)
            || Presentation.PROP_DISABLED_ICON.equals(name)
            || SELECTED.equals(name)) {
          updateIcon(myAction.getAction());
        }
      } finally {
        mySynchronized.remove(name);
        if (queueForDispose) {
          // later since we cannot remove property listeners inside event processing
          //noinspection SSBasedInspection
          SwingUtilities.invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  if (getParent() == null) {
                    uninstallSynchronizer();
                  }
                }
              });
        }
      }
    }