Search in sources :

Example 56 with AFreeplaneAction

use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.

the class FontStyleContributorFactory method getContributor.

public ARibbonContributor getContributor(final Properties attributes) {
    return new ARibbonContributor() {

        public String getKey() {
            return attributes.getProperty("name");
        }

        public void contribute(final RibbonBuildContext context, ARibbonContributor parent) {
            setAccelerator(context.getBuilder(), "control B", "BoldAction");
            setAccelerator(context.getBuilder(), "control I", "ItalicAction");
            setAccelerator(context.getBuilder(), "control PLUS", "IncreaseNodeFontAction");
            setAccelerator(context.getBuilder(), "control MINUS", "DecreaseNodeFontAction");
            setAccelerator(context.getBuilder(), "alt shift F", "NodeColorAction");
            setAccelerator(context.getBuilder(), "alt shift P", "UsePlainTextAction");
            if (parent == null) {
                return;
            }
            // RIBBONS expandlistener and icon
            JFlowRibbonBand band = new JFlowRibbonBand(TextUtils.removeTranslateComment(TextUtils.getText("ribbon.band.font")), null, null);
            band.setExpandButtonKeyTip("FN");
            band.setCollapsedStateKeyTip("ZF");
            MUIFactory uiFactory = Controller.getCurrentModeController().getExtension(MUIFactory.class);
            final Container fontBox = uiFactory.createFontBox();
            JRibbonComponent fontComboWrapper = new JRibbonComponent((JComponent) fontBox);
            fontComboWrapper.setKeyTip("SF");
            addDefaultToggleHandler(context, fontComboWrapper);
            band.addFlowComponent(fontComboWrapper);
            final Container sizeBox = uiFactory.createSizeBox();
            JRibbonComponent sizeComboWrapper = new JRibbonComponent((JComponent) sizeBox);
            sizeComboWrapper.setKeyTip("SS");
            addDefaultToggleHandler(context, sizeComboWrapper);
            band.addFlowComponent(sizeComboWrapper);
            final Container styleBox = uiFactory.createStyleBox();
            JRibbonComponent styleComboWrapper = new JRibbonComponent((JComponent) styleBox);
            styleComboWrapper.setKeyTip("SD");
            addDefaultToggleHandler(context, styleComboWrapper);
            band.addFlowComponent(styleComboWrapper);
            JCommandButtonStrip styleStrip = new JCommandButtonStrip();
            AFreeplaneAction action = context.getBuilder().getMode().getAction("BoldAction");
            final JCommandToggleButton boldButton = RibbonActionContributorFactory.createCommandToggleButton(action);
            addDefaultToggleHandler(context, action, boldButton);
            styleStrip.add(boldButton);
            action = context.getBuilder().getMode().getAction("ItalicAction");
            final JCommandToggleButton italicButton = RibbonActionContributorFactory.createCommandToggleButton(action);
            addDefaultToggleHandler(context, action, italicButton);
            styleStrip.add(italicButton);
            action = context.getBuilder().getMode().getAction("NodeColorAction");
            JCommandButton button = RibbonActionContributorFactory.createCommandButton(action);
            addDefaultToggleHandler(context, action, button);
            styleStrip.add(button);
            action = context.getBuilder().getMode().getAction("NodeBackgroundColorAction");
            button = RibbonActionContributorFactory.createCommandButton(action);
            addDefaultToggleHandler(context, action, button);
            styleStrip.add(button);
            action = context.getBuilder().getMode().getAction("NodeColorBlendAction");
            button = RibbonActionContributorFactory.createCommandButton(action);
            addDefaultToggleHandler(context, action, button);
            styleStrip.add(button);
            action = context.getBuilder().getMode().getAction("BlinkingNodeHookAction");
            button = RibbonActionContributorFactory.createCommandButton(action);
            addDefaultToggleHandler(context, action, button);
            styleStrip.add(button);
            action = context.getBuilder().getMode().getAction("MapBackgroundColorAction");
            button = RibbonActionContributorFactory.createCommandButton(action);
            addDefaultToggleHandler(context, action, button);
            styleStrip.add(button);
            band.addFlowComponent(styleStrip);
            action = context.getBuilder().getMode().getAction("RemoveFormatAction");
            button = RibbonActionContributorFactory.createCommandButton(action);
            button.setDisplayState(CommandButtonDisplayState.MEDIUM);
            addDefaultToggleHandler(context, action, button);
            band.addFlowComponent(button);
            action = context.getBuilder().getMode().getAction("UsePlainTextAction");
            button = RibbonActionContributorFactory.createCommandButton(action);
            button.setDisplayState(CommandButtonDisplayState.MEDIUM);
            addDefaultToggleHandler(context, action, button);
            band.addFlowComponent(button);
            List<RibbonBandResizePolicy> policies = new ArrayList<RibbonBandResizePolicy>();
            policies.add(new CoreRibbonResizePolicies.FlowThreeRows(band.getControlPanel()));
            policies.add(new IconRibbonBandResizePolicy(band.getControlPanel()));
            band.setResizePolicies(policies);
            parent.addChild(band, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
        }

        public void addChild(Object child, ChildProperties properties) {
        }
    };
}
Also used : ARibbonContributor(org.freeplane.core.ui.ribbon.ARibbonContributor) MUIFactory(org.freeplane.features.styles.mindmapmode.MUIFactory) CoreRibbonResizePolicies(org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies) ArrayList(java.util.ArrayList) IconRibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy) JCommandButton(org.pushingpixels.flamingo.api.common.JCommandButton) JFlowRibbonBand(org.pushingpixels.flamingo.api.ribbon.JFlowRibbonBand) JRibbonComponent(org.pushingpixels.flamingo.api.ribbon.JRibbonComponent) IconRibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy) RibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy) Container(java.awt.Container) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) JCommandToggleButton(org.pushingpixels.flamingo.api.common.JCommandToggleButton) RibbonBuildContext(org.freeplane.core.ui.ribbon.RibbonBuildContext) JCommandButtonStrip(org.pushingpixels.flamingo.api.common.JCommandButtonStrip)

Example 57 with AFreeplaneAction

use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.

the class FilterConditionsContributorFactory method getContributor.

public ARibbonContributor getContributor(final Properties attributes) {
    return new ARibbonContributor() {

        public String getKey() {
            return attributes.getProperty("name");
        }

        public void contribute(final RibbonBuildContext context, ARibbonContributor parent) {
            if (parent == null) {
                return;
            }
            JCommandButton button = new JCommandButton(TextUtils.removeTranslateComment(TextUtils.getText("FilterCondition")));
            button.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
            button.setPopupCallback(new PopupPanelCallback() {

                public JPopupPanel getPopupPanel(JCommandButton commandButton) {
                    JCommandPopupMenu popupmenu = new JCommandPopupMenu();
                    AFreeplaneAction action = context.getBuilder().getMode().getAction("ApplyToVisibleAction");
                    JCommandToggleMenuButton toggleButton = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
                    action.setSelected();
                    toggleButton.getActionModel().setSelected(action.isSelected());
                    popupmenu.addMenuButton(toggleButton);
                    action = context.getBuilder().getMode().getAction("ShowAncestorsAction");
                    toggleButton = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
                    action.setSelected();
                    toggleButton.getActionModel().setSelected(action.isSelected());
                    popupmenu.addMenuButton(toggleButton);
                    action = context.getBuilder().getMode().getAction("ShowDescendantsAction");
                    toggleButton = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
                    action.setSelected();
                    toggleButton.getActionModel().setSelected(action.isSelected());
                    popupmenu.addMenuButton(toggleButton);
                    return popupmenu;
                }
            });
            ChildProperties props = new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", "")));
            props.set(RibbonElementPriority.class, RibbonElementPriority.MEDIUM);
            parent.addChild(button, props);
        }

        public void addChild(Object child, ChildProperties properties) {
        }
    };
}
Also used : ARibbonContributor(org.freeplane.core.ui.ribbon.ARibbonContributor) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) JCommandToggleMenuButton(org.pushingpixels.flamingo.api.common.JCommandToggleMenuButton) JCommandPopupMenu(org.pushingpixels.flamingo.api.common.popup.JCommandPopupMenu) PopupPanelCallback(org.pushingpixels.flamingo.api.common.popup.PopupPanelCallback) JPopupPanel(org.pushingpixels.flamingo.api.common.popup.JPopupPanel) JCommandButton(org.pushingpixels.flamingo.api.common.JCommandButton) RibbonBuildContext(org.freeplane.core.ui.ribbon.RibbonBuildContext)

Example 58 with AFreeplaneAction

use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.

the class ViewSettingsContributorFactory method getContributor.

public ARibbonContributor getContributor(final Properties attributes) {
    return new ARibbonContributor() {

        public String getKey() {
            return attributes.getProperty("name");
        }

        public void contribute(final RibbonBuildContext context, ARibbonContributor parent) {
            if (parent == null) {
                return;
            }
            JRibbonBand band = new JRibbonBand(TextUtils.removeTranslateComment(TextUtils.getText("ribbon.band.viewsettings")), null, null);
            createAttributeViewMenu(context, band);
            createNoteViewMenu(context, band);
            createToolTipMenu(context, band);
            createToolbarsMenu(context, band);
            List<RibbonBandResizePolicy> policies = new ArrayList<RibbonBandResizePolicy>();
            policies.add(new CoreRibbonResizePolicies.Mirror(band.getControlPanel()));
            policies.add(new CoreRibbonResizePolicies.High2Low(band.getControlPanel()));
            band.setResizePolicies(policies);
            parent.addChild(band, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
        }

        private void createToolbarsMenu(final RibbonBuildContext context, JRibbonBand band) {
            JCommandButton button = new JCommandButton(TextUtils.removeTranslateComment(TextUtils.getText("menu_toolbars")));
            button.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
            button.setPopupCallback(new PopupPanelCallback() {

                public JPopupPanel getPopupPanel(JCommandButton commandButton) {
                    JCommandPopupMenu popupmenu = new JCommandPopupMenu();
                    final AFreeplaneAction toggleFBarAction = context.getBuilder().getMode().getAction("ToggleFBarAction");
                    final JCommandToggleMenuButton toggleFBarButton = RibbonActionContributorFactory.createCommandToggleMenuButton(toggleFBarAction);
                    toggleFBarAction.setSelected();
                    toggleFBarButton.getActionModel().setSelected(toggleFBarAction.isSelected());
                    popupmenu.addMenuButton(toggleFBarButton);
                    final AFreeplaneAction toggleLeftToolbarAction = context.getBuilder().getMode().getAction("ToggleLeftToolbarAction");
                    final JCommandToggleMenuButton toggleLeftToolbarButton = RibbonActionContributorFactory.createCommandToggleMenuButton(toggleLeftToolbarAction);
                    toggleLeftToolbarAction.setSelected();
                    toggleLeftToolbarButton.getActionModel().setSelected(toggleLeftToolbarAction.isSelected());
                    popupmenu.addMenuButton(toggleLeftToolbarButton);
                    final AFreeplaneAction toggleStatusAction = context.getBuilder().getMode().getAction("ToggleStatusAction");
                    final JCommandToggleMenuButton toggleStatusButton = RibbonActionContributorFactory.createCommandToggleMenuButton(toggleStatusAction);
                    toggleStatusAction.setSelected();
                    toggleStatusButton.getActionModel().setSelected(toggleStatusAction.isSelected());
                    popupmenu.addMenuButton(toggleStatusButton);
                    final AFreeplaneAction toggleScrollbarsAction = context.getBuilder().getMode().getAction("ToggleScrollbarsAction");
                    final JCommandToggleMenuButton toggleScrollbarsButton = RibbonActionContributorFactory.createCommandToggleMenuButton(toggleScrollbarsAction);
                    toggleScrollbarsAction.setSelected();
                    toggleScrollbarsButton.getActionModel().setSelected(toggleScrollbarsAction.isSelected());
                    popupmenu.addMenuButton(toggleScrollbarsButton);
                    return popupmenu;
                }
            });
            band.addCommandButton(button, RibbonElementPriority.MEDIUM);
            AFreeplaneAction action = context.getBuilder().getMode().getAction("SetShortenerStateAction");
            button = RibbonActionContributorFactory.createCommandButton(action);
            band.addCommandButton(button, RibbonElementPriority.MEDIUM);
            action = context.getBuilder().getMode().getAction("ToggleDetailsAction");
            button = RibbonActionContributorFactory.createCommandButton(action);
            band.addCommandButton(button, RibbonElementPriority.MEDIUM);
        }

        private void createToolTipMenu(final RibbonBuildContext context, final JRibbonBand band) {
            JCommandButton button = new JCommandButton(TextUtils.removeTranslateComment(TextUtils.getText("menu_hoverView")));
            button.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
            button.setPopupCallback(new PopupPanelCallback() {

                public JPopupPanel getPopupPanel(JCommandButton commandButton) {
                    JCommandPopupMenu popupmenu = new JCommandPopupMenu();
                    final SetBooleanPropertyAction showAction = (SetBooleanPropertyAction) context.getBuilder().getMode().getAction("SetBooleanPropertyAction.show_node_tooltips");
                    final JCommandToggleMenuButton showButton = RibbonActionContributorFactory.createCommandToggleMenuButton(showAction);
                    showAction.setSelected();
                    showButton.getActionModel().setSelected(showAction.isSelected());
                    popupmenu.addMenuButton(showButton);
                    final SetBooleanPropertyAction showStylesAction = (SetBooleanPropertyAction) context.getBuilder().getMode().getAction("SetBooleanPropertyAction.show_styles_in_tooltip");
                    final JCommandToggleMenuButton showStylesButton = RibbonActionContributorFactory.createCommandToggleMenuButton(showStylesAction);
                    showStylesAction.setSelected();
                    showStylesButton.getActionModel().setSelected(showStylesAction.isSelected());
                    popupmenu.addMenuButton(showStylesButton);
                    final AFreeplaneAction modificationAction = context.getBuilder().getMode().getAction("CreationModificationPluginAction");
                    final JCommandToggleMenuButton modificationButton = RibbonActionContributorFactory.createCommandToggleMenuButton(modificationAction);
                    modificationAction.setSelected();
                    modificationButton.getActionModel().setSelected(modificationAction.isSelected());
                    popupmenu.addMenuButton(modificationButton);
                    return popupmenu;
                }
            });
            band.addCommandButton(button, RibbonElementPriority.MEDIUM);
        }

        private void createNoteViewMenu(final RibbonBuildContext context, final JRibbonBand band) {
            JCommandButton displayNotesButton = new JCommandButton(TextUtils.removeTranslateComment(TextUtils.getText("menu_noteView")));
            displayNotesButton.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
            displayNotesButton.setPopupCallback(new PopupPanelCallback() {

                public JPopupPanel getPopupPanel(JCommandButton commandButton) {
                    JCommandPopupMenu popupmenu = new JCommandPopupMenu();
                    final ShowNotesInMapAction showNotesInMapAction = (ShowNotesInMapAction) context.getBuilder().getMode().getAction("ShowNotesInMapAction");
                    final JCommandToggleMenuButton showNotedsInMapButton = RibbonActionContributorFactory.createCommandToggleMenuButton(showNotesInMapAction);
                    showNotesInMapAction.setSelected();
                    showNotedsInMapButton.getActionModel().setSelected(showNotesInMapAction.isSelected());
                    popupmenu.addMenuButton(showNotedsInMapButton);
                    final SetBooleanMapPropertyAction showIconAction = (SetBooleanMapPropertyAction) context.getBuilder().getMode().getAction("SetBooleanMapPropertyAction.show_note_icons");
                    final JCommandToggleMenuButton toggleButton = RibbonActionContributorFactory.createCommandToggleMenuButton(showIconAction);
                    showIconAction.setSelected();
                    toggleButton.getActionModel().setSelected(showIconAction.isSelected());
                    popupmenu.addMenuButton(toggleButton);
                    JCommandMenuButton button = new JCommandMenuButton(TextUtils.removeTranslateComment(TextUtils.getText("note_window_location")), null);
                    button.setDisplayState(CommandButtonDisplayState.MEDIUM);
                    button.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
                    button.setPopupCallback(new PopupPanelCallback() {

                        public JPopupPanel getPopupPanel(JCommandButton commandButton) {
                            JCommandPopupMenu popupmenu = new JCommandPopupMenu();
                            final SetNoteWindowPosition posTopAction = (SetNoteWindowPosition) context.getBuilder().getMode().getAction("SetNoteWindowPosition.top");
                            final JCommandToggleMenuButton posTopButton = RibbonActionContributorFactory.createCommandToggleMenuButton(posTopAction);
                            popupmenu.addMenuButton(posTopButton);
                            posTopAction.setSelected();
                            posTopButton.getActionModel().setSelected(posTopAction.isSelected());
                            final SetNoteWindowPosition posLeftAction = (SetNoteWindowPosition) context.getBuilder().getMode().getAction("SetNoteWindowPosition.left");
                            final JCommandToggleMenuButton posLeftButton = RibbonActionContributorFactory.createCommandToggleMenuButton(posLeftAction);
                            popupmenu.addMenuButton(posLeftButton);
                            posLeftAction.setSelected();
                            posLeftButton.getActionModel().setSelected(posLeftAction.isSelected());
                            final SetNoteWindowPosition posRightAction = (SetNoteWindowPosition) context.getBuilder().getMode().getAction("SetNoteWindowPosition.right");
                            final JCommandToggleMenuButton posRightButton = RibbonActionContributorFactory.createCommandToggleMenuButton(posRightAction);
                            popupmenu.addMenuButton(posRightButton);
                            posRightAction.setSelected();
                            posRightButton.getActionModel().setSelected(posRightAction.isSelected());
                            final SetNoteWindowPosition posBottomAction = (SetNoteWindowPosition) context.getBuilder().getMode().getAction("SetNoteWindowPosition.bottom");
                            final JCommandToggleMenuButton posBottomButton = RibbonActionContributorFactory.createCommandToggleMenuButton(posBottomAction);
                            popupmenu.addMenuButton(posBottomButton);
                            posBottomAction.setSelected();
                            posBottomButton.getActionModel().setSelected(posBottomAction.isSelected());
                            return popupmenu;
                        }
                    });
                    popupmenu.addMenuButton(button);
                    return popupmenu;
                }
            });
            band.addCommandButton(displayNotesButton, RibbonElementPriority.MEDIUM);
        }

        private void createAttributeViewMenu(final RibbonBuildContext context, JRibbonBand band) {
            JCommandButton button = new JCommandButton(TextUtils.removeTranslateComment(TextUtils.getText("menu_displayAttributes")));
            button.setDisplayState(CommandButtonDisplayState.MEDIUM);
            button.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
            button.setPopupCallback(new PopupPanelCallback() {

                public JPopupPanel getPopupPanel(JCommandButton commandButton) {
                    JCommandPopupMenu popupmenu = new JCommandPopupMenu();
                    final AttributeViewTypeAction showSelectedAttributesAction = (AttributeViewTypeAction) context.getBuilder().getMode().getAction("ShowSelectedAttributesAction");
                    final JCommandToggleMenuButton showSelectedAttributesButton = RibbonActionContributorFactory.createCommandToggleMenuButton(showSelectedAttributesAction);
                    popupmenu.addMenuButton(showSelectedAttributesButton);
                    showSelectedAttributesAction.setSelected();
                    showSelectedAttributesButton.getActionModel().setSelected(showSelectedAttributesAction.isSelected());
                    final AttributeViewTypeAction showAllAttributesAction = (AttributeViewTypeAction) context.getBuilder().getMode().getAction("ShowAllAttributesAction");
                    final JCommandToggleMenuButton showAllAttributesButton = RibbonActionContributorFactory.createCommandToggleMenuButton(showAllAttributesAction);
                    popupmenu.addMenuButton(showAllAttributesButton);
                    showAllAttributesAction.setSelected();
                    showAllAttributesButton.getActionModel().setSelected(showAllAttributesAction.isSelected());
                    final AttributeViewTypeAction hideAllAttributesAction = (AttributeViewTypeAction) context.getBuilder().getMode().getAction("HideAllAttributesAction");
                    final JCommandToggleMenuButton hideAllAttributesButton = RibbonActionContributorFactory.createCommandToggleMenuButton(hideAllAttributesAction);
                    popupmenu.addMenuButton(hideAllAttributesButton);
                    hideAllAttributesAction.setSelected();
                    hideAllAttributesButton.getActionModel().setSelected(hideAllAttributesAction.isSelected());
                    final SetBooleanMapPropertyAction showIconAction = (SetBooleanMapPropertyAction) context.getBuilder().getMode().getAction("SetBooleanMapPropertyAction.show_icon_for_attributes");
                    final JCommandToggleMenuButton toggleButton = RibbonActionContributorFactory.createCommandToggleMenuButton(showIconAction);
                    showIconAction.setSelected();
                    toggleButton.getActionModel().setSelected(showIconAction.isSelected());
                    popupmenu.addMenuButton(toggleButton);
                    context.getBuilder().getMapChangeAdapter().addListener(new IChangeObserver() {

                        public void updateState(CurrentState state) {
                            showSelectedAttributesAction.setSelected();
                            showSelectedAttributesButton.getActionModel().setSelected(showSelectedAttributesAction.isSelected());
                            showAllAttributesAction.setSelected();
                            showAllAttributesButton.getActionModel().setSelected(showAllAttributesAction.isSelected());
                            hideAllAttributesAction.setSelected();
                            hideAllAttributesButton.getActionModel().setSelected(hideAllAttributesAction.isSelected());
                            showIconAction.setSelected();
                            toggleButton.getActionModel().setSelected(showIconAction.isSelected());
                        }
                    });
                    JCommandMenuButton button = RibbonActionContributorFactory.createCommandMenuButton(context.getBuilder().getMode().getAction("ShowAttributeDialogAction"));
                    popupmenu.addMenuButton(button);
                    return popupmenu;
                }
            });
            band.addCommandButton(button, RibbonElementPriority.MEDIUM);
        }

        public void addChild(Object child, ChildProperties properties) {
        }
    };
}
Also used : CoreRibbonResizePolicies(org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies) ArrayList(java.util.ArrayList) JPopupPanel(org.pushingpixels.flamingo.api.common.popup.JPopupPanel) JCommandButton(org.pushingpixels.flamingo.api.common.JCommandButton) RibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy) JCommandMenuButton(org.pushingpixels.flamingo.api.common.JCommandMenuButton) IChangeObserver(org.freeplane.core.ui.ribbon.IChangeObserver) JCommandPopupMenu(org.pushingpixels.flamingo.api.common.popup.JCommandPopupMenu) CurrentState(org.freeplane.core.ui.ribbon.CurrentState) RibbonBuildContext(org.freeplane.core.ui.ribbon.RibbonBuildContext) ARibbonContributor(org.freeplane.core.ui.ribbon.ARibbonContributor) JCommandToggleMenuButton(org.pushingpixels.flamingo.api.common.JCommandToggleMenuButton) SetBooleanMapPropertyAction(org.freeplane.features.styles.mindmapmode.SetBooleanMapPropertyAction) SetNoteWindowPosition(org.freeplane.features.note.mindmapmode.SetNoteWindowPosition) PopupPanelCallback(org.pushingpixels.flamingo.api.common.popup.PopupPanelCallback) AttributeViewTypeAction(org.freeplane.features.attribute.AttributeViewTypeAction) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) SetBooleanPropertyAction(org.freeplane.core.resources.SetBooleanPropertyAction) JRibbonBand(org.pushingpixels.flamingo.api.ribbon.JRibbonBand) ShowNotesInMapAction(org.freeplane.view.swing.map.ShowNotesInMapAction)

Example 59 with AFreeplaneAction

use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.

the class MLinkController method createActionBox.

@SuppressWarnings("serial")
protected JComboBox createActionBox(AFreeplaneAction[] items) {
    final JComboBox box = new JComboBox();
    box.setEditable(false);
    box.setModel(new DefaultComboBoxModel(items));
    for (AFreeplaneAction item : items) {
        if (item.isSelected()) {
            box.setSelectedItem(item);
            break;
        }
    }
    box.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Action action = (Action) value;
            Icon icon = (Icon) action.getValue(Action.SMALL_ICON);
            String text = (String) action.getValue(Action.NAME);
            Object renderedValue = text == null ? icon : text;
            DefaultListCellRenderer renderer = (DefaultListCellRenderer) super.getListCellRendererComponent(list, renderedValue, index, isSelected, cellHasFocus);
            if (text != null && icon != null)
                renderer.setIcon(icon);
            return renderer;
        }
    });
    box.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            AFreeplaneAction item = (AFreeplaneAction) e.getItem();
            final JComboBox box = (JComboBox) e.getSource();
            item.actionPerformed(new ActionEvent(box, ActionEvent.ACTION_PERFORMED, null));
        }
    });
    return box;
}
Also used : Action(javax.swing.Action) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ItemEvent(java.awt.event.ItemEvent) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Point(java.awt.Point) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) ItemListener(java.awt.event.ItemListener) Icon(javax.swing.Icon) Component(java.awt.Component) JComponent(javax.swing.JComponent) JList(javax.swing.JList)

Example 60 with AFreeplaneAction

use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.

the class MLinkController method createArrowLinkPopup.

@Override
protected void createArrowLinkPopup(final ConnectorModel link, final JComponent arrowLinkPopup) {
    super.createArrowLinkPopup(link, arrowLinkPopup);
    addClosingAction(arrowLinkPopup, new RemoveConnectorAction(this, link));
    addSeparator(arrowLinkPopup);
    addAction(arrowLinkPopup, new ConnectorColorAction(this, link));
    final JSlider transparencySlider = new JSlider(20, 255, link.getAlpha());
    transparencySlider.setMinorTickSpacing(20);
    transparencySlider.setPaintTicks(true);
    transparencySlider.setSnapToTicks(true);
    transparencySlider.setPaintTrack(true);
    addPopupComponent(arrowLinkPopup, TextUtils.getText("edit_transparency_label"), transparencySlider);
    addSeparator(arrowLinkPopup);
    AFreeplaneAction[] arrowActions = new AFreeplaneAction[] { new ChangeConnectorArrowsAction(this, "none", link, ArrowType.NONE, ArrowType.NONE), new ChangeConnectorArrowsAction(this, "forward", link, ArrowType.NONE, ArrowType.DEFAULT), new ChangeConnectorArrowsAction(this, "backward", link, ArrowType.DEFAULT, ArrowType.NONE), new ChangeConnectorArrowsAction(this, "both", link, ArrowType.DEFAULT, ArrowType.DEFAULT) };
    final JComboBox connectorArrows = createActionBox(arrowActions);
    addPopupComponent(arrowLinkPopup, TextUtils.getText("connector_arrows"), connectorArrows);
    final boolean twoNodesConnector = !link.getSource().equals(link.getTarget());
    AFreeplaneAction[] shapeActions;
    if (twoNodesConnector) {
        shapeActions = new AFreeplaneAction[] { new ChangeConnectorShapeAction(this, link, Shape.CUBIC_CURVE), new ChangeConnectorShapeAction(this, link, Shape.LINE), new ChangeConnectorShapeAction(this, link, Shape.LINEAR_PATH), new ChangeConnectorShapeAction(this, link, Shape.EDGE_LIKE) };
    } else {
        shapeActions = new AFreeplaneAction[] { new ChangeConnectorShapeAction(this, link, Shape.CUBIC_CURVE), new ChangeConnectorShapeAction(this, link, Shape.LINE), new ChangeConnectorShapeAction(this, link, Shape.LINEAR_PATH) };
    }
    final JComboBox connectorShapes = createActionBox(shapeActions);
    addPopupComponent(arrowLinkPopup, TextUtils.getText("connector_shapes"), connectorShapes);
    AFreeplaneAction[] dashActions = new AFreeplaneAction[] { new ChangeConnectorDashAction(this, link, null), new ChangeConnectorDashAction(this, link, new int[] { 3, 3 }), new ChangeConnectorDashAction(this, link, new int[] { 7, 7 }), new ChangeConnectorDashAction(this, link, new int[] { 2, 7 }), new ChangeConnectorDashAction(this, link, new int[] { 2, 7, 7, 7 }) };
    final JComboBox connectorDashes = createActionBox(dashActions);
    addPopupComponent(arrowLinkPopup, TextUtils.getText("connector_lines"), connectorDashes);
    final SpinnerNumberModel widthModel = new SpinnerNumberModel(link.getWidth(), 1, 32, 1);
    final JSpinner widthSpinner = new JSpinner(widthModel);
    addPopupComponent(arrowLinkPopup, TextUtils.getText("edit_width_label"), widthSpinner);
    addSeparator(arrowLinkPopup);
    {
        final GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
        final String[] envFonts = gEnv.getAvailableFontFamilyNames();
        DefaultComboBoxModel fonts = new DefaultComboBoxModel(envFonts);
        fonts.setSelectedItem(link.getLabelFontFamily());
        JComboBox fontBox = new JComboBox(fonts);
        fontBox.setEditable(false);
        addPopupComponent(arrowLinkPopup, TextUtils.getText("edit_label_font_family"), fontBox);
        fontBox.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                final Object item = e.getItem();
                if (item != null)
                    setLabelFontFamily(link, item.toString());
            }
        });
    }
    {
        final Integer[] sizes = { 4, 6, 8, 10, 12, 14, 16, 18, 24, 36 };
        DefaultComboBoxModel sizesModel = new DefaultComboBoxModel(sizes);
        sizesModel.setSelectedItem(link.getLabelFontSize());
        JComboBox sizesBox = new JComboBox(sizesModel);
        sizesBox.setEditable(true);
        addPopupComponent(arrowLinkPopup, TextUtils.getText("edit_label_font_size"), sizesBox);
        sizesBox.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                final Object item = e.getItem();
                if (item != null) {
                    final int size;
                    if (item instanceof Integer)
                        size = (Integer) item;
                    else {
                        try {
                            size = Integer.valueOf(item.toString());
                            if (size <= 0)
                                return;
                        } catch (NumberFormatException ex) {
                            return;
                        }
                    }
                    setLabelFontSize(link, size);
                }
            }
        });
    }
    final JTextArea sourceLabelEditor;
    sourceLabelEditor = new JTextArea(link.getSourceLabel());
    addTextEditor(arrowLinkPopup, "edit_source_label", sourceLabelEditor);
    final JTextArea middleLabelEditor = new JTextArea(link.getMiddleLabel());
    addTextEditor(arrowLinkPopup, "edit_middle_label", middleLabelEditor);
    final JTextArea targetLabelEditor;
    targetLabelEditor = new JTextArea(link.getTargetLabel());
    addTextEditor(arrowLinkPopup, "edit_target_label", targetLabelEditor);
    arrowLinkPopup.addHierarchyListener(new HierarchyListener() {

        private Component focusOwner;

        private Window dialog;

        public void hierarchyChanged(HierarchyEvent e) {
            final JComponent component = (JComponent) e.getComponent();
            if (component.isShowing()) {
                if (dialog == null) {
                    dialog = SwingUtilities.getWindowAncestor(component);
                    dialog.addWindowListener(new WindowAdapter() {

                        @Override
                        public void windowClosing(WindowEvent e) {
                            component.putClientProperty(CANCEL, Boolean.TRUE);
                        }
                    });
                }
                if (focusOwner == null)
                    focusOwner = FocusManager.getCurrentManager().getFocusOwner();
                return;
            }
            if (focusOwner == null || !focusOwner.isShowing())
                return;
            focusOwner.requestFocus();
            if (Boolean.TRUE.equals(component.getClientProperty(CANCEL))) {
                return;
            }
            final IMapSelection selection = Controller.getCurrentController().getSelection();
            if (selection == null || selection.getSelected() == null)
                return;
            setSourceLabel(link, sourceLabelEditor.getText());
            setTargetLabel(link, targetLabelEditor.getText());
            setMiddleLabel(link, middleLabelEditor.getText());
            setAlpha(link, transparencySlider.getValue());
            setWidth(link, widthModel.getNumber().intValue());
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) JTextArea(javax.swing.JTextArea) IMapSelection(org.freeplane.features.map.IMapSelection) WindowAdapter(java.awt.event.WindowAdapter) HierarchyListener(java.awt.event.HierarchyListener) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JSlider(javax.swing.JSlider) Component(java.awt.Component) JComponent(javax.swing.JComponent) Window(java.awt.Window) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) GraphicsEnvironment(java.awt.GraphicsEnvironment) Point(java.awt.Point) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) HierarchyEvent(java.awt.event.HierarchyEvent) WindowEvent(java.awt.event.WindowEvent) JSpinner(javax.swing.JSpinner) ItemListener(java.awt.event.ItemListener)

Aggregations

AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)66 EntryAccessor (org.freeplane.core.ui.menubuilders.generic.EntryAccessor)23 Entry (org.freeplane.core.ui.menubuilders.generic.Entry)20 Test (org.junit.Test)20 Component (java.awt.Component)9 ArrayList (java.util.ArrayList)9 KeyStroke (javax.swing.KeyStroke)8 JCommandButton (org.pushingpixels.flamingo.api.common.JCommandButton)8 Container (java.awt.Container)6 ARibbonContributor (org.freeplane.core.ui.ribbon.ARibbonContributor)6 RibbonBuildContext (org.freeplane.core.ui.ribbon.RibbonBuildContext)6 Controller (org.freeplane.features.mode.Controller)6 ModeController (org.freeplane.features.mode.ModeController)6 ActionEvent (java.awt.event.ActionEvent)5 JMenuItem (javax.swing.JMenuItem)5 ResourceController (org.freeplane.core.resources.ResourceController)5 JComponent (javax.swing.JComponent)4 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)4 RichTooltip (org.pushingpixels.flamingo.api.common.RichTooltip)4 PopupPanelCallback (org.pushingpixels.flamingo.api.common.popup.PopupPanelCallback)4