예제 #1
0
    /**
     * Execute the change request by retrieving the icon description or EditorIcon of the single
     * entity in the container given in the constructor and copying it to the entity given in the
     * constructor.
     *
     * @exception Exception If the icon cannot be retrieved, or it cannot be associated with the
     *     entity.
     */
    protected void _execute() throws Exception {
      ComponentEntity actor;
      try {
        _container.workspace().getReadAccess();
        actor = (ComponentEntity) _container.entityList().get(0);
      } finally {
        _container.workspace().doneReading();
      }

      if (!_removeEditorIcons(_entity)) {
        return;
      }

      ConfigurableAttribute actorAttribute =
          (ConfigurableAttribute) actor.getAttribute("_iconDescription");
      String iconDescription = actorAttribute.getConfigureText();
      _setIconDescription(_entity, iconDescription);

      try {
        actor.workspace().getReadAccess();
        List<?> editorIconList = actor.attributeList(EditorIcon.class);
        for (Object editorIconObject : editorIconList) {
          EditorIcon editorIcon = (EditorIcon) editorIconObject;
          EditorIcon icon = (EditorIcon) editorIcon.clone(((NamedObj) _entity).workspace());
          icon.setName("_icon");
          EditorIcon oldIcon = (EditorIcon) ((NamedObj) _entity).getAttribute("_icon");
          if (oldIcon != null) {
            oldIcon.setContainer(null);
          }
          icon.setContainer((NamedObj) _entity);
          icon.setPersistent(false);
          break;
        }
      } finally {
        actor.workspace().doneReading();
      }
    }
예제 #2
0
 /**
  * Remove the EditorIcons defined for the entity.
  *
  * @param entity The entity.
  * @return true if at least one EditorIcon is found and removed; false otherwise.
  * @exception KernelException If error occurs while removing the EditorIcons.
  */
 private static boolean _removeEditorIcons(GTEntity entity) throws KernelException {
   NamedObj object = (NamedObj) entity;
   boolean foundPersistentIcon = false;
   try {
     object.workspace().getReadAccess();
     for (Object iconObject : object.attributeList(EditorIcon.class)) {
       EditorIcon icon = (EditorIcon) iconObject;
       if (icon.isPersistent()) {
         foundPersistentIcon = true;
       } else {
         icon.setContainer(null);
       }
     }
   } finally {
     object.workspace().doneReading();
   }
   return !foundPersistentIcon;
 }