Search in sources :

Example 1 with IScriptStarter

use of org.freeplane.features.script.IScriptStarter in project freeplane by freeplane.

the class ReminderHook method runScript.

public void runScript(ReminderExtension reminderExtension) {
    final String script = reminderExtension.getScript();
    if (script == null || script.equals(""))
        return;
    final IScriptStarter starter = (IScriptStarter) modeController.getExtension(IScriptStarter.class);
    if (starter == null)
        return;
    final NodeModel node = reminderExtension.getNode();
    final MapModel map = node.getMap();
    final Controller controller = modeController.getController();
    if (!controller.getMapViewManager().getMaps(modeController.getModeName()).containsValue(map))
        return;
    starter.executeScript(node, script);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IScriptStarter(org.freeplane.features.script.IScriptStarter) MapModel(org.freeplane.features.map.MapModel) ResourceController(org.freeplane.core.resources.ResourceController) FilterController(org.freeplane.features.filter.FilterController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) ModeController(org.freeplane.features.mode.ModeController)

Example 2 with IScriptStarter

use of org.freeplane.features.script.IScriptStarter in project freeplane by freeplane.

the class ScriptingRegistration method register.

private void register(ModeController modeController) {
    modeController.addExtension(IScriptEditorStarter.class, new IScriptEditorStarter() {

        @Override
        public String startEditor(final String pScriptInput) {
            final ScriptModel scriptModel = new ScriptModel(pScriptInput);
            final ScriptEditorPanel scriptEditorPanel = new ScriptEditorPanel(scriptModel, false);
            scriptEditorPanel.setVisible(true);
            return scriptModel.getScript();
        }

        @Override
        public ComboBoxEditor createComboBoxEditor(Dimension minimumSize) {
            final ScriptComboBoxEditor scriptComboBoxEditor = new ScriptComboBoxEditor();
            if (minimumSize != null)
                scriptComboBoxEditor.setMinimumSize(minimumSize);
            return scriptComboBoxEditor;
        }
    });
    modeController.addExtension(IScriptStarter.class, new IScriptStarter() {

        @Override
        public void executeScript(NodeModel node, String script) {
            ScriptingEngine.executeScript(node, script);
        }
    });
    registerScriptAddOns();
    if (!modeController.getController().getViewController().isHeadless()) {
        registerGuiStuff(modeController);
        ScriptCompiler.compileScriptsOnPath(ScriptResources.getClasspath());
        createUserScriptsDirectory();
        createInitScriptsDirectory();
        createUserLibDirectory();
    }
    FilterController.getCurrentFilterController().getConditionFactory().addConditionController(100, new ScriptConditionController());
    ScriptingPolicy.installRestrictingPolicy();
    System.setSecurityManager(new InternationalizedSecurityManager());
}
Also used : IScriptModel(org.freeplane.plugin.script.ScriptEditorPanel.IScriptModel) NodeModel(org.freeplane.features.map.NodeModel) ScriptConditionController(org.freeplane.plugin.script.filter.ScriptConditionController) IScriptEditorStarter(org.freeplane.features.script.IScriptEditorStarter) Dimension(java.awt.Dimension) IScriptStarter(org.freeplane.features.script.IScriptStarter) ComboBoxEditor(javax.swing.ComboBoxEditor)

Aggregations

NodeModel (org.freeplane.features.map.NodeModel)2 IScriptStarter (org.freeplane.features.script.IScriptStarter)2 Dimension (java.awt.Dimension)1 ComboBoxEditor (javax.swing.ComboBoxEditor)1 ResourceController (org.freeplane.core.resources.ResourceController)1 FilterController (org.freeplane.features.filter.FilterController)1 IconController (org.freeplane.features.icon.IconController)1 MapModel (org.freeplane.features.map.MapModel)1 Controller (org.freeplane.features.mode.Controller)1 ModeController (org.freeplane.features.mode.ModeController)1 IScriptEditorStarter (org.freeplane.features.script.IScriptEditorStarter)1 TextController (org.freeplane.features.text.TextController)1 IScriptModel (org.freeplane.plugin.script.ScriptEditorPanel.IScriptModel)1 ScriptConditionController (org.freeplane.plugin.script.filter.ScriptConditionController)1