use of org.freeplane.core.ui.components.JAutoRadioButtonMenuItem 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.components.JAutoRadioButtonMenuItem in project freeplane by freeplane.
the class MenuBuilder method addRadioItem.
public JMenuItem addRadioItem(final String category, final String key, final AFreeplaneAction action, final boolean isSelected) {
assert key != null;
final JRadioButtonMenuItem item;
if (action.getClass().getAnnotation(SelectableAction.class) != null) {
item = new JAutoRadioButtonMenuItem(decorateAction(category, action));
} else {
item = new JRadioButtonMenuItem(decorateAction(category, action));
}
addMenuItem(category, item, key, MenuBuilder.AS_CHILD);
item.setSelected(isSelected);
addListeners(key, action);
return item;
}
Aggregations