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);
}
}
}
}
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);
}
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));
}
}
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());
}
}
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);
}
Aggregations