Example #1
0
 /**
  * The constructor.
  *
  * @param hasIcon true if an icon has to be shown
  * @param key the (to be localized) name of the action
  * @param global the action is global, i.e. implements shouldBeEnabled(), and listens to Target
  *     changes
  */
 public UMLAction(String key, boolean global, boolean hasIcon) {
   super(Translator.localize(key));
   if (hasIcon) {
     iconName = key;
   }
   putValue(Action.SHORT_DESCRIPTION, Translator.localize(key));
   if (global) {
     Actions.addAction(this);
   }
   // Jaap B. 17-6-2003 added next line to make sure every action
   // is in the right enable condition on creation.
   setEnabled(shouldBeEnabled());
 }
Example #2
0
  /**
   * Gets one of this object's properties using the associated key.
   *
   * @param key the name of the property.
   * @return the value of the property.
   * @see #putValue(String, Object)
   */
  public Object getValue(String key) {
    if (iconName != null && Action.SMALL_ICON.equals(key)) {
      Icon icon = ResourceLoaderWrapper.lookupIcon(iconName);

      if (icon != null) {
        putValue(Action.SMALL_ICON, icon);
      } else {
        LOG.warn(
            "Requested icon for: "
                + getClass()
                + ". \nIcon not found: "
                + iconName
                + "\nLocalization:"
                + Translator.localize(iconName));
      }
      iconName = null;
    }
    return super.getValue(key);
  }