Search in sources :

Example 1 with IconRibbonBandResizePolicy

use of org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy in project freeplane by freeplane.

the class ZoomContributorFactory 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;
            }
            JFlowRibbonBand band = new JFlowRibbonBand(TextUtils.removeTranslateComment(TextUtils.getText("ribbon.band.zoom")), null, null);
            JComboBox zoomBox = ((MapViewController) Controller.getCurrentController().getMapViewManager()).createZoomBox();
            addDefaultToggleHandler(context, zoomBox);
            band.addFlowComponent(zoomBox);
            JCommandButtonStrip strip = new JCommandButtonStrip();
            AFreeplaneAction action = context.getBuilder().getMode().getAction("ZoomInAction");
            JCommandButton button = RibbonActionContributorFactory.createCommandButton(action);
            button.setDisplayState(CommandButtonDisplayState.SMALL);
            getAccelChangeListener().addAction(action.getKey(), button);
            addDefaultToggleHandler(context, action, button);
            strip.add(button);
            action = context.getBuilder().getMode().getAction("ZoomOutAction");
            button = RibbonActionContributorFactory.createCommandButton(action);
            button.setDisplayState(CommandButtonDisplayState.SMALL);
            getAccelChangeListener().addAction(action.getKey(), button);
            addDefaultToggleHandler(context, action, button);
            strip.add(button);
            action = context.getBuilder().getMode().getAction("FitToPage");
            button = RibbonActionContributorFactory.createCommandButton(action);
            button.setDisplayState(CommandButtonDisplayState.MEDIUM);
            getAccelChangeListener().addAction(action.getKey(), button);
            addDefaultToggleHandler(context, action, button);
            strip.add(button);
            band.addFlowComponent(strip);
            List<RibbonBandResizePolicy> policies = new ArrayList<RibbonBandResizePolicy>();
            policies.add(new CoreRibbonResizePolicies.FlowTwoRows(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) CoreRibbonResizePolicies(org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies) JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) IconRibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy) JCommandButton(org.pushingpixels.flamingo.api.common.JCommandButton) MapViewController(org.freeplane.view.swing.map.MapViewController) JFlowRibbonBand(org.pushingpixels.flamingo.api.ribbon.JFlowRibbonBand) IconRibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy) RibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) RibbonBuildContext(org.freeplane.core.ui.ribbon.RibbonBuildContext) JCommandButtonStrip(org.pushingpixels.flamingo.api.common.JCommandButtonStrip)

Example 2 with IconRibbonBandResizePolicy

use of org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy in project freeplane by freeplane.

the class FlowRibbonBandContributorFactory method getContributor.

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

        private JFlowRibbonBand band;

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

        public void contribute(RibbonBuildContext context, ARibbonContributor parent) {
            if (parent == null) {
                return;
            }
            band = new JFlowRibbonBand(TextUtils.removeTranslateComment(TextUtils.getText("ribbon.band." + attributes.getProperty("name"))), null);
            RibbonBandResizePolicy policy = band.getCurrentResizePolicy();
            band.setCurrentResizePolicy(policy);
            // read policies and sub-contributions
            context.processChildren(context.getCurrentPath(), this);
            parent.addChild(band, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
            List<RibbonBandResizePolicy> policies = new ArrayList<RibbonBandResizePolicy>();
            policies.add(new CoreRibbonResizePolicies.FlowThreeRows(band.getControlPanel()));
            policies.add(new IconRibbonBandResizePolicy(band.getControlPanel()));
            band.setResizePolicies(policies);
        }

        public void addChild(Object child, ChildProperties properties) {
            if (child instanceof JComponent) {
                band.addFlowComponent((JComponent) child);
            }
        }
    };
}
Also used : JFlowRibbonBand(org.pushingpixels.flamingo.api.ribbon.JFlowRibbonBand) RibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy) IconRibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy) CoreRibbonResizePolicies(org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies) ArrayList(java.util.ArrayList) JComponent(javax.swing.JComponent) IconRibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy)

Example 3 with IconRibbonBandResizePolicy

use of org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy in project freeplane by freeplane.

the class RibbonBandContributorFactory method getContributor.

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

        private JRibbonBand band;

        private boolean valid = false;

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

        public void contribute(RibbonBuildContext context, ARibbonContributor parent) {
            if (parent == null) {
                return;
            }
            band = new JRibbonBand(TextUtils.removeTranslateComment(TextUtils.getText("ribbon.band." + attributes.getProperty("name"))), null);
            // read policies and sub-contributions
            context.processChildren(context.getCurrentPath(), this);
            setResizePolicies(attributes.getProperty("resize_policies"));
            band.setFocusable(false);
            if (valid) {
                parent.addChild(band, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
            }
        }

        public void addChild(Object child, ChildProperties properties) {
            if (child instanceof AbstractCommandButton) {
                RibbonElementPriority priority = properties.get(RibbonElementPriority.class);
                if (priority == null) {
                    priority = RibbonElementPriority.TOP;
                }
                band.addCommandButton((AbstractCommandButton) child, priority);
                valid = true;
            }
        }

        private void setResizePolicies(String policiesString) {
            if (policiesString != null) {
                String[] tokens = policiesString.split(",");
                List<RibbonBandResizePolicy> policyList = new ArrayList<RibbonBandResizePolicy>();
                for (String policyStr : tokens) {
                    if ("none".equals(policyStr.toLowerCase().trim())) {
                        policyList.add(new CoreRibbonResizePolicies.None(band.getControlPanel()));
                    } else if ("mirror".equals(policyStr.toLowerCase().trim())) {
                        policyList.add(new CoreRibbonResizePolicies.Mirror(band.getControlPanel()));
                    } else if ("high2low".equals(policyStr.toLowerCase().trim())) {
                        policyList.add(new CoreRibbonResizePolicies.High2Low(band.getControlPanel()));
                    } else if ("high2mid".equals(policyStr.toLowerCase().trim())) {
                        policyList.add(new CoreRibbonResizePolicies.High2Mid(band.getControlPanel()));
                    } else if ("mid2low".equals(policyStr.toLowerCase().trim())) {
                        policyList.add(new CoreRibbonResizePolicies.Mid2Low(band.getControlPanel()));
                    } else if ("mid2mid".equals(policyStr.toLowerCase().trim())) {
                        policyList.add(new CoreRibbonResizePolicies.Mid2Mid(band.getControlPanel()));
                    } else if ("low2mid".equals(policyStr.toLowerCase().trim())) {
                        policyList.add(new CoreRibbonResizePolicies.Low2Mid(band.getControlPanel()));
                    }
                }
                policyList.add(new IconRibbonBandResizePolicy(band.getControlPanel()));
                band.setResizePolicies(policyList);
                try {
                    FlamingoUtilities.checkResizePoliciesConsistency(band);
                } catch (Exception ignore) {
                    reorganizePolicies(band, true);
                }
            }
        }
    };
}
Also used : CoreRibbonResizePolicies(org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies) ArrayList(java.util.ArrayList) IconRibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy) RibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy) IconRibbonBandResizePolicy(org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy) RibbonElementPriority(org.pushingpixels.flamingo.api.ribbon.RibbonElementPriority) JRibbonBand(org.pushingpixels.flamingo.api.ribbon.JRibbonBand) AbstractCommandButton(org.pushingpixels.flamingo.api.common.AbstractCommandButton)

Example 4 with IconRibbonBandResizePolicy

use of org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy 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)

Aggregations

ArrayList (java.util.ArrayList)4 CoreRibbonResizePolicies (org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies)4 IconRibbonBandResizePolicy (org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy)4 RibbonBandResizePolicy (org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy)4 JFlowRibbonBand (org.pushingpixels.flamingo.api.ribbon.JFlowRibbonBand)3 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)2 ARibbonContributor (org.freeplane.core.ui.ribbon.ARibbonContributor)2 RibbonBuildContext (org.freeplane.core.ui.ribbon.RibbonBuildContext)2 JCommandButton (org.pushingpixels.flamingo.api.common.JCommandButton)2 JCommandButtonStrip (org.pushingpixels.flamingo.api.common.JCommandButtonStrip)2 Container (java.awt.Container)1 JComboBox (javax.swing.JComboBox)1 JComponent (javax.swing.JComponent)1 MUIFactory (org.freeplane.features.styles.mindmapmode.MUIFactory)1 MapViewController (org.freeplane.view.swing.map.MapViewController)1 AbstractCommandButton (org.pushingpixels.flamingo.api.common.AbstractCommandButton)1 JCommandToggleButton (org.pushingpixels.flamingo.api.common.JCommandToggleButton)1 JRibbonBand (org.pushingpixels.flamingo.api.ribbon.JRibbonBand)1 JRibbonComponent (org.pushingpixels.flamingo.api.ribbon.JRibbonComponent)1 RibbonElementPriority (org.pushingpixels.flamingo.api.ribbon.RibbonElementPriority)1