Search in sources :

Example 1 with ExecutionMode

use of org.freeplane.plugin.script.ExecuteScriptAction.ExecutionMode in project freeplane by freeplane.

the class ScriptingMenuEntryVisitor method addEntryForGivenLocation.

private void addEntryForGivenLocation(Entry rootEntry, final ScriptMetaData metaData, String scriptPath) {
    for (final ExecutionMode executionMode : metaData.getExecutionModes()) {
        final String location = metaData.getMenuLocation(executionMode);
        if (registeredLocations.add(location + "/" + metaData.getScriptName())) {
            Entry parentEntry = findOrCreateEntry(rootEntry, location);
            if (parentEntry == null)
                throw new RuntimeException("internal error: cannot add entry for " + location);
            Entry entry = createEntry(metaData.getScriptName(), scriptPath, executionMode);
            parentEntry.addChild(entry);
            ;
        }
    }
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) ExecutionMode(org.freeplane.plugin.script.ExecuteScriptAction.ExecutionMode)

Example 2 with ExecutionMode

use of org.freeplane.plugin.script.ExecuteScriptAction.ExecutionMode in project freeplane by freeplane.

the class ScriptingMenuEntryVisitor method visit.

/**
 * builds menu entries for scripts without a special menu location.
 */
@Override
public void visit(Entry target) {
    initEntryNavigator(target);
    for (final Map.Entry<String, String> entry : configuration.getMenuTitleToPathMap().entrySet()) {
        String scriptName = entry.getKey();
        final ScriptMetaData metaData = configuration.getMenuTitleToMetaDataMap().get(scriptName);
        if (!metaData.hasMenuLocation()) {
            for (final ExecutionMode executionMode : metaData.getExecutionModes()) {
                target.addChild(createEntry(scriptName, entry.getValue(), executionMode));
            }
        }
    // else: see buildPhaseFinished
    }
    if (target.isLeaf()) {
        target.addChild(createNoScriptsAvailableAction());
    }
}
Also used : ScriptMetaData(org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData) ExecutionMode(org.freeplane.plugin.script.ExecuteScriptAction.ExecutionMode) Map(java.util.Map)

Example 3 with ExecutionMode

use of org.freeplane.plugin.script.ExecuteScriptAction.ExecutionMode in project freeplane by freeplane.

the class ScriptingMenuContributor method registerScript.

private void registerScript(final String scriptName, final String scriptPath) {
    final ScriptMetaData metaData = configuration.getMenuTitleToMetaDataMap().get(scriptName);
    for (final ExecutionMode executionMode : metaData.getExecutionModes()) {
        final String location = getLocation(scriptName, metaData, executionMode);
        addSubMenu(parentLocation(location), location, getMenuTitle(metaData, executionMode));
        addMenuItem(location, scriptName, scriptPath, executionMode, metaData);
    }
}
Also used : ScriptMetaData(org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData) ExecutionMode(org.freeplane.plugin.script.ExecuteScriptAction.ExecutionMode)

Aggregations

ExecutionMode (org.freeplane.plugin.script.ExecuteScriptAction.ExecutionMode)3 ScriptMetaData (org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData)2 Map (java.util.Map)1 Entry (org.freeplane.core.ui.menubuilders.generic.Entry)1