use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class JComponentRemover method visit.
@Override
public void visit(Entry target) {
final EntryAccessor entryAccessor = new EntryAccessor();
final Component component = (Component) entryAccessor.removeComponent(target);
if (component != null) {
if (component instanceof AbstractButton)
((AbstractButton) component).setAction(null);
removeMenuComponent(component);
ActionEnabler actionEnabler = target.removeAttribute(ActionEnabler.class);
if (actionEnabler != null) {
final AFreeplaneAction action = entryAccessor.getAction(target);
action.removePropertyChangeListener(actionEnabler);
}
}
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class LastOpenedList method updateMenus.
private void updateMenus(ModeController modeController, Entry target) {
List<AFreeplaneAction> openMapActions = createOpenLastMapActionList();
for (AFreeplaneAction openMapAction : openMapActions) {
modeController.addActionIfNotAlreadySet(openMapAction);
new EntryAccessor().addChildAction(target, openMapAction);
}
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class AcceleratorBuilderTest method setsDefaultAcceleratorForAction.
@Test
public void setsDefaultAcceleratorForAction() {
Entry actionEntry = new Entry();
String actionKey = "actionKey";
actionEntry.setName(actionKey);
String keyStroke = KeyStroke.getKeyStroke('A', InputEvent.CTRL_MASK).toString();
actionEntry.setAttribute("accelerator", keyStroke);
final AFreeplaneAction action = mock(AFreeplaneAction.class);
new EntryAccessor().setAction(actionEntry, action);
IAcceleratorMap map = mock(IAcceleratorMap.class);
final AcceleratorBuilder acceleratorBuilder = new AcceleratorBuilder(map, mock(IEntriesForAction.class));
acceleratorBuilder.visit(actionEntry);
Mockito.verify(map).setDefaultAccelerator(action, keyStroke);
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class AcceleratorBuilderTest method givenEntryWithoutAccelerator_doesNotSetOwnDefaultAccelerator.
@Test
public void givenEntryWithoutAccelerator_doesNotSetOwnDefaultAccelerator() {
Entry actionEntry = new Entry();
final AFreeplaneAction action = mock(AFreeplaneAction.class);
new EntryAccessor().setAction(actionEntry, action);
IAcceleratorMap map = mock(IAcceleratorMap.class);
final AcceleratorBuilder acceleratorBuilder = new AcceleratorBuilder(map, mock(IEntriesForAction.class));
acceleratorBuilder.visit(actionEntry);
Mockito.verify(map, never()).setDefaultAccelerator(Mockito.<AFreeplaneAction>any(), anyString());
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class ActionFinderTest method attachesExistingFreeplaneAction.
@Test
public void attachesExistingFreeplaneAction() {
FreeplaneActions freeplaneActions = mock(FreeplaneActions.class);
Entry entry = new Entry();
entry.setName("action");
final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
when(freeplaneActions.getAction("action")).thenReturn(someAction);
final ActionFinder actionFinder = new ActionFinder(freeplaneActions);
actionFinder.visit(entry);
assertThat((AFreeplaneAction) new EntryAccessor().getAction(entry), CoreMatchers.equalTo(someAction));
}
Aggregations