use of org.freeplane.core.ui.MenuBuilder in project freeplane by freeplane.
the class HotKeyInfoAction method actionPerformed.
@SuppressWarnings("unchecked")
public void actionPerformed(ActionEvent e) {
// use the MModeController for the mindmap mode menu if possible - the browse menu doesn't have much entries!
final ModeController modeController = ResourceController.getResourceController().isApplet() ? Controller.getCurrentModeController() : MModeController.getMModeController();
final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
// TODO - find a similar way to outline the hotkeys for the ribbons
final DefaultMutableTreeNode menuEntryTree = MenuUtils.createAcceleratebleMenuEntryTree(FreeplaneMenuBar.MENU_BAR_PREFIX, menuBuilder);
final String title = TextUtils.getText("hot_keys_table");
final String html = formatAsHtml(menuEntryTree.children());
JEditorPane refPane = new JEditorPane("text/html", html);
refPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, false);
refPane.setCaretPosition(0);
refPane.setEditable(false);
final Dimension preferredSize = refPane.getPreferredSize();
JScrollPane scrollPane = new JScrollPane(refPane, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setPreferredSize(new Dimension(preferredSize.width, 600));
JOptionPane.showMessageDialog((Component) e.getSource(), scrollPane, title, JOptionPane.INFORMATION_MESSAGE);
}
use of org.freeplane.core.ui.MenuBuilder in project freeplane by freeplane.
the class LoadAcceleratorPresetsAction method install.
public static final void install() {
final File[] dirs = { LoadAcceleratorPresetsAction.getAcceleratorsUserDirectory(), LoadAcceleratorPresetsAction.getAcceleratorsSysDirectory() };
final Controller controller = Controller.getCurrentController();
ModeController modecontroller = controller.getModeController(MModeController.MODENAME);
final MenuBuilder menuBuilder = modecontroller.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
// TODO RIBBONS: impl. eventually
for (final File dir : dirs) {
final File[] fileList = dir.listFiles();
if (fileList == null) {
continue;
}
for (final File prop : fileList) {
final String fileName = prop.getName();
if (prop.isDirectory()) {
continue;
}
if (!fileName.endsWith(".properties")) {
continue;
}
try {
final int propNameLength = fileName.lastIndexOf('.');
final String propName = fileName.substring(0, propNameLength);
final String key = "LoadAcceleratorPresetsAction." + propName;
if (controller.getAction(key) == null) {
final String title = TextUtils.getText(key + ".text", propName);
final LoadAcceleratorPresetsAction loadAcceleratorPresetsAction = new LoadAcceleratorPresetsAction(prop.toURL(), key, title);
controller.addAction(loadAcceleratorPresetsAction);
menuBuilder.addAction("main_menu_new_load_accelerator_presets", key, loadAcceleratorPresetsAction, MenuBuilder.AS_CHILD);
}
} catch (final Exception e) {
UITools.errorMessage(TextUtils.format("accelerators_loading_error", prop.getPath()));
}
}
}
}
use of org.freeplane.core.ui.MenuBuilder in project freeplane by freeplane.
the class LastOpenedList method updateMenus.
private void updateMenus() {
Controller controller = Controller.getCurrentController();
final ModeController modeController = controller.getModeController();
if (!modeController.getUserInputListenerFactory().useRibbonMenu()) {
final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
menuBuilder.removeChildElements(MENU_CATEGORY);
List<AFreeplaneAction> openMapActions = createOpenLastMapActionList();
for (AFreeplaneAction openMapAction : openMapActions) {
final IFreeplaneAction acceleratableAction = menuBuilder.acceleratableAction(openMapAction);
final JMenuItem item = new JFreeplaneMenuItem(acceleratableAction);
item.setMnemonic(0);
menuBuilder.addMenuItem(MENU_CATEGORY, item, MENU_CATEGORY + '/' + openMapAction.getKey(), UIBuilder.AS_CHILD);
}
}
}
use of org.freeplane.core.ui.MenuBuilder in project freeplane by freeplane.
the class Activator method start.
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
@Override
public void start(final BundleContext context) throws Exception {
final Hashtable<String, String[]> props = new Hashtable<String, String[]>();
props.put("mode", new String[] { MModeController.MODENAME /*TODO: other modes too?*/
});
context.registerService(IModeControllerExtensionProvider.class.getName(), new IModeControllerExtensionProvider() {
@Override
public void installExtension(ModeController modeController) {
final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
final $$$$Action action = new $$$$Action();
modeController.addAction(action);
modeController.addMenuContributor(new IMenuContributor() {
@Override
public void updateMenus(ModeController modeController, MenuBuilder builder) {
menuBuilder.addAction("/menu_bar/file", action, MenuBuilder.AS_CHILD);
}
});
}
}, props);
}
use of org.freeplane.core.ui.MenuBuilder in project freeplane by freeplane.
the class UpdateCheckAction method addUpdateButton.
private void addUpdateButton(final FreeplaneVersion lastVersion) {
Controller controller = Controller.getCurrentController();
final Set<String> modes = controller.getModes();
for (final String mode : modes) {
ModeController modeController = controller.getModeController(mode);
if (!modeController.getUserInputListenerFactory().useRibbonMenu()) {
final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
if (lastVersion == null || lastVersion.compareTo(FreeplaneVersion.getVersion()) <= 0) {
ResourceController.getResourceController().setProperty(LAST_UPDATE_VERSION, "");
if (menuBuilder.get(UPDATE_BUTTON_PATH) != null) {
menuBuilder.removeElement(UPDATE_BUTTON_PATH);
}
continue;
}
ResourceController.getResourceController().setProperty(LAST_UPDATE_VERSION, lastVersion.toString());
final String updateAvailable = TextUtils.format("new_version_available", lastVersion.toString());
controller.getViewController().out(updateAvailable);
putValue(SHORT_DESCRIPTION, updateAvailable);
putValue(LONG_DESCRIPTION, updateAvailable);
if (menuBuilder.get(UPDATE_BUTTON_PATH) == null) {
menuBuilder.addAction(UPDATE_BUTTON_LOCATION, UPDATE_BUTTON_PATH, UpdateCheckAction.this, MenuBuilder.AS_CHILD);
}
}
}
}
Aggregations