use of org.freeplane.core.ui.IFreeplaneAction in project freeplane by freeplane.
the class MenuActionComponentProvider method createComponent.
/* (non-Javadoc)
* @see org.freeplane.core.ui.menubuilders.menu.ComponentProvider#createComponent(org.freeplane.core.ui.menubuilders.generic.Entry)
*/
@Override
public Component createComponent(Entry entry) {
final AFreeplaneAction action = entryAccessor.getAction(entry);
if (action != null) {
final JMenuItem actionComponent;
IFreeplaneAction wrappedAction = acceleratebleActionProvider.wrap(action);
if (action.isSelectable()) {
actionComponent = new JAutoCheckBoxMenuItem(wrappedAction);
} else {
actionComponent = new JFreeplaneMenuItem(wrappedAction);
}
final KeyStroke accelerator = accelerators.getAccelerator(action);
actionComponent.setAccelerator(accelerator);
MenuIconScaling.scaleIcon(actionComponent);
return actionComponent;
} else if (entry.builders().contains("separator")) {
return new JPopupMenu.Separator();
} else
return null;
}
use of org.freeplane.core.ui.IFreeplaneAction in project freeplane by freeplane.
the class MenuRadioActionComponentProvider method createComponent.
/* (non-Javadoc)
* @see org.freeplane.core.ui.menubuilders.menu.ComponentProvider#createComponent(org.freeplane.core.ui.menubuilders.generic.Entry)
*/
@Override
public Component createComponent(Entry entry) {
final AFreeplaneAction action = entryAccessor.getAction(entry);
if (action != null) {
final JMenuItem actionComponent;
IFreeplaneAction wrappedAction = acceleratebleActionProvider.wrap(action);
if (action.isSelectable()) {
actionComponent = new JAutoRadioButtonMenuItem(wrappedAction);
} else {
actionComponent = new JRadioButtonMenuItem(wrappedAction);
}
actionComponent.setSelected(Boolean.parseBoolean(String.valueOf(entry.getAttribute("selected"))) || entry.getName().equals(getSelectedActionName(entry)));
buttonGroup.add(actionComponent);
final KeyStroke accelerator = accelerators.getAccelerator(action);
actionComponent.setAccelerator(accelerator);
MenuIconScaling.scaleIcon(actionComponent);
return actionComponent;
} else if (entry.builders().contains("separator")) {
return new JPopupMenu.Separator();
} else
return null;
}
use of org.freeplane.core.ui.IFreeplaneAction in project freeplane by freeplane.
the class MenuUtils method menuNode2menuEntryNode.
// in: node for JMenu, out: node for MenuEntry
private static DefaultMutableTreeNode menuNode2menuEntryNode(final DefaultMutableTreeNode menuNode, final HashMap<String, KeyStroke> menuKeyToKeyStrokeMap) {
final IndexedTree.Node node = (Node) menuNode;
final Object userObject = menuNode.getUserObject();
if (userObject instanceof JMenuItem) {
final JMenuItem jMenuItem = (JMenuItem) userObject;
final IFreeplaneAction action = (IFreeplaneAction) jMenuItem.getAction();
final String key = String.valueOf(node.getKey());
final String iconKey = action == null ? null : action.getIconKey();
return new DefaultMutableTreeNode(new MenuEntry(key, jMenuItem.getText(), iconKey, menuKeyToKeyStrokeMap.get(key), jMenuItem.getToolTipText()));
}
// - just omit them
return null;
}
use of org.freeplane.core.ui.IFreeplaneAction 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);
}
}
}
Aggregations