Example #1
0
  /** Read command descriptors from extension points. */
  private void initializeCreationCommandDescriptors() {

    creationCommandDescriptors = new HashMap<Object, CreationCommandDescriptor>();
    // Reading data from plugins
    IConfigurationElement[] configElements =
        Platform.getExtensionRegistry()
            .getConfigurationElementsFor(extensionPointNamespace, EDITOR_EXTENSION_ID);

    CreationCommandExtensionFactory extensionReader = new CreationCommandExtensionFactory();

    for (IConfigurationElement ele : configElements) {
      CreationCommandDescriptor desc;
      try {
        if (CreationCommandExtensionFactory.CREATION_COMMAND_EXTENSIONPOINT.equals(ele.getName())) {
          desc = extensionReader.createCreationCommand(ele);
          creationCommandDescriptors.put(desc.commandId, desc);
        }
      } catch (ExtensionException e) {
        Activator.getDefault()
            .getLog()
            .log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage(), e));
        PapyrusTrace.error(
            IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING,
            this,
            "Initialization creation command problem " + e);
      }
    }
    PapyrusTrace.trace(
        IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING,
        this,
        "" + creationCommandDescriptors.size() + " creationCommands loaded");
  }
  /**
   * Deletes a local palette definition
   *
   * @param id the id of the palette to delete
   */
  public static void deleteLocalPalette(String id) {
    // retrieves memento
    XMLMemento rootMemento = getExistingLocalPalettes();

    // search existing customization
    IMemento paletteMemento = searchPaletteMemento(rootMemento, id);

    if (paletteMemento == null) {
      PapyrusTrace.log(IStatus.WARNING, "impossible to find the palette with id: " + id);
      return;
    }

    // no remove method...
    // so, creation of a new root memento, then, duplicate all entries
    // except the one to
    // delete...

    XMLMemento newRootMemento = XMLMemento.createWriteRoot(PALETTE_LOCAL_DEFINITIONS);
    for (IMemento memento : rootMemento.getChildren(PALETTE)) {
      if (!memento.getString(ID).equals(paletteMemento.getString(ID))) {
        IMemento newChild = newRootMemento.createChild(PALETTE);
        newChild.putMemento(memento);
      }
    }
    // save new Memento
    saveLocalPalettes(newRootMemento);
  }