Search in sources :

Example 1 with BuildProcessFactory

use of org.freeplane.core.ui.menubuilders.generic.BuildProcessFactory 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);
    }
}
Also used : Phase(org.freeplane.core.ui.menubuilders.generic.PhaseProcessor.Phase) InputStreamReader(java.io.InputStreamReader) FreeplaneResourceAccessor(org.freeplane.core.ui.menubuilders.FreeplaneResourceAccessor) InputStream(java.io.InputStream) JPopupMenu(javax.swing.JPopupMenu) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) BuildProcessFactory(org.freeplane.core.ui.menubuilders.generic.BuildProcessFactory) MenuBuildProcessFactory(org.freeplane.core.ui.menubuilders.menu.MenuBuildProcessFactory) MenuBuildProcessFactory(org.freeplane.core.ui.menubuilders.menu.MenuBuildProcessFactory) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntriesForAction(org.freeplane.core.ui.menubuilders.action.EntriesForAction) PhaseProcessor(org.freeplane.core.ui.menubuilders.generic.PhaseProcessor) ActionAcceleratorManager(org.freeplane.core.ui.ActionAcceleratorManager) BufferedReader(java.io.BufferedReader) MenuAcceleratorChangeListener(org.freeplane.core.ui.menubuilders.menu.MenuAcceleratorChangeListener)

Aggregations

BufferedReader (java.io.BufferedReader)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 JPopupMenu (javax.swing.JPopupMenu)1 ActionAcceleratorManager (org.freeplane.core.ui.ActionAcceleratorManager)1 FreeplaneResourceAccessor (org.freeplane.core.ui.menubuilders.FreeplaneResourceAccessor)1 EntriesForAction (org.freeplane.core.ui.menubuilders.action.EntriesForAction)1 BuildProcessFactory (org.freeplane.core.ui.menubuilders.generic.BuildProcessFactory)1 Entry (org.freeplane.core.ui.menubuilders.generic.Entry)1 PhaseProcessor (org.freeplane.core.ui.menubuilders.generic.PhaseProcessor)1 Phase (org.freeplane.core.ui.menubuilders.generic.PhaseProcessor.Phase)1 MenuAcceleratorChangeListener (org.freeplane.core.ui.menubuilders.menu.MenuAcceleratorChangeListener)1 MenuBuildProcessFactory (org.freeplane.core.ui.menubuilders.menu.MenuBuildProcessFactory)1