use of org.freeplane.core.ui.menubuilders.action.EntriesForAction in project freeplane by freeplane.
the class MenuAcceleratorChangeListenerTest method setsKeystroke.
@Test
public void setsKeystroke() throws Exception {
final EntriesForAction entriesForAction = new EntriesForAction();
final MenuAcceleratorChangeListener menuAcceleratorChangeListener = new MenuAcceleratorChangeListener(entriesForAction);
final AFreeplaneAction action = mock(AFreeplaneAction.class);
Entry actionEntry = new Entry();
final JMenuItem menu = new JMenuItem();
new EntryAccessor().setComponent(actionEntry, menu);
entriesForAction.registerEntry(action, actionEntry);
final KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0);
menuAcceleratorChangeListener.acceleratorChanged(action, null, keyStroke);
Assert.assertThat(menu.getAccelerator(), equalTo(keyStroke));
}
use of org.freeplane.core.ui.menubuilders.action.EntriesForAction in project freeplane by freeplane.
the class UserInputListenerFactory method updateMenus.
public void updateMenus(String menuStructureResource, Set<String> plugins) {
mapsPopupMenu = new JPopupMenu();
mapsPopupMenu.setName(TextUtils.getText("mindmaps"));
final URL genericStructure = ResourceController.getResourceController().getResource(menuStructureResource);
try {
final FreeplaneResourceAccessor resourceAccessor = new FreeplaneResourceAccessor();
final EntriesForAction entries = new EntriesForAction();
final ActionAcceleratorManager acceleratorManager = ResourceController.getResourceController().getAcceleratorManager();
final BuildProcessFactory buildProcessFactory = new MenuBuildProcessFactory(this, modeController, resourceAccessor, acceleratorManager, entries, buildPhaseListeners);
final PhaseProcessor buildProcessor = buildProcessFactory.getBuildProcessor();
subtreeBuilder = buildProcessFactory.getChildProcessor();
acceleratorManager.addAcceleratorChangeListener(modeController, new MenuAcceleratorChangeListener(entries));
for (final Phase phase : Phase.values()) for (java.util.Map.Entry<String, BuilderDestroyerPair> entry : customBuilders.get(phase.ordinal()).entrySet()) buildProcessor.phase(phase).addBuilderPair(entry.getKey(), entry.getValue());
final InputStream resource = genericStructure.openStream();
final BufferedReader reader = new BufferedReader(new InputStreamReader(resource));
genericMenuStructure = XmlEntryStructureBuilder.buildMenuStructure(reader);
filterPlugins(genericMenuStructure, plugins);
buildProcessor.build(genericMenuStructure);
if (Boolean.getBoolean("org.freeplane.outputUnusedActions"))
outputUnusedActions();
} catch (Exception e) {
final boolean isUserDefined = isUserDefined(genericStructure);
if (isUserDefined) {
LogUtils.warn(e);
String myMessage = TextUtils.format("menu_error", genericStructure.getPath(), e.getMessage());
UITools.backOtherWindows();
JOptionPane.showMessageDialog(UITools.getMenuComponent(), myMessage, "Freeplane", JOptionPane.ERROR_MESSAGE);
System.exit(-1);
}
throw new RuntimeException("Error in menu resource " + menuStructureResource, e);
}
}
use of org.freeplane.core.ui.menubuilders.action.EntriesForAction in project freeplane by freeplane.
the class MenuBuilderAcceptanceTest method setup.
@BeforeClass
public static void setup() {
final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
when(userInputListenerFactory.getToolBar("/main_toolbar")).thenReturn(new JToolBar());
when(userInputListenerFactory.getNodePopupMenu()).thenReturn(new JPopupMenu());
when(userInputListenerFactory.getMapPopup()).thenReturn(new JPopupMenu());
when(userInputListenerFactory.getMenuBar()).thenReturn(TestMenuBarFactory.createFreeplaneMenuBar());
final PhaseProcessor buildProcessor = new MenuBuildProcessFactory(userInputListenerFactory, Controller.getCurrentModeController(), new FreeplaneResourceAccessor(), mock(IAcceleratorMap.class), new EntriesForAction(), Collections.<BuildPhaseListener>emptyList()).getBuildProcessor();
final String menuResource = "/xml/mindmapmodemenu.xml";
final InputStream resource = MenuBuilderAcceptanceTest.class.getResourceAsStream(menuResource);
final BufferedReader reader = new BufferedReader(new InputStreamReader(resource));
menuStructure = XmlEntryStructureBuilder.buildMenuStructure(reader);
buildProcessor.build(menuStructure);
}
use of org.freeplane.core.ui.menubuilders.action.EntriesForAction in project freeplane by freeplane.
the class MenuBuildProcessFactoryTest method setup.
@Before
public void setup() {
freeplaneActions = mock(FreeplaneActions.class);
final ResourceAccessor resourceAccessorMock = mock(ResourceAccessor.class);
when(resourceAccessorMock.getRawText(Matchers.anyString())).thenReturn("text");
final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
final FreeplaneMenuBar menubar = TestMenuBarFactory.createFreeplaneMenuBar();
when(userInputListenerFactory.getMenuBar()).thenReturn(menubar);
phaseProcessor = new MenuBuildProcessFactory(userInputListenerFactory, freeplaneActions, resourceAccessorMock, mock(IAcceleratorMap.class), new EntriesForAction(), Collections.<BuildPhaseListener>emptyList()).getBuildProcessor();
}
Aggregations