use of org.freeplane.core.ui.components.JAutoCheckBoxMenuItem 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.components.JAutoCheckBoxMenuItem in project freeplane by freeplane.
the class JMenuItemBuilderTest method createsMenuItemWithSelectableAction.
@Test
public void createsMenuItemWithSelectableAction() {
menuEntry.addChild(actionEntry);
when(action.isSelectable()).thenReturn(true);
new EntryAccessor().setComponent(menuEntry, menu);
menuActionGroupBuilder.visit(actionEntry);
JAutoCheckBoxMenuItem item = (JAutoCheckBoxMenuItem) new EntryAccessor().getComponent(actionEntry);
final AccelerateableAction itemAction = (AccelerateableAction) item.getAction();
assertThat(itemAction.getOriginalAction(), CoreMatchers.<Action>equalTo(action));
assertThat(item.getParent(), CoreMatchers.<Container>equalTo(menu.getPopupMenu()));
}
Aggregations