Package org.freeplane.plugin.script.ScriptingConfiguration

Examples of org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData


        return new JCommandMenuButton(noScriptsAvailableMessage(), null);
    }

    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;
    }
View Full Code Here


            }
        }
    }

    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);
        }
    }
View Full Code Here

    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());
  }
View Full Code Here

    // 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));
  }
View Full Code Here

  @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());
  }
View Full Code Here

  @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
  }
View Full Code Here

    // assert that duplicate entries do no harm
  }

  @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);
View Full Code Here

TOP

Related Classes of org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.