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);
}
}
Aggregations