Search in sources :

Example 1 with PluginManagerUtil

use of net.xeoh.plugins.base.util.PluginManagerUtil in project ANNIS by korpling.

the class ExportPanel method attach.

@Override
public void attach() {
    super.attach();
    this.ui = UI.getCurrent();
    if (this.ui instanceof AnnisBaseUI) {
        PluginManagerUtil util = new PluginManagerUtil(((AnnisBaseUI) getUI()).getPluginManager());
        for (ExporterPlugin e : util.getPlugins(ExporterPlugin.class)) {
            exporterClassContainer.addItem(e.getClass());
        }
    }
    exporterClassContainer.sort(new Object[] { "simpleName" }, new boolean[] { true });
    cbExporter.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    cbExporter.setItemCaptionPropertyId("simpleName");
    if (exporterClassContainer.size() > 0) {
        cbExporter.setValue(exporterClassContainer.getIdByIndex(0));
    }
}
Also used : ExporterPlugin(annis.libgui.exporter.ExporterPlugin) PluginManagerUtil(net.xeoh.plugins.base.util.PluginManagerUtil) AnnisBaseUI(annis.libgui.AnnisBaseUI)

Example 2 with PluginManagerUtil

use of net.xeoh.plugins.base.util.PluginManagerUtil in project ANNIS by korpling.

the class AnnisBaseUI method getExporter.

@Override
public ExporterPlugin getExporter(Class<? extends ExporterPlugin> clazz) {
    if (exporterRegistryCache == null) {
        exporterRegistryCache = MutableClassToInstanceMap.create();
        PluginManagerUtil util = new PluginManagerUtil(getPluginManager());
        for (ExporterPlugin e : util.getPlugins(ExporterPlugin.class)) {
            exporterRegistryCache.put(e.getClass(), e);
        }
    }
    return exporterRegistryCache.get(clazz);
}
Also used : ExporterPlugin(annis.libgui.exporter.ExporterPlugin) PluginManagerUtil(net.xeoh.plugins.base.util.PluginManagerUtil)

Example 3 with PluginManagerUtil

use of net.xeoh.plugins.base.util.PluginManagerUtil in project ANNIS by korpling.

the class AnnisBaseUI method initPlugins.

private void initPlugins() {
    log.info("Adding plugins");
    pluginManager = PluginManagerFactory.createPluginManager();
    addCustomUIPlugins(pluginManager);
    File baseDir = VaadinService.getCurrent().getBaseDirectory();
    File builtin = new File(baseDir, "WEB-INF/lib/annis-visualizers-" + VersionInfo.getReleaseName() + ".jar");
    if (builtin.canRead()) {
        pluginManager.addPluginsFrom(builtin.toURI());
        log.info("added built-in plugins from  {}", builtin.getPath());
    } else {
        log.warn("could not find built-in plugin file {}", builtin.getPath());
    }
    File basicPlugins = new File(baseDir, "WEB-INF/plugins");
    if (basicPlugins.isDirectory()) {
        pluginManager.addPluginsFrom(basicPlugins.toURI());
        log.info("added plugins from {}", basicPlugins.getPath());
    }
    String globalPlugins = System.getenv("ANNIS_PLUGINS");
    if (globalPlugins != null) {
        pluginManager.addPluginsFrom(new File(globalPlugins).toURI());
        log.info("added plugins from {}", globalPlugins);
    }
    StringBuilder listOfPlugins = new StringBuilder();
    listOfPlugins.append("loaded plugins:\n");
    PluginManagerUtil util = new PluginManagerUtil(pluginManager);
    for (Plugin p : util.getPlugins()) {
        listOfPlugins.append(p.getClass().getName()).append("\n");
    }
    log.info(listOfPlugins.toString());
    Collection<VisualizerPlugin> visualizers = util.getPlugins(VisualizerPlugin.class);
    for (VisualizerPlugin vis : visualizers) {
        visualizerRegistry.put(vis.getShortName(), vis);
        resourceAddedDate.put(vis.getShortName(), new Date());
    }
}
Also used : VisualizerPlugin(annis.libgui.visualizers.VisualizerPlugin) PluginManagerUtil(net.xeoh.plugins.base.util.PluginManagerUtil) File(java.io.File) Date(java.util.Date) ExporterPlugin(annis.libgui.exporter.ExporterPlugin) VisualizerPlugin(annis.libgui.visualizers.VisualizerPlugin) Plugin(net.xeoh.plugins.base.Plugin)

Aggregations

ExporterPlugin (annis.libgui.exporter.ExporterPlugin)3 PluginManagerUtil (net.xeoh.plugins.base.util.PluginManagerUtil)3 AnnisBaseUI (annis.libgui.AnnisBaseUI)1 VisualizerPlugin (annis.libgui.visualizers.VisualizerPlugin)1 File (java.io.File)1 Date (java.util.Date)1 Plugin (net.xeoh.plugins.base.Plugin)1