use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class MIconController method getMindIcons.
public Collection<MindIcon> getMindIcons() {
final List<MindIcon> iconInfoList = new ArrayList<MindIcon>();
final Collection<AFreeplaneAction> iconActions = getIconActions();
for (final Action action : iconActions) {
final MindIcon info = ((IconAction) action).getMindIcon();
iconInfoList.add(info);
}
return iconInfoList;
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class MIconController method addActionToIconSubmenu.
private void addActionToIconSubmenu(final JMenu menu, final MindIcon icon, final String fileName) {
final AFreeplaneAction myAction = iconActions.get(icon);
final int separatorPosition = fileName.indexOf('/');
if (separatorPosition == -1) {
new MenuSplitter().addMenuComponent(menu, new JMenuItem(myAction), menu.getItemCount());
return;
}
final String submenuName = fileName.substring(0, separatorPosition);
final int componentCount = menu.getItemCount();
if (componentCount != 0) {
final Component lastComponent = menu.getMenuComponent(componentCount - 1);
if (lastComponent instanceof JMenu) {
final JMenu lastSubmenu = (JMenu) lastComponent;
if (lastSubmenu.getText().equals(submenuName)) {
addActionToIconSubmenu(lastSubmenu, icon, fileName.substring(separatorPosition + 1));
return;
}
}
}
final JMenu submenu = new JMenu(submenuName);
menu.add(submenu);
addActionToIconSubmenu(submenu, icon, fileName.substring(separatorPosition + 1));
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class MIconController method createPreferences.
private void createPreferences() {
final MModeController modeController = (MModeController) Controller.getCurrentModeController();
final OptionPanelBuilder optionPanelBuilder = modeController.getOptionPanelBuilder();
final List<AFreeplaneAction> actions = new ArrayList<AFreeplaneAction>();
actions.addAll(iconActions.values());
actions.add(modeController.getAction("RemoveIcon_0_Action"));
actions.add(modeController.getAction("RemoveIconAction"));
actions.add(modeController.getAction("RemoveAllIconsAction"));
for (final AFreeplaneAction iconAction : actions) {
final IIconInformation info = (IIconInformation) iconAction;
optionPanelBuilder.addCreator("Keystrokes/icons", new IPropertyControlCreator() {
public IPropertyControl createControl() {
final KeyProperty keyProperty = new KeyProperty(info.getShortcutKey(), info.getTranslationKeyLabel());
keyProperty.setImageIcon(info.getIcon());
keyProperty.disableModifiers();
return keyProperty;
}
}, IndexedTree.AS_CHILD);
}
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class MIconController method updateIconToolbar.
private void updateIconToolbar(ModeController modeController) {
iconToolBar.removeAll();
iconToolBar.add(modeController.getAction("RemoveIcon_0_Action")).setAlignmentX(JComponent.CENTER_ALIGNMENT);
iconToolBar.add(modeController.getAction("RemoveIconAction")).setAlignmentX(JComponent.CENTER_ALIGNMENT);
iconToolBar.add(modeController.getAction("RemoveAllIconsAction")).setAlignmentX(JComponent.CENTER_ALIGNMENT);
iconToolBar.addSeparator();
if (ResourceController.getResourceController().getBooleanProperty("structured_icon_toolbar")) {
insertSubmenus(iconToolBar);
return;
}
final String[] fpIcons = ResourceController.getResourceController().getProperty("icons.list").split(";");
for (final String icon : fpIcons) {
final MindIcon mindIcon = STORE.getMindIcon(icon);
final AFreeplaneAction iconAction = iconActions.get(mindIcon);
iconToolBar.add(iconAction).setAlignmentX(JComponent.CENTER_ALIGNMENT);
}
final Collection<MindIcon> userIcons = STORE.getUserIcons();
for (final MindIcon icon : userIcons) {
final AFreeplaneAction iconAction = iconActions.get(icon);
iconToolBar.add(iconAction).setAlignmentX(JComponent.CENTER_ALIGNMENT);
}
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class InputController method keyPressed.
public void keyPressed(KeyEvent e) {
KeyStroke currentStroke = KeyStroke.getKeyStrokeForEvent(e);
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
TreePath path = ((JTree) e.getSource()).getSelectionPath();
if (path == null) {
return;
}
AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
if (node instanceof IWorkspaceNodeActionListener) {
((IWorkspaceNodeActionListener) node).handleAction(new WorkspaceActionEvent(node, WorkspaceActionEvent.WSNODE_OPEN_DOCUMENT, 0, 0, e.getComponent()));
e.consume();
}
} else {
for (HotKeyIdentifier id : actionKeyMap.keySet()) {
if (currentStroke.equals(id.getKeyStroke())) {
if (id.accept(e)) {
AFreeplaneAction action = WorkspaceController.getAction(actionKeyMap.get(id));
if (action != null) {
action.actionPerformed(new ActionEvent(e.getSource(), 0, null));
} else {
LogUtils.info("No action set for: " + id.getKeyStroke());
}
}
e.consume();
break;
}
}
}
}
Aggregations