Search in sources :

Example 11 with MModeController

use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.

the class ControllerProxy method deactivateUndo.

public void deactivateUndo() {
    final MapModel map = Controller.getCurrentController().getMap();
    if (map instanceof MapModel) {
        MModeController modeController = ((MModeController) Controller.getCurrentModeController());
        modeController.deactivateUndo((MMapModel) map);
    }
}
Also used : MMapModel(org.freeplane.features.map.mindmapmode.MMapModel) MapModel(org.freeplane.features.map.MapModel) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 12 with MModeController

use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.

the class MIconController method createPreferences.

private void createPreferences() {
    final MModeController modeController = (MModeController) Controller.getCurrentModeController();
    final OptionPanelBuilder optionPanelBuilder = modeController.getOptionPanelBuilder();
    final List<AFreeplaneAction> actions = new ArrayList<AFreeplaneAction>();
    actions.addAll(iconActions.values());
    actions.add(modeController.getAction("RemoveIcon_0_Action"));
    actions.add(modeController.getAction("RemoveIconAction"));
    actions.add(modeController.getAction("RemoveAllIconsAction"));
    for (final AFreeplaneAction iconAction : actions) {
        final IIconInformation info = (IIconInformation) iconAction;
        optionPanelBuilder.addCreator("Keystrokes/icons", new IPropertyControlCreator() {

            public IPropertyControl createControl() {
                final KeyProperty keyProperty = new KeyProperty(info.getShortcutKey(), info.getTranslationValueLabel());
                keyProperty.setIcon(info.getIcon());
                keyProperty.disableModifiers();
                return keyProperty;
            }
        }, IndexedTree.AS_CHILD);
    }
}
Also used : IPropertyControlCreator(org.freeplane.core.resources.components.IPropertyControlCreator) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) OptionPanelBuilder(org.freeplane.core.resources.components.OptionPanelBuilder) ArrayList(java.util.ArrayList) IIconInformation(org.freeplane.features.icon.IIconInformation) IPropertyControl(org.freeplane.core.resources.components.IPropertyControl) KeyProperty(org.freeplane.core.resources.components.KeyProperty) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 13 with MModeController

use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.

the class ScriptingRegistration method addPropertiesToOptionPanel.

private void addPropertiesToOptionPanel() {
    final URL preferences = this.getClass().getResource("preferences.xml");
    if (preferences == null)
        throw new RuntimeException("cannot open preferences");
    Controller.getCurrentController().addOptionValidator(new IValidator() {

        @Override
        public ValidationResult validate(Properties properties) {
            final ValidationResult result = new ValidationResult();
            final String readAccessString = properties.getProperty(ScriptingPermissions.RESOURCES_EXECUTE_SCRIPTS_WITHOUT_READ_RESTRICTION);
            final String writeAccessString = properties.getProperty(ScriptingPermissions.RESOURCES_EXECUTE_SCRIPTS_WITHOUT_WRITE_RESTRICTION);
            final String classpath = properties.getProperty(ScriptResources.RESOURCES_SCRIPT_CLASSPATH);
            final boolean readAccess = readAccessString != null && Boolean.parseBoolean(readAccessString);
            final boolean writeAccess = writeAccessString != null && Boolean.parseBoolean(writeAccessString);
            final boolean classpathIsSet = classpath != null && classpath.length() > 0;
            if (classpathIsSet && !readAccess) {
                result.addError(TextUtils.getText("OptionPanel.validate_classpath_needs_readaccess"));
            }
            if (writeAccess && !readAccess) {
                result.addWarning(TextUtils.getText("OptionPanel.validate_write_without_read"));
            }
            return result;
        }
    });
    final MModeController modeController = (MModeController) Controller.getCurrentModeController();
    modeController.getOptionPanelBuilder().load(preferences);
}
Also used : IValidator(org.freeplane.core.resources.components.IValidator) Properties(java.util.Properties) ScriptAddOnProperties(org.freeplane.plugin.script.addons.ScriptAddOnProperties) URL(java.net.URL) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 14 with MModeController

use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.

the class Activator method registerMindMapModeExtension.

private void registerMindMapModeExtension(final BundleContext context) {
    final Hashtable<String, String[]> props = new Hashtable<String, String[]>();
    props.put("mode", new String[] { MModeController.MODENAME, SModeController.MODENAME });
    context.registerService(IModeControllerExtensionProvider.class.getName(), new IModeControllerExtensionProvider() {

        public void installExtension(final ModeController modeController) {
            // LattexNodeHook -> Menu insert
            final LatexNodeHook nodeHook = new LatexNodeHook();
            // 
            modeController.getExtension(TextController.class).addTextTransformer(new ConditionalContentTransformer(new LatexRenderer(), Activator.TOGGLE_PARSE_LATEX));
            modeController.getController().getExtension(FormatController.class).addPatternFormat(new LatexFormat());
            modeController.getController().getExtension(FormatController.class).addPatternFormat(new UnparsedLatexFormat());
            if (modeController.getModeName().equals("MindMap")) {
                modeController.addAction(new InsertLatexAction(nodeHook));
                modeController.addAction(new EditLatexAction(nodeHook));
                modeController.addAction(new DeleteLatexAction(nodeHook));
                addPreferencesToOptionPanel();
            }
        }

        private void addPreferencesToOptionPanel() {
            final URL preferences = this.getClass().getResource(PREFERENCES_RESOURCE);
            if (preferences == null)
                throw new RuntimeException("cannot open preferences");
            final Controller controller = Controller.getCurrentController();
            MModeController modeController = (MModeController) controller.getModeController();
            modeController.getOptionPanelBuilder().load(preferences);
        }
    }, props);
}
Also used : Hashtable(java.util.Hashtable) SModeController(org.freeplane.main.mindmapmode.stylemode.SModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ModeController(org.freeplane.features.mode.ModeController) IModeControllerExtensionProvider(org.freeplane.main.osgi.IModeControllerExtensionProvider) SModeController(org.freeplane.main.mindmapmode.stylemode.SModeController) Controller(org.freeplane.features.mode.Controller) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) TextController(org.freeplane.features.text.TextController) ModeController(org.freeplane.features.mode.ModeController) FormatController(org.freeplane.features.format.FormatController) URL(java.net.URL) ConditionalContentTransformer(org.freeplane.features.text.mindmapmode.ConditionalContentTransformer) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 15 with MModeController

use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.

the class ExecuteScriptAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    Controller.getCurrentController().getViewController().setWaitingCursor(true);
    try {
        final List<NodeModel> nodes = new ArrayList<NodeModel>();
        final IMapSelection selection = Controller.getCurrentController().getSelection();
        if (mode == ExecutionMode.ON_SINGLE_NODE) {
            nodes.add(selection.getSelected());
        } else {
            nodes.addAll(selection.getSelection());
        }
        final MModeController modeController = (MModeController) Controller.getCurrentModeController();
        modeController.startTransaction();
        for (final NodeModel node : nodes) {
            try {
                if (mode == ExecutionMode.ON_SELECTED_NODE_RECURSIVELY) {
                    // TODO: ensure that a script is invoked only once on every node?
                    // (might be a problem with recursive actions if parent and child
                    // are selected.)
                    executeScriptRecursive(node);
                } else {
                    script.execute(node);
                }
            } catch (ExecuteScriptException ex) {
                final String cause;
                // that, it is what we want to know.
                if (ex.getCause() != null) {
                    if (ex.getCause().getCause() != null) {
                        LogUtils.warn("ExecuteScriptAction failed:", ex.getCause().getCause());
                        cause = ex.getCause().getCause().toString();
                    } else {
                        LogUtils.warn("ExecuteScriptAction failed:", ex.getCause());
                        cause = ex.getCause().toString();
                    }
                } else {
                    LogUtils.warn("ExecuteScriptAction failed:", ex);
                    cause = ex.toString();
                }
                LogUtils.warn("error executing script " + scriptFile + " - giving up\n" + cause);
                modeController.delayedRollback();
                ScriptingEngine.showScriptExceptionErrorMessage(ex);
                return;
            }
        }
        modeController.delayedCommit();
    } finally {
        Controller.getCurrentController().getViewController().setWaitingCursor(false);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) ArrayList(java.util.ArrayList) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Aggregations

MModeController (org.freeplane.features.mode.mindmapmode.MModeController)23 Controller (org.freeplane.features.mode.Controller)8 ModeController (org.freeplane.features.mode.ModeController)8 MMapController (org.freeplane.features.map.mindmapmode.MMapController)6 LinkController (org.freeplane.features.link.LinkController)5 MLinkController (org.freeplane.features.link.mindmapmode.MLinkController)5 ResourceController (org.freeplane.core.resources.ResourceController)4 NodeModel (org.freeplane.features.map.NodeModel)4 Component (java.awt.Component)3 URL (java.net.URL)3 RootPaneContainer (javax.swing.RootPaneContainer)3 ClipboardController (org.freeplane.features.clipboard.ClipboardController)3 IconController (org.freeplane.features.icon.IconController)3 MIconController (org.freeplane.features.icon.mindmapmode.MIconController)3 MapController (org.freeplane.features.map.MapController)3 MapModel (org.freeplane.features.map.MapModel)3 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)3 MNodeStyleController (org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController)3 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)3 TextController (org.freeplane.features.text.TextController)3