Package org.java.plugin

Examples of org.java.plugin.PluginManager


        Logger log = Logger.getLogger(PluginCore.class.getName());

        ObjectFactory objectFactory = ObjectFactory.newInstance();

        PluginManager result = objectFactory.createManager();

       
        /*
         * Now find plug-ins! Check directories and jar.
         */
        try {
            DefaultPluginsCollector collector = new DefaultPluginsCollector();
            ExtendedProperties ep = new ExtendedProperties();


            List<File> directoriesToSearch = new LinkedList<File>();
            directoriesToSearch.add(new File("./src/plugins"));
            directoriesToSearch.add(new File("./plugins"));
            directoriesToSearch.add(userPluginDir);

            try {
                File parent = new File(PluginCore.class.getProtectionDomain()
                    .getCodeSource().getLocation().toURI()).getParentFile();
           
                if (!parent.getCanonicalFile().equals(
                    new File(".").getCanonicalFile())) {
                    directoriesToSearch.add(new File(parent, "/src/plugins"));
                    directoriesToSearch.add(new File(parent, "/plugins"));
                }
            } catch (Exception e) {
                // no problem, we just use paths relative to current dir.
            }

            StringBuilder sb = new StringBuilder();
            for (File directory : directoriesToSearch) {
                // We don't want warnings if the default plug-in paths don't
                // exist, we do that below
                if (directory.exists()) {
                    if (sb.length() > 0)
                        sb.append(',');
                    sb.append(directory.getPath());
                }
            }

            ep.setProperty("org.java.plugin.boot.pluginsRepositories", sb
                .toString());
            collector.configure(ep);

            Collection<PluginLocation> plugins = collector
                .collectPluginLocations();

            /**
             * I know the following is really, really ugly, but I have found no
             * way to automatically discover multiple plugin.xmls in JARs
             */
            String[] jarLocationsToSearch = new String[] {
                "/plugins/net.sf.jabref.core/",
                "/plugins/net.sf.jabref.export.misq/"};
               
            // Collection locations
            for (String jarLocation : jarLocationsToSearch) {
                PluginLocation location = getLocationInsideJar(jarLocation,
                    "plugin.xml");
                if (location != null)
                    plugins.add(location);
            }

            if (plugins.size() <= 0) {
                log
                    .warning(Globals
                        .lang("No plugins were found in the following folders:") +
                        "\n  " +
                        Util.join(directoriesToSearch
                            .toArray(new String[directoriesToSearch.size()]),
                            "\n  ", 0, directoriesToSearch.size()) +
                        "\n" +
                        Globals.lang("and inside the JabRef-jar:") +
                        "\n  " +
                        Util.join(jarLocationsToSearch, "\n  ", 0,
                            jarLocationsToSearch.length) +
                        "\n" +
                        Globals
                            .lang("At least the plug-in 'net.sf.jabref.core' should be there."));
            } else {
                result.publishPlugins(plugins.toArray(new PluginLocation[] {}));

                Collection<PluginDescriptor> descs = result.getRegistry()
                    .getPluginDescriptors();

                sb = new StringBuilder();
                sb.append(Globals.lang("Found %0 plugin(s)", String
                    .valueOf(descs.size())) +
                    ":\n");

                for (PluginDescriptor p : result.getRegistry()
                    .getPluginDescriptors()) {
                    sb.append("  - ").append(p.getId()).append(" (").append(
                        p.getLocation()).append(")\n");
                }
                log.info(sb.toString());
View Full Code Here


   * Initalizes the plugin.
   * @param networkView the network view displaying the loaded map
   * @author Jonas Truemper
   */
  public void init(GraphController networkView) {
    PluginManager pManager = PluginManager.lookup(this);
    EventsPlugin plugin = null;
    try {
      plugin = (EventsPlugin) pManager.getPlugin(EventsPlugin.PLUGIN_ID);
    } catch (PluginLifecycleException e) {
      Logger.getLogger(this.getClass()).error("Error while initializing EventDock event handler", e);
    }
   
    plugin.initializeEventHandling(networkView);
View Full Code Here

    /**
     * @author Jonas Truemper
     * adds a callback to the menu item
     */
    public void init(JMenu menu, MainWindow mainWindow) {
      PluginManager pManager = PluginManager.lookup(this);
      TLSEditorPlugin plugin = null;
      try {
        plugin = (TLSEditorPlugin) pManager.getPlugin(TLSEditorPlugin.PLUGIN_ID);
      } catch (PluginLifecycleException e) {
        Logger log = Logger.getLogger(this.getClass());
        log.error("Error while initializing TLS Editor GUI support.", e);
      }
      plugin.initMenu(menu);
View Full Code Here

* OpenStreetMap.org specific data importer. extends de.hpi.eworld.importer as plugin
*/
public class OsmFileImportProvider implements ImportProviderInterface {

  public void init(JMenu menu) {
    PluginManager pManager = PluginManager.lookup(this);
    OsmFileImportPlugin plugin = null;
    try {
      plugin = (OsmFileImportPlugin) pManager.getPlugin(OsmFileImportPlugin.PLUGIN_ID);
    } catch (PluginLifecycleException e) {
      Logger log = Logger.getLogger(this.getClass());
      log.error("Error while initializing Osm File Import GUI support.", e);
    }
   
View Full Code Here

   * Initalizes the plugin.
   * @param networkView the network view displaying the loaded map
   * @author Jonas Truemper
   */
  public void init(GraphController networkView) {
    PluginManager pManager = PluginManager.lookup(this);
    MiniMapPlugin plugin = null;
    try {
      plugin = (MiniMapPlugin) pManager.getPlugin(MiniMapPlugin.PLUGIN_ID);
    } catch (PluginLifecycleException e) {
      Logger log = Logger.getLogger(this.getClass());
      log.error("Error while initializing MiniMapDock event handler", e);
    }
   
View Full Code Here

   * Initializes the event handler of the scenario plugin.
   * @param networkView The network view instance to receive events from.
   */
  @Override
  public void init(GraphController networkView) {
    PluginManager pManager = PluginManager.lookup(this);

    try {
      ScenarioAreasPlugin plugin =
        (ScenarioAreasPlugin) pManager.getPlugin(ScenarioAreasPlugin.PLUGIN_ID);
      plugin.initializeEventHandling(networkView);
    } catch (PluginLifecycleException e) {
      log.error("Error while initializing Scenarios event handler", e);
    }
  }
View Full Code Here

   * @author Florian Thomas, Nico Naumann
   * Initializes the editor menu in the main applications menu bar
   */
  public void init(JMenu menuBar) {
    try {
      PluginManager manager = PluginManager.lookup(this);
      EditorPlugin plugin = (EditorPlugin) manager
          .getPlugin(EditorPlugin.PLUGIN_ID);
      menuBar.setText("Edit");
      menuBar.setMnemonic('E');
      plugin.setMenu(menuBar);
      plugin.initializeEditorPlugins();
View Full Code Here

*/
public class GUIProvider implements EventHandlerProviderInterface {

  @Override
  public void init(GraphController networkView) {
    PluginManager pm = PluginManager.lookup(this);
    SumoExportProvider sumoPlugin;
    try {
      sumoPlugin = (SumoExportProvider) pm.getPlugin(SumoExportProvider.PLUGIN_ID);
      sumoPlugin.setNetworkViewWindow(networkView);
    } catch (PluginLifecycleException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

*/
public class EventHandlerProvider implements EventHandlerProviderInterface {

  public void init(GraphController networkView) {

    PluginManager pManager = PluginManager.lookup(this);
    TimelinePlugin plugin = null;
    try {
      plugin = (TimelinePlugin) pManager.getPlugin(TimelinePlugin.PLUGIN_ID);
    } catch (PluginLifecycleException e) {
      Logger log = Logger.getLogger(this.getClass());
      log.error("Error while initializing Timeline event handler", e);
    }
   
View Full Code Here

public class VisualizerProvider implements VisualizerPluginProviderInterface {

  @Override
  public void init(JMenu topMenuElement, MainWindow mainWindow) {
    PluginManager pManager = PluginManager.lookup(this);
    @SuppressWarnings("unused")
    VisualizerPlugin plugin = null;
    try {
      plugin = (VisualizerPlugin) pManager.getPlugin(VisualizerPlugin.PLUGIN_ID);
    } catch (PluginLifecycleException e) {
      Logger log = Logger.getLogger(this.getClass());
      log.error("Error while initializing the visualizer plugin.", e);
    }
  }
View Full Code Here

TOP

Related Classes of org.java.plugin.PluginManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.