Search in sources :

Example 26 with AFreeplaneAction

use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.

the class ActionSelectListenerTest method activatesSelectOnPopup_forCheckSelectionOnPopup.

@Test
public void activatesSelectOnPopup_forCheckSelectionOnPopup() {
    Entry menuEntry = new Entry();
    Entry actionEntry = new Entry();
    menuEntry.addChild(actionEntry);
    final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
    when(someAction.checkSelectionOnPopup()).thenReturn(true);
    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).setSelected();
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryPopupListenerCollection(org.freeplane.core.ui.menubuilders.generic.EntryPopupListenerCollection) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Test(org.junit.Test)

Example 27 with AFreeplaneAction

use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.

the class EntriesForActionTest method returnsEmptyListIfNoActionWasRegistered.

@Test
public void returnsEmptyListIfNoActionWasRegistered() throws Exception {
    final EntriesForAction entriesForAction = new EntriesForAction();
    AFreeplaneAction action = mock(AFreeplaneAction.class);
    Collection<Entry> entries = entriesForAction.entries(action);
    assertThat(entries.isEmpty(), equalTo(true));
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Test(org.junit.Test)

Example 28 with AFreeplaneAction

use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.

the class EntriesForActionTest method returnsListWithRegisteredAction.

@Test
public void returnsListWithRegisteredAction() throws Exception {
    final EntriesForAction entriesForAction = new EntriesForAction();
    AFreeplaneAction action = mock(AFreeplaneAction.class);
    final Entry actionEntry = new Entry();
    entriesForAction.registerEntry(action, actionEntry);
    Collection<Entry> entries = entriesForAction.entries(action);
    assertThat(entries, equalTo((Collection<Entry>) asList(actionEntry)));
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Collection(java.util.Collection) Test(org.junit.Test)

Example 29 with AFreeplaneAction

use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.

the class ScriptingMenuEntryVisitor method createAction.

private AFreeplaneAction createAction(final String scriptName, final String scriptPath, ExecutionMode executionMode, final ScriptMetaData metaData, final String title) {
    final String key = ExecuteScriptAction.makeMenuItemKey(scriptName, executionMode);
    final AFreeplaneAction alreadyRegisteredAction = modeController.getAction(key);
    if (alreadyRegisteredAction == null) {
        String longTitle = createTooltip(title, executionMode);
        String menuItemTitle = hasMultipleExcecutionModes(metaData) ? longTitle : title;
        AFreeplaneAction action = new ExecuteScriptAction(scriptName, menuItemTitle, scriptPath, executionMode, metaData.getPermissions());
        action.putValue(Action.SHORT_DESCRIPTION, longTitle);
        action.putValue(Action.LONG_DESCRIPTION, longTitle);
        modeController.addAction(action);
        return action;
    } else {
        return alreadyRegisteredAction;
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction)

Example 30 with AFreeplaneAction

use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.

the class ScriptingMenuEntryVisitor method createNoScriptsAvailableAction.

private Entry createNoScriptsAvailableAction() {
    final Entry entry = new Entry();
    entry.setName("NoScriptsAvailableAction");
    @SuppressWarnings("serial") final AFreeplaneAction noScriptsAvailableAction = new AFreeplaneAction("NoScriptsAvailableAction", noScriptsAvailableMessage(), null) {

        @Override
        public void actionPerformed(ActionEvent e) {
        }
    };
    new EntryAccessor().setAction(entry, noScriptsAvailableAction);
    return entry;
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ActionEvent(java.awt.event.ActionEvent) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor)

Aggregations

AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)66 EntryAccessor (org.freeplane.core.ui.menubuilders.generic.EntryAccessor)23 Entry (org.freeplane.core.ui.menubuilders.generic.Entry)20 Test (org.junit.Test)20 Component (java.awt.Component)9 ArrayList (java.util.ArrayList)9 KeyStroke (javax.swing.KeyStroke)8 JCommandButton (org.pushingpixels.flamingo.api.common.JCommandButton)8 Container (java.awt.Container)6 ARibbonContributor (org.freeplane.core.ui.ribbon.ARibbonContributor)6 RibbonBuildContext (org.freeplane.core.ui.ribbon.RibbonBuildContext)6 Controller (org.freeplane.features.mode.Controller)6 ModeController (org.freeplane.features.mode.ModeController)6 ActionEvent (java.awt.event.ActionEvent)5 JMenuItem (javax.swing.JMenuItem)5 ResourceController (org.freeplane.core.resources.ResourceController)5 JComponent (javax.swing.JComponent)4 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)4 RichTooltip (org.pushingpixels.flamingo.api.common.RichTooltip)4 PopupPanelCallback (org.pushingpixels.flamingo.api.common.popup.PopupPanelCallback)4