use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class ActionFinderTest method attachesSetBooleanPropertyAction.
@Test
public void attachesSetBooleanPropertyAction() {
FreeplaneActions freeplaneActions = mock(FreeplaneActions.class);
final SetBooleanPropertyAction setBooleanPropertyAction = Mockito.mock(SetBooleanPropertyAction.class);
Entry entry = new Entry();
final String propertyActionName = "SetBooleanPropertyAction.property";
entry.setName(propertyActionName);
when(freeplaneActions.getAction(propertyActionName)).thenReturn(null);
final ActionFinder actionFinder = new ActionFinder(freeplaneActions) {
@Override
protected AFreeplaneAction createAction(Class<? extends AFreeplaneAction> actionClass, String propertyName) {
return setBooleanPropertyAction;
}
};
actionFinder.visit(entry);
Mockito.verify(freeplaneActions).addAction(setBooleanPropertyAction);
assertThat(new EntryAccessor().getAction(entry), CoreMatchers.<Object>equalTo(setBooleanPropertyAction));
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class ActionSelectListenerTest method dontActivateSelectOnPopup_forNotCheckSelectionOnPopup.
@Test
public void dontActivateSelectOnPopup_forNotCheckSelectionOnPopup() {
Entry menuEntry = new Entry();
Entry actionEntry = new Entry();
menuEntry.addChild(actionEntry);
final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
when(someAction.checkSelectionOnPopup()).thenReturn(false);
when(someAction.isEnabled()).thenReturn(true);
new EntryAccessor().setAction(actionEntry, someAction);
final EntryPopupListenerCollection entryPopupListenerCollection = new EntryPopupListenerCollection();
final ActionSelectListener actionSelectListener = new ActionSelectListener();
entryPopupListenerCollection.addEntryPopupListener(actionSelectListener);
entryPopupListenerCollection.childEntriesWillBecomeVisible(menuEntry);
verify(someAction, never()).setSelected();
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class UserInputListenerFactory method createModeActions.
private void createModeActions(final Entry modesMenuEntry) {
rebuildMenuOnMapChange(modesMenuEntry);
Controller controller = Controller.getCurrentController();
EntryAccessor entryAccessor = new EntryAccessor();
for (final String key : new LinkedList<String>(controller.getModes())) {
final AFreeplaneAction modesMenuAction = new ModesMenuAction(key, controller);
modeController.addActionIfNotAlreadySet(modesMenuAction);
Entry actionEntry = new Entry();
entryAccessor.setAction(actionEntry, modesMenuAction);
actionEntry.setName(modesMenuAction.getKey());
final ModeController modeController = controller.getModeController();
if (modeController != null && modeController.getModeName().equals(key)) {
actionEntry.setAttribute("selected", true);
}
modesMenuEntry.addChild(actionEntry);
ResourceController.getResourceController().getProperty(("keystroke_mode_" + key));
}
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class JComponentRemoverTest method removesComponentsFromParents.
@Test
public void removesComponentsFromParents() throws Exception {
final JComponentRemover componentRemover = new JComponentRemover();
final Entry entry = new Entry();
JComponent parent = new JPanel();
JComponent entryComponent = new JPanel();
parent.add(entryComponent);
new EntryAccessor().setComponent(entry, entryComponent);
componentRemover.visit(entry);
Assert.assertThat(entryComponent.getParent(), nullValue(Container.class));
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class JComponentRemoverTest method removesExtraSubmenusFromParents.
@Test
public void removesExtraSubmenusFromParents() throws Exception {
final JComponentRemover componentRemover = new JComponentRemover();
final Entry entry = new Entry();
JMenu parent = new JMenu();
JComponent entryComponent = new JMenu();
final MenuSplitter menuSplitter = new MenuSplitter(1);
menuSplitter.addMenuComponent(parent, new JMenu());
menuSplitter.addMenuComponent(parent, entryComponent);
new EntryAccessor().setComponent(entry, entryComponent);
componentRemover.visit(entry);
Assert.assertThat(parent.getPopupMenu().getComponentCount(), equalTo(1));
}
Aggregations