Search in sources :

Example 1 with IIconInformation

use of org.freeplane.features.icon.IIconInformation in project freeplane by freeplane.

the class IconSelectionPopupDialog method findIndexByKeyEvent.

private int findIndexByKeyEvent(final KeyEvent keyEvent) {
    for (int i = 0; i < icons.size(); i++) {
        final IIconInformation info = icons.get(i);
        final KeyStroke iconKeyStroke = info.getKeyStroke();
        if (iconKeyStroke != null && (keyEvent.getKeyCode() == iconKeyStroke.getKeyCode() && keyEvent.getKeyCode() != 0 && (iconKeyStroke.getModifiers() & InputEvent.SHIFT_MASK) == (keyEvent.getModifiers() & InputEvent.SHIFT_MASK) || keyEvent.getKeyChar() == iconKeyStroke.getKeyChar()) && keyEvent.getKeyChar() != 0 && keyEvent.getKeyChar() != KeyEvent.CHAR_UNDEFINED) {
            return i;
        }
    }
    return -1;
}
Also used : KeyStroke(javax.swing.KeyStroke) IIconInformation(org.freeplane.features.icon.IIconInformation)

Example 2 with IIconInformation

use of org.freeplane.features.icon.IIconInformation in project freeplane by freeplane.

the class IconSelectionPlugin method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentModeController();
    ArrayList<IIconInformation> actions = new ArrayList<IIconInformation>();
    final Controller controller = Controller.getCurrentController();
    actions.add((IIconInformation) modeController.getAction("RemoveIcon_0_Action"));
    actions.add((IIconInformation) modeController.getAction("RemoveIconAction"));
    actions.add((IIconInformation) modeController.getAction("RemoveAllIconsAction"));
    final MIconController mIconController = (MIconController) IconController.getController();
    for (AFreeplaneAction aFreeplaneAction : mIconController.getIconActions()) actions.add((IIconInformation) aFreeplaneAction);
    final IconSelectionPopupDialog selectionDialog = new IconSelectionPopupDialog(UITools.getCurrentFrame(), actions);
    final NodeModel selected = controller.getSelection().getSelected();
    controller.getMapViewManager().scrollNodeToVisible(selected);
    selectionDialog.pack();
    UITools.setDialogLocationRelativeTo(selectionDialog, selected);
    selectionDialog.setModal(true);
    selectionDialog.show();
    final int result = selectionDialog.getResult();
    if (result >= 0) {
        final Action action = (Action) actions.get(result);
        action.actionPerformed(new ActionEvent(action, 0, NodeModel.NODE_ICON, selectionDialog.getModifiers()));
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) NodeModel(org.freeplane.features.map.NodeModel) Action(javax.swing.Action) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) IIconInformation(org.freeplane.features.icon.IIconInformation) ModeController(org.freeplane.features.mode.ModeController) IconSelectionPopupDialog(org.freeplane.core.ui.components.IconSelectionPopupDialog) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController)

Example 3 with IIconInformation

use of org.freeplane.features.icon.IIconInformation 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.getTranslationValueLabel());
                keyProperty.setIcon(info.getIcon());
                keyProperty.disableModifiers();
                return keyProperty;
            }
        }, IndexedTree.AS_CHILD);
    }
}
Also used : IPropertyControlCreator(org.freeplane.core.resources.components.IPropertyControlCreator) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) OptionPanelBuilder(org.freeplane.core.resources.components.OptionPanelBuilder) ArrayList(java.util.ArrayList) IIconInformation(org.freeplane.features.icon.IIconInformation) IPropertyControl(org.freeplane.core.resources.components.IPropertyControl) KeyProperty(org.freeplane.core.resources.components.KeyProperty) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 4 with IIconInformation

use of org.freeplane.features.icon.IIconInformation in project freeplane by freeplane.

the class IconSelectionPopupDialog method select.

private void select(final Position position) {
    unhighlight(getSelectedPosition());
    setSelectedPosition(position);
    highlight(position);
    final int index = calculateIndex(position);
    final IIconInformation iconInformation = icons.get(index);
    final String keyStroke = ResourceController.getResourceController().getProperty(iconInformation.getShortcutKey());
    if (keyStroke != null) {
        descriptionLabel.setText(iconInformation.getTranslationValueLabel() + ", " + keyStroke);
    } else {
        descriptionLabel.setText(iconInformation.getTranslationValueLabel());
    }
}
Also used : IIconInformation(org.freeplane.features.icon.IIconInformation)

Aggregations

IIconInformation (org.freeplane.features.icon.IIconInformation)4 ArrayList (java.util.ArrayList)2 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)2 ActionEvent (java.awt.event.ActionEvent)1 Action (javax.swing.Action)1 KeyStroke (javax.swing.KeyStroke)1 IPropertyControl (org.freeplane.core.resources.components.IPropertyControl)1 IPropertyControlCreator (org.freeplane.core.resources.components.IPropertyControlCreator)1 KeyProperty (org.freeplane.core.resources.components.KeyProperty)1 OptionPanelBuilder (org.freeplane.core.resources.components.OptionPanelBuilder)1 IconSelectionPopupDialog (org.freeplane.core.ui.components.IconSelectionPopupDialog)1 IconController (org.freeplane.features.icon.IconController)1 NodeModel (org.freeplane.features.map.NodeModel)1 Controller (org.freeplane.features.mode.Controller)1 ModeController (org.freeplane.features.mode.ModeController)1 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)1