use of org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData in project freeplane by freeplane.
the class ScriptingConfigurationTest method testAnalyseScriptContentRemoveDuplicates.
@Test
public void testAnalyseScriptContentRemoveDuplicates() {
String content = "// some comment" + "\n// @ExecutionModes (\t{\n ExecutionMode.ON_selECTED_NODE_recursively,\n \tON_SelECTED_NODE_RECURSIVELY } )";
ScriptMetaData metaData = new ScriptingConfiguration().analyseScriptContent(content, scriptName);
assertEquals("duplicated modes should not matter", 1, metaData.getExecutionModes().size());
assertTrue("ON_SELECTED_NODE_RECURSIVELY was set", metaData.getExecutionModes().contains(ExecutionMode.ON_SELECTED_NODE_RECURSIVELY));
assertTrue("CacheScriptContent=false is the default", !metaData.cacheContent());
}
use of org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData in project freeplane by freeplane.
the class ScriptingConfigurationTest method testAnalyseScriptContentWithTitleKey.
@Test
public void testAnalyseScriptContentWithTitleKey() {
// it's case insensitive
// it's tolerant on white space
String content = //
"// some comment" + //
"\n//@ExecutionModes (\t{\n ExecutionMode.ON_selECTED_NODE=\"/menu_bar/help[icon_button_ok]\"" + //
",\n \tON_SelECTED_NODE_RECURSIVELY = \"/menu_bar/help[Test_Script]\" } )" + "\n def test() {}\n";
ScriptMetaData metaData = new ScriptingConfiguration().analyseScriptContent(content, scriptName);
assertEquals("expected only modes set in the script", 2, metaData.getExecutionModes().size());
assertTrue("ON_SELECTED_NODE was set", metaData.getExecutionModes().contains(ExecutionMode.ON_SELECTED_NODE));
assertEquals("wrong menu location", "/menu_bar/help", metaData.getMenuLocation(ExecutionMode.ON_SELECTED_NODE));
assertEquals("wrong title key", "icon_button_ok", metaData.getTitleKey(ExecutionMode.ON_SELECTED_NODE));
assertTrue("ON_SELECTED_NODE_RECURSIVELY was set", metaData.getExecutionModes().contains(ExecutionMode.ON_SELECTED_NODE_RECURSIVELY));
assertEquals("wrong menu location", "/menu_bar/help", metaData.getMenuLocation(ExecutionMode.ON_SELECTED_NODE_RECURSIVELY));
assertEquals("wrong title key", "Test_Script", metaData.getTitleKey(ExecutionMode.ON_SELECTED_NODE_RECURSIVELY));
}
use of org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData in project freeplane by freeplane.
the class ScriptingMenuEntryVisitor method createEntry.
private Entry createEntry(final String scriptName, final String scriptPath, ExecutionMode executionMode) {
final ScriptMetaData metaData = configuration.getMenuTitleToMetaDataMap().get(scriptName);
final String title = scriptNameToMenuItemTitle(scriptName);
return createEntry(createAction(scriptName, scriptPath, executionMode, metaData, title));
}
use of org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData 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());
}
}
use of org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData in project freeplane by freeplane.
the class ScriptingConfigurationTest method testParseExecutionModes.
@Test
public void testParseExecutionModes() throws Exception {
ScriptMetaData metaData = new ScriptMetaData("test");
ScriptingConfiguration.setExecutionModes("@ExecutionModes({on_selected_node=\"/menu/bla/blupp\",on_single_node=\"/menu/hi/ho\"})", metaData);
ScriptingConfiguration.setExecutionModes("@ExecutionModes({on_selected_node=\"/menu/bla/blupp\"on_single_node=\"/menu/hi/ho\"})", metaData);
ScriptingConfiguration.setExecutionModes("@ExecutionModes({on_single_node=\"/menu/hi/ho\"})", metaData);
ScriptingConfiguration.setExecutionModes("@ExecutionModes({on_single_node})", metaData);
ScriptingConfiguration.setExecutionModes("@ExecutionModes({\"/menu/hi/ho\"})", metaData);
ScriptingConfiguration.setExecutionModes("@ExecutionModes({})", metaData);
}
Aggregations