コード例 #1
0
  /**
   * Method to return an array list containing plugins of a certain editor type and category
   *
   * @param editorType The editor type
   * @param category The category
   * @return An array list of any plugins found
   */
  public ArrayList<ATPlugin> getEmbeddedEditorPlugins(String editorType, String category) {
    ArrayList<ATPlugin> foundPlugins = new ArrayList<ATPlugin>();

    try {
      Iterator it = pluginManager.getRegistry().getPluginDescriptors().iterator();

      while (it.hasNext()) {
        PluginDescriptor pluginDescriptor = (PluginDescriptor) it.next();
        String id = pluginDescriptor.getId();
        ATPlugin plugin = (org.archiviststoolkit.plugin.ATPlugin) pluginManager.getPlugin(id);

        String cat = plugin.getCategory();
        String et = plugin.getEditorType();

        // check to make sure that the plugin is of the right category and
        // editor type and that it has a panel that can be embedded into
        // the resource editor panel
        if (cat.indexOf(category) != -1
            && et.indexOf(editorType) != -1
            && plugin.getEmbeddedPanels() != null) {
          foundPlugins.add(plugin);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return foundPlugins;
  }
コード例 #2
0
 /** Method set the model for any plugins loaded */
 private void setPluginModel() {
   if (plugins != null) {
     for (ATPlugin plugin : plugins) {
       plugin.setModel(getModel(), null);
     }
   }
 }
コード例 #3
0
  /**
   * Method to return the ATPlugin for a particular and domain object
   *
   * @param domainObject The domain object to find a plugin for
   * @param category The category to find a domain object for
   * @return The plugin found or null if none can be located.
   */
  private ATPlugin getATPlugin(DomainObject domainObject, String category) {
    String editorType = getEditorTypeForDomainObject(domainObject);

    if (editorType != null) {
      ATPlugin foundPlugin = null;

      try {
        Iterator it = pluginManager.getRegistry().getPluginDescriptors().iterator();

        while (it.hasNext()) {
          PluginDescriptor pluginDescriptor = (PluginDescriptor) it.next();
          String id = pluginDescriptor.getId();
          ATPlugin plugin = (org.archiviststoolkit.plugin.ATPlugin) pluginManager.getPlugin(id);

          String cat = plugin.getCategory();
          String et = plugin.getEditorType();

          if (cat.indexOf(category) != -1 && et.indexOf(editorType) != -1) {
            foundPlugin = plugin;
            break;
          }
        }
      } catch (Exception e) {
        e.printStackTrace();
      }

      return foundPlugin;
    } else {
      return null;
    }
  }
コード例 #4
0
  /**
   * Method to return the name of all plugins in a particular category. It is used to add plugins to
   * plugin menu in the main application frame
   *
   * @return HashMap containing the names and ids of all the plugins found
   */
  public HashMap getPluginNamesByCategory(String inCategory) {
    HashMap<String, String> pluginNames = new HashMap<String, String>();

    try {
      Iterator it = pluginManager.getRegistry().getPluginDescriptors().iterator();

      while (it.hasNext()) {
        PluginDescriptor pluginDescriptor = (PluginDescriptor) it.next();
        String id = pluginDescriptor.getId();
        ATPlugin plugin = (org.archiviststoolkit.plugin.ATPlugin) pluginManager.getPlugin(id);
        String name = plugin.getName();
        String category = plugin.getCategory();
        if (category.indexOf(inCategory) != -1) {
          if (plugin.getTaskList() == null) { // no list of task so just return the id and name
            pluginNames.put(id, name);
          } else { // list of task so return the name::task1::task2::task3 etc ...
            String nameWithTask = getNameWithTask(name, plugin.getTaskList());
            pluginNames.put(id, nameWithTask);
          }
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (pluginNames.size() == 0) {
      return null; // no plugins in this category so return null
    } else {
      return pluginNames;
    }
  }
コード例 #5
0
 /** Method that initializes any embedded plugins that would add an editor */
 private void initPlugins() {
   plugins = ATPluginFactory.getInstance().getEmbeddedNameEditorPlugins();
   if (plugins != null) {
     for (ATPlugin plugin : plugins) {
       plugin.setEditorField(this);
       HashMap pluginPanels = plugin.getEmbeddedPanels();
       for (Object key : pluginPanels.keySet()) {
         String panelName = (String) key;
         JPanel pluginPanel = (JPanel) pluginPanels.get(key);
         tabbedPane.addTab(panelName, pluginPanel);
       }
     }
   }
 }
  /**
   * Method to load a custom plugin domain editor for viewing the record. Usefull if someone want to
   * implemment an editor that is more suited for their workflow or to load a read only viewer for
   * the record.
   *
   * @param domainObject The record to edit
   * @return Whether any plugin editors where found
   */
  protected boolean usePluginDomainEditor(
      boolean newInstance, DomainObject domainObject, DomainSortableTable callingTable) {
    ATPlugin plugin = ATPluginFactory.getInstance().getEditorPlugin(domainObject);

    if (plugin == null) { // just return false and so that the built in domain object can be used
      return false;
    }

    // set the calling table and editor
    plugin.setEditorField(this);
    plugin.setCallingTable(callingTable);

    if (!newInstance) { // this means that it is a record being edited, so may have to do something
                        // special
      plugin.setModel(domainObject, null);
    } else { // its a new record to just set the model
      plugin.setModel(domainObject, null);
    }

    // set the main program application frame and display it
    plugin.setApplicationFrame(ApplicationFrame.getInstance());
    plugin.showPlugin(getParentEditor());

    return true;
  }
コード例 #7
0
  /**
   * Method to return an list of all the plugin names and ids in a hasmap
   *
   * @return HashMap containing the names and ids of all the plugins found
   */
  public HashMap getPluginNames() {
    HashMap<String, String> pluginNames = new HashMap<String, String>();

    try {
      Iterator it = pluginManager.getRegistry().getPluginDescriptors().iterator();

      while (it.hasNext()) {
        PluginDescriptor pluginDescriptor = (PluginDescriptor) it.next();
        String id = pluginDescriptor.getId();
        ATPlugin plugin = (org.archiviststoolkit.plugin.ATPlugin) pluginManager.getPlugin(id);
        String name = plugin.getName();
        pluginNames.put(id, name);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (pluginNames.size() == 0) {
      return null; // no plugins found so return null
    } else {
      return pluginNames;
    }
  }