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