Search in sources :

Example 1 with IconSelectionPopupDialog

use of org.freeplane.core.ui.components.IconSelectionPopupDialog 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 2 with IconSelectionPopupDialog

use of org.freeplane.core.ui.components.IconSelectionPopupDialog in project freeplane by freeplane.

the class IconProperty method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final List<MindIcon> icons = new ArrayList<MindIcon>();
    final List<String> descriptions = new ArrayList<String>();
    for (final MindIcon icon : mIcons) {
        icons.add(icon);
        descriptions.add(icon.getTranslationValueLabel());
    }
    final IconSelectionPopupDialog dialog = new IconSelectionPopupDialog(JOptionPane.getFrameForComponent((Component) e.getSource()), icons);
    dialog.setLocationRelativeTo(JOptionPane.getFrameForComponent((Component) e.getSource()));
    dialog.setModal(true);
    dialog.setVisible(true);
    final int result = dialog.getResult();
    if (result >= 0) {
        final MindIcon icon = mIcons.get(result);
        setValue(icon.getName());
        firePropertyChangeEvent();
    }
}
Also used : ArrayList(java.util.ArrayList) MindIcon(org.freeplane.features.icon.MindIcon) IconSelectionPopupDialog(org.freeplane.core.ui.components.IconSelectionPopupDialog) Component(java.awt.Component)

Aggregations

ArrayList (java.util.ArrayList)2 IconSelectionPopupDialog (org.freeplane.core.ui.components.IconSelectionPopupDialog)2 Component (java.awt.Component)1 ActionEvent (java.awt.event.ActionEvent)1 Action (javax.swing.Action)1 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)1 IIconInformation (org.freeplane.features.icon.IIconInformation)1 IconController (org.freeplane.features.icon.IconController)1 MindIcon (org.freeplane.features.icon.MindIcon)1 NodeModel (org.freeplane.features.map.NodeModel)1 Controller (org.freeplane.features.mode.Controller)1 ModeController (org.freeplane.features.mode.ModeController)1