Search in sources :

Example 81 with Controller

use of org.freeplane.features.mode.Controller in project freeplane by freeplane.

the class UpdateCheckAction method addUpdateButton.

private void addUpdateButton(final FreeplaneVersion lastVersion) {
    if (entry != null) {
        Controller controller = Controller.getCurrentController();
        final Component component = (Component) new EntryAccessor().getComponent(entry);
        if (component != null) {
            final Dimension preferredSize = component.getPreferredSize();
            if (lastVersion == null || lastVersion.compareTo(FreeplaneVersion.getVersion()) <= 0) {
                ResourceController.getResourceController().setProperty(LAST_UPDATE_VERSION, "");
                component.setPreferredSize(new Dimension(0, preferredSize.height));
                component.setVisible(false);
            } else {
                ResourceController.getResourceController().setProperty(LAST_UPDATE_VERSION, lastVersion.toString());
                final String updateAvailable = TextUtils.format("new_version_available", lastVersion.toString());
                controller.getViewController().out(updateAvailable);
                putValue(SHORT_DESCRIPTION, updateAvailable);
                putValue(LONG_DESCRIPTION, updateAvailable);
                component.setPreferredSize(new Dimension(preferredSize.height, preferredSize.height));
                component.setVisible(true);
            }
        }
    }
}
Also used : EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Dimension(java.awt.Dimension) AddOnsController(org.freeplane.main.addons.AddOnsController) ResourceController(org.freeplane.core.resources.ResourceController) Controller(org.freeplane.features.mode.Controller) Component(java.awt.Component)

Example 82 with Controller

use of org.freeplane.features.mode.Controller in project freeplane by freeplane.

the class MMapModel method close.

@Override
public boolean close() {
    final Controller controller = Controller.getCurrentController();
    final ModeController modeController = controller.getModeController(MModeController.MODENAME);
    final MMapController mapController = (MMapController) modeController.getMapController();
    return mapController.close(this);
}
Also used : ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) ResourceController(org.freeplane.core.resources.ResourceController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 83 with Controller

use of org.freeplane.features.mode.Controller in project freeplane by freeplane.

the class UserInputListenerFactory method createModeActions.

private void createModeActions(final Entry modesMenuEntry) {
    rebuildMenuOnMapChange(modesMenuEntry);
    Controller controller = Controller.getCurrentController();
    EntryAccessor entryAccessor = new EntryAccessor();
    for (final String key : new LinkedList<String>(controller.getModes())) {
        final AFreeplaneAction modesMenuAction = new ModesMenuAction(key, controller);
        modeController.addActionIfNotAlreadySet(modesMenuAction);
        Entry actionEntry = new Entry();
        entryAccessor.setAction(actionEntry, modesMenuAction);
        actionEntry.setName(modesMenuAction.getKey());
        final ModeController modeController = controller.getModeController();
        if (modeController != null && modeController.getModeName().equals(key)) {
            actionEntry.setAttribute("selected", true);
        }
        modesMenuEntry.addChild(actionEntry);
        ResourceController.getResourceController().getProperty(("keystroke_mode_" + key));
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) ModeController(org.freeplane.features.mode.ModeController) Controller(org.freeplane.features.mode.Controller) ResourceController(org.freeplane.core.resources.ResourceController) ViewController(org.freeplane.features.ui.ViewController) ModeController(org.freeplane.features.mode.ModeController) LinkedList(java.util.LinkedList)

Example 84 with Controller

use of org.freeplane.features.mode.Controller in project freeplane by freeplane.

the class ActionAcceleratorManager method loadAcceleratorPresets.

public void loadAcceleratorPresets(final InputStream in) {
    final Properties prop = new Properties();
    try {
        prop.load(in);
        for (final Entry<Object, Object> property : prop.entrySet()) {
            final String shortcutKey = (String) property.getKey();
            final String keystrokeString = (String) property.getValue();
            if (!shortcutKey.startsWith(SHORTCUT_PROPERTY_PREFIX)) {
                LogUtils.warn("wrong property key " + shortcutKey);
                continue;
            }
            final int pos = shortcutKey.indexOf("/", SHORTCUT_PROPERTY_PREFIX.length());
            if (pos <= 0) {
                LogUtils.warn("wrong property key " + shortcutKey);
                continue;
            }
            final String modeName = shortcutKey.substring(SHORTCUT_PROPERTY_PREFIX.length(), pos);
            final String itemKey = shortcutKey.substring(pos + 1);
            Controller controller = Controller.getCurrentController();
            final ModeController modeController = controller.getModeController(modeName);
            if (modeController != null) {
                final AFreeplaneAction action = modeController.getAction(itemKey);
                if (action == null) {
                    LogUtils.warn("wrong key in " + shortcutKey);
                    continue;
                }
                final KeyStroke keyStroke;
                if (!keystrokeString.equals("")) {
                    keyStroke = UITools.getKeyStroke(parseKeyStroke(keystrokeString).toString());
                    final AFreeplaneAction oldAction = accelerators.get(keyStroke);
                    if (oldAction != null) {
                        setAccelerator(oldAction, null);
                        final Object key = oldAction.getKey();
                        final String oldShortcutKey = getPropertyKey(key.toString());
                        keysetProps.setProperty(oldShortcutKey, "");
                    }
                } else {
                    keyStroke = null;
                }
                setAccelerator(action, keyStroke);
            }
            keysetProps.setProperty(shortcutKey, keystrokeString);
        }
    } catch (final IOException e) {
        LogUtils.warn("shortcut presets not stored: " + e.getMessage());
    }
}
Also used : KeyStroke(javax.swing.KeyStroke) ModeController(org.freeplane.features.mode.ModeController) IOException(java.io.IOException) Properties(java.util.Properties) ResourceController(org.freeplane.core.resources.ResourceController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController)

Example 85 with Controller

use of org.freeplane.features.mode.Controller in project freeplane by freeplane.

the class CopyNodeURIAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final Controller controller = Controller.getCurrentController();
    final NodeModel node = controller.getSelection().getSelected();
    File mindmapFile = node.getMap().getFile();
    if (mindmapFile == null) {
        UITools.errorMessage(TextUtils.getRawText("map_not_saved"));
        return;
    }
    final String idString = uri(node, mindmapFile);
    final ClipboardController clipboardController = Controller.getCurrentModeController().getExtension(ClipboardController.class);
    clipboardController.setClipboardContents(new StringSelection(idString));
    controller.getViewController().out(idString);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) Controller(org.freeplane.features.mode.Controller) File(java.io.File) StringSelection(java.awt.datatransfer.StringSelection)

Aggregations

Controller (org.freeplane.features.mode.Controller)152 ModeController (org.freeplane.features.mode.ModeController)92 ResourceController (org.freeplane.core.resources.ResourceController)69 NodeModel (org.freeplane.features.map.NodeModel)46 MapController (org.freeplane.features.map.MapController)41 MapModel (org.freeplane.features.map.MapModel)34 LinkController (org.freeplane.features.link.LinkController)32 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)32 TextController (org.freeplane.features.text.TextController)27 MMapController (org.freeplane.features.map.mindmapmode.MMapController)24 ViewController (org.freeplane.features.ui.ViewController)23 IconController (org.freeplane.features.icon.IconController)22 Component (java.awt.Component)19 FilterController (org.freeplane.features.filter.FilterController)17 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)17 FormatController (org.freeplane.features.format.FormatController)16 ScannerController (org.freeplane.features.format.ScannerController)16 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)15 File (java.io.File)14 MTextController (org.freeplane.features.text.mindmapmode.MTextController)14