use of org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData in project freeplane by freeplane.
the class ScriptingConfigurationTest method testAnalyseScriptContentForFormula.
@Test
public void testAnalyseScriptContentForFormula() {
String content = //
"=\"blabla\"" + "\n// @CacheScriptContent ( true\t ) ";
ScriptMetaData metaData = new ScriptingConfiguration().analyseScriptContent(content, scriptName);
assertEquals("single node mode should be removed for '=' scripts", 2, metaData.getExecutionModes().size());
assertTrue("ON_SELECTED_NODE shouldn't been removed", metaData.getExecutionModes().contains(ExecutionMode.ON_SELECTED_NODE));
assertTrue("ON_SELECTED_NODE_RECURSIVELY shouldn't been removed", metaData.getExecutionModes().contains(ExecutionMode.ON_SELECTED_NODE_RECURSIVELY));
assertTrue("CacheScriptContent was set to true", metaData.cacheContent());
// assert that duplicate entries do no harm
}
use of org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData in project freeplane by freeplane.
the class ScriptingConfigurationTest method testAnalyseScriptContent1.
@Test
public void testAnalyseScriptContent1() {
// it's case insensitive
// it's tolerant on white space
String content = //
"// some comment" + //
"//@ExecutionModes (\t{ ExecutionMode.ON_selECTED_NODE" + //
", \tON_SelECTED_NODE_RECURSIVELY = \"/menu_bar/help\" } )" + //
"// @CacheScriptContent ( true\t ) " + " def test() {}";
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));
assertTrue("ON_SELECTED_NODE_RECURSIVELY was set", metaData.getExecutionModes().contains(ExecutionMode.ON_SELECTED_NODE_RECURSIVELY));
assertEquals("menu location for ON_SELECTED_NODE_RECURSIVELY was set explicitely", "/menu_bar/help", metaData.getMenuLocation(ExecutionMode.ON_SELECTED_NODE_RECURSIVELY));
assertTrue("CacheScriptContent was set to true", metaData.cacheContent());
}
use of org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData 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);
}
}
use of org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData in project freeplane by freeplane.
the class ScriptingRibbonsContributor method createScriptButton.
private JCommandMenuButton createScriptButton(final String scriptName, final String scriptPath, ExecutionMode executionMode) {
final ScriptMetaData metaData = configuration.getMenuTitleToMetaDataMap().get(scriptName);
final String title = scriptNameToMenuItemTitle(scriptName);
AFreeplaneAction action = new ExecuteScriptAction(scriptName, title, scriptPath, executionMode, metaData.cacheContent(), metaData.getPermissions());
ResizableIcon icon = ActionUtils.getActionIcon(action);
final JCommandMenuButton scriptEntry = new JCommandMenuButton(title, icon);
scriptEntry.setActionRichTooltip(createRichTooltip(title, metaData));
scriptEntry.addActionListener(action);
scriptEntry.setFocusable(false);
scriptEntry.setEnabled(metaData.getExecutionModes().contains(executionMode));
return scriptEntry;
}
Aggregations