use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class EntriesForActionTest method returnsListWithTwoRegisteredActions.
@Test
public void returnsListWithTwoRegisteredActions() throws Exception {
final EntriesForAction entriesForAction = new EntriesForAction();
AFreeplaneAction action = mock(AFreeplaneAction.class);
final Entry actionEntry1 = new Entry();
final Entry actionEntry2 = new Entry();
entriesForAction.registerEntry(action, actionEntry1);
entriesForAction.registerEntry(action, actionEntry2);
Collection<Entry> entries = entriesForAction.entries(action);
assertThat(entries, equalTo((Collection<Entry>) asList(actionEntry1, actionEntry2)));
}
use of org.freeplane.core.ui.AFreeplaneAction 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.AFreeplaneAction in project freeplane by freeplane.
the class EntryAccessorTest method addsChildAction.
@Test
public void addsChildAction() throws Exception {
final AFreeplaneAction action = mock(AFreeplaneAction.class);
when(action.getKey()).thenReturn("key");
entryAccessor.addChildAction(entry, action);
final Entry actionEntry = entry.getChild(0);
final AFreeplaneAction entryAction = entryAccessor.getAction(actionEntry);
Assert.assertThat(actionEntry.getName(), equalTo("key"));
Assert.assertThat(entryAction, equalTo(action));
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class JToolbarComponentBuilderTest method createsToolbarButtonWithSelectableAction.
@Test
public void createsToolbarButtonWithSelectableAction() {
Entry actionEntry = new Entry();
final AFreeplaneAction action = Mockito.mock(AFreeplaneAction.class);
when(action.isSelectable()).thenReturn(true);
new EntryAccessor().setAction(actionEntry, action);
Entry toolbarEntry = new Entry();
final FreeplaneToolBar toolbar = new FreeplaneToolBar("toolbar", SwingConstants.HORIZONTAL);
new EntryAccessor().setComponent(toolbarEntry, toolbar);
toolbarEntry.addChild(actionEntry);
final JToolbarComponentBuilder toolbarActionGroupBuilder = new JToolbarComponentBuilder();
toolbarActionGroupBuilder.visit(actionEntry);
JAutoToggleButton button = (JAutoToggleButton) new EntryAccessor().getComponent(actionEntry);
assertThat(button.getAction(), CoreMatchers.<Action>equalTo(action));
assertThat(button.getParent(), CoreMatchers.equalTo((Container) toolbar));
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class LastOpenedMapsRibbonContributorFactory method getContributor.
public ARibbonContributor getContributor(final Properties attributes) {
return new ARibbonContributor() {
@Override
public String getKey() {
return "lastOpenedMaps";
}
private final String menuName = TextUtils.getText(attributes.getProperty("name_ref"));
@Override
public void contribute(RibbonBuildContext context, ARibbonContributor parent) {
RibbonApplicationMenuEntryPrimary primeEntry = new RibbonApplicationMenuEntryPrimary(null, menuName, null, CommandButtonKind.POPUP_ONLY);
primeEntry.setRolloverCallback(getCallback(primeEntry));
parent.addChild(primeEntry, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
}
@Override
public void addChild(Object child, ChildProperties properties) {
}
private PrimaryRolloverCallback getCallback(final RibbonApplicationMenuEntryPrimary primeEntry) {
if (rolloverCallback == null) {
rolloverCallback = new PrimaryRolloverCallback() {
public void menuEntryActivated(JPanel targetPanel) {
targetPanel.removeAll();
targetPanel.setLayout(new BorderLayout());
JCommandButtonPanel secondary = new JRibbonApplicationMenuPopupPanelSecondary(primeEntry);
secondary.setToShowGroupLabels(false);
String groupDesc = menuName;
secondary.addButtonGroup(groupDesc);
List<AFreeplaneAction> openActions = lastOpenedList.createOpenLastMapActionList();
for (AFreeplaneAction action : openActions) {
String restoreable = (String) action.getValue(Action.DEFAULT);
StringTokenizer tokens = new StringTokenizer(restoreable, ";");
File file = lastOpenedList.createFileFromRestorable(tokens);
JCommandButton menuButton = new JCommandButton(file.getName());
menuButton.addActionListener(action);
menuButton.setCommandButtonKind(CommandButtonKind.ACTION_ONLY);
menuButton.setHorizontalAlignment(SwingUtilities.LEADING);
menuButton.setPopupOrientationKind(CommandButtonPopupOrientationKind.SIDEWARD);
menuButton.setEnabled(true);
menuButton.setActionRichTooltip(new RichTooltip((String) action.getValue(Action.SHORT_DESCRIPTION), file.toString()));
secondary.addButtonToLastGroup(menuButton);
}
JScrollablePanel<JCommandButtonPanel> scrollPanel = new JScrollablePanel<JCommandButtonPanel>(secondary, ScrollType.VERTICALLY);
targetPanel.add(scrollPanel, BorderLayout.CENTER);
}
};
}
return rolloverCallback;
}
};
}
Aggregations