use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class AController method addAction.
public void addAction(final AFreeplaneAction value) {
final String key = value.getKey();
final AFreeplaneAction old = getActions().put(key, value);
// System.out.println("key\t\t" + value.getClass().getSimpleName() + "\t\ts/\\\"" + pattern + "\\\"/\\\"" + value.getClass().getSimpleName() + "\\\"/;");
if (old != null && !old.equals(value)) {
getActions().put(key, old);
throw new RuntimeException("action " + key + " already registered");
}
if (AFreeplaneAction.checkSelectionOnPropertyChange(value)) {
final ActionSelectorOnPropertyChange listener = new ActionSelectorOnPropertyChange(value);
ResourceController.getResourceController().addPropertyChangeListener(listener);
}
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class MLinkController method setAnchorID.
public void setAnchorID(final String anchorID) {
this.anchorID = anchorID;
final String tooltip;
AFreeplaneAction setLinkAnchorAction = modeController.getAction("SetLinkAnchorAction");
final boolean anchored = isAnchored();
if (anchored)
tooltip = TextUtils.format(setLinkAnchorAction.getTooltipKey() + "_anchored", anchorID);
else
tooltip = TextUtils.getRawText(setLinkAnchorAction.getTooltipKey());
setLinkAnchorAction.putValue(Action.SHORT_DESCRIPTION, tooltip);
setLinkAnchorAction.putValue(Action.LONG_DESCRIPTION, tooltip);
setLinkAnchorAction.setSelected(anchored);
modeController.getAction("ClearLinkAnchorAction").setEnabled(anchored);
modeController.getAction("MakeLinkToAnchorAction").setEnabled(anchored);
modeController.getAction("MakeLinkFromAnchorAction").setEnabled(anchored);
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class LastOpenedList method createOpenLastMapActionList.
public List<AFreeplaneAction> createOpenLastMapActionList() {
Controller controller = Controller.getCurrentController();
final ModeController modeController = controller.getModeController();
int i = 0;
int maxEntries = getMaxMenuEntries();
List<AFreeplaneAction> openMapActions = new ArrayList<AFreeplaneAction>(maxEntries);
for (final String key : lastOpenedList) {
if (i == 0 && (!modeController.getModeName().equals(MModeController.MODENAME) || controller.getMap() == null || controller.getMap().getURL() == null)) {
i++;
maxEntries++;
}
if (i == maxEntries) {
break;
}
final AFreeplaneAction openMapAction = new OpenLastOpenedAction(i++, this, key);
createOpenMapItemName(openMapAction, key);
openMapActions.add(openMapAction);
}
return openMapActions;
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class LastOpenedList method updateMenus.
private void updateMenus() {
Controller controller = Controller.getCurrentController();
final ModeController modeController = controller.getModeController();
if (!modeController.getUserInputListenerFactory().useRibbonMenu()) {
final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
menuBuilder.removeChildElements(MENU_CATEGORY);
List<AFreeplaneAction> openMapActions = createOpenLastMapActionList();
for (AFreeplaneAction openMapAction : openMapActions) {
final IFreeplaneAction acceleratableAction = menuBuilder.acceleratableAction(openMapAction);
final JMenuItem item = new JFreeplaneMenuItem(acceleratableAction);
item.setMnemonic(0);
menuBuilder.addMenuItem(MENU_CATEGORY, item, MENU_CATEGORY + '/' + openMapAction.getKey(), UIBuilder.AS_CHILD);
}
}
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class UserInputListenerFactory method updateModeMenu.
private void updateModeMenu() {
if (!useRibbonMenu()) {
getMenuBuilder(MenuBuilder.class).removeChildElements(FreeplaneMenuBar.MODES_MENU);
Controller controller = Controller.getCurrentController();
for (final String key : new LinkedList<String>(controller.getModes())) {
final AFreeplaneAction modesMenuActionListener = new ModesMenuActionListener(key, controller);
final ModeController modeController = controller.getModeController();
final boolean isSelected;
if (modeController != null) {
isSelected = modeController.getModeName().equals(key);
} else {
isSelected = false;
}
getMenuBuilder(MenuBuilder.class).addRadioItem(FreeplaneMenuBar.MODES_MENU, modesMenuActionListener, isSelected);
ResourceController.getResourceController().getProperty(("keystroke_mode_" + key));
}
}
}
Aggregations