use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class AcceleratorBuilder method visit.
public void visit(Entry entry) {
final AFreeplaneAction action = new EntryAccessor().getAction(entry);
if (action != null) {
final EntryAccessor entryAccessor = new EntryAccessor();
String accelerator = entryAccessor.getAccelerator(entry);
if (accelerator != null) {
map.setDefaultAccelerator(action, accelerator);
} else
map.setUserDefinedAccelerator(action);
entries.registerEntry(action, entry);
}
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class ActionFinder method visit.
@Override
public void visit(final Entry target) {
final String actionName = target.getName();
if (!actionName.isEmpty() && new EntryAccessor().getAction(target) == null) {
AFreeplaneAction action = freeplaneActions.getAction(actionName);
if (action == null) {
for (final Class<? extends AFreeplaneAction> actionClass : Arrays.asList(SetBooleanPropertyAction.class, SetBooleanMapPropertyAction.class, SetBooleanMapViewPropertyAction.class, SetStringPropertyAction.class)) {
final String setBooleanPropertyActionPrefix = actionClass.getSimpleName() + ".";
if (actionName.startsWith(setBooleanPropertyActionPrefix)) {
String propertyName = actionName.substring(setBooleanPropertyActionPrefix.length());
action = createAction(actionClass, propertyName);
if (action != null) {
freeplaneActions.addAction(action);
}
break;
}
}
}
new EntryAccessor().setAction(target, action);
}
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class MenuBuilderIntegrationTest method createsToolbarButtonWithAction.
@Test
public void createsToolbarButtonWithAction() {
String content = "<FreeplaneUIEntries>" + "<Entry name='home' builder='toolbar'>" + "<Entry name='action'/>" + "</Entry>" + "</FreeplaneUIEntries>";
final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
when(freeplaneActions.getAction("action")).thenReturn(someAction);
Entry builtMenuStructure = buildJMenu(content);
assertThat(((JButton) new EntryAccessor().getComponent(builtMenuStructure.getChild(0).getChild(0))).getAction(), CoreMatchers.<Action>equalTo(someAction));
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class MenuBuilderIntegrationTest method givengroupWithAction_addsActionButtonToToolbar.
@Test
public void givengroupWithAction_addsActionButtonToToolbar() {
String content = "<FreeplaneUIEntries>" + "<Entry name='home' builder='toolbar'>" + "<Entry name='action'/>" + "</Entry>" + "</FreeplaneUIEntries>";
final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
when(freeplaneActions.getAction("action")).thenReturn(someAction);
Entry builtMenuStructure = buildJMenu(content);
final JToolBar toolbar = (JToolBar) new EntryAccessor().getComponent(builtMenuStructure.getChild(0));
final JButton button = (JButton) new EntryAccessor().getComponent(builtMenuStructure.getChild(0).getChild(0));
assertThat(button.getParent(), CoreMatchers.equalTo((Container) toolbar));
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class AcceleratorBuilderTest method registersEntryWithAction.
@Test
public void registersEntryWithAction() {
Entry actionEntry = new Entry();
final AFreeplaneAction action = mock(AFreeplaneAction.class);
new EntryAccessor().setAction(actionEntry, action);
IAcceleratorMap map = mock(IAcceleratorMap.class);
IEntriesForAction entries = mock(IEntriesForAction.class);
final AcceleratorBuilder acceleratorBuilder = new AcceleratorBuilder(map, entries);
acceleratorBuilder.visit(actionEntry);
Mockito.verify(entries).registerEntry(action, actionEntry);
}
Aggregations