Exemplo n.º 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();
      }
    }