Search in sources :

Example 1 with ScriptAddOnProperties

use of org.freeplane.plugin.script.addons.ScriptAddOnProperties in project freeplane by freeplane.

the class ScriptingConfiguration method createAddOnScriptMap.

private Map<File, Script> createAddOnScriptMap() {
    Map<File, Script> result = new LinkedHashMap<File, Script>();
    for (ScriptAddOnProperties scriptAddOnProperties : getInstalledScriptAddOns()) {
        final List<Script> scripts = scriptAddOnProperties.getScripts();
        for (Script script : scripts) {
            script.active = scriptAddOnProperties.isActive();
            result.put(findScriptFile(scriptAddOnProperties, script), script);
        }
    }
    return result;
}
Also used : Script(org.freeplane.plugin.script.addons.ScriptAddOnProperties.Script) ScriptAddOnProperties(org.freeplane.plugin.script.addons.ScriptAddOnProperties) File(java.io.File) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with ScriptAddOnProperties

use of org.freeplane.plugin.script.addons.ScriptAddOnProperties in project freeplane by freeplane.

the class ScriptingRegistration method registerScriptAddOns.

private void registerScriptAddOns() {
    File[] addonXmlFiles = AddOnsController.getController().getAddOnsDir().listFiles(new FilenameFilter() {

        @Override
        public boolean accept(File dir, String name) {
            return name.endsWith(".script.xml");
        }
    });
    final IXMLParser parser = XMLLocalParserFactory.createLocalXMLParser();
    for (File file : addonXmlFiles) {
        BufferedInputStream inputStream = null;
        try {
            inputStream = new BufferedInputStream(new FileInputStream(file));
            final IXMLReader reader = new StdXMLReader(inputStream);
            parser.setReader(reader);
            final ScriptAddOnProperties addOn = new ScriptAddOnProperties((XMLElement) parser.parse());
            addOn.setAddOnPropertiesFile(file);
            AddOnsController.getController().registerInstalledAddOn(addOn);
        } catch (final Exception e) {
            LogUtils.warn("error parsing " + file, e);
        } finally {
            FileUtils.silentlyClose(inputStream);
        }
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) ScriptAddOnProperties(org.freeplane.plugin.script.addons.ScriptAddOnProperties) IXMLReader(org.freeplane.n3.nanoxml.IXMLReader) BufferedInputStream(java.io.BufferedInputStream) IXMLParser(org.freeplane.n3.nanoxml.IXMLParser) StdXMLReader(org.freeplane.n3.nanoxml.StdXMLReader) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 3 with ScriptAddOnProperties

use of org.freeplane.plugin.script.addons.ScriptAddOnProperties in project freeplane by freeplane.

the class ScriptingConfiguration method addClasspathForAddOns.

private void addClasspathForAddOns(final ArrayList<String> classpath) {
    final List<ScriptAddOnProperties> installedScriptAddOns = getInstalledScriptAddOns();
    for (ScriptAddOnProperties scriptAddOnProperties : installedScriptAddOns) {
        final List<String> lib = scriptAddOnProperties.getLib();
        if (lib != null) {
            for (String libEntry : lib) {
                final File dir = new File(getPrivateAddOnDirectory(scriptAddOnProperties), "lib");
                classpath.add(new File(dir, libEntry).getAbsolutePath());
            }
        }
    }
}
Also used : ScriptAddOnProperties(org.freeplane.plugin.script.addons.ScriptAddOnProperties) File(java.io.File)

Aggregations

File (java.io.File)3 ScriptAddOnProperties (org.freeplane.plugin.script.addons.ScriptAddOnProperties)3 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 FilenameFilter (java.io.FilenameFilter)1 LinkedHashMap (java.util.LinkedHashMap)1 IXMLParser (org.freeplane.n3.nanoxml.IXMLParser)1 IXMLReader (org.freeplane.n3.nanoxml.IXMLReader)1 StdXMLReader (org.freeplane.n3.nanoxml.StdXMLReader)1 Script (org.freeplane.plugin.script.addons.ScriptAddOnProperties.Script)1