Search in sources :

Example 1 with RibbonApplicationMenuEntryFooter

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

the class RibbonMenuFooterContributorFactory method getContributor.

/**
 *********************************************************************************
 * METHODS
 *********************************************************************************
 */
/**
 *********************************************************************************
 * REQUIRED METHODS FOR INTERFACES
 *********************************************************************************
 */
public ARibbonContributor getContributor(final Properties attributes) {
    String accel = attributes.getProperty("accelerator", null);
    final String actionKey = attributes.getProperty("action");
    if (actionKey != null) {
        if (accel != null) {
            if (Compat.isMacOsX()) {
                accel = accel.replaceFirst("CONTROL", "META").replaceFirst("control", "meta");
            }
            builder.getAcceleratorManager().setDefaultAccelerator(actionKey, accel);
        }
    }
    return new ARibbonContributor() {

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

        public void contribute(RibbonBuildContext context, ARibbonContributor parent) {
            final String key = attributes.getProperty("action");
            if (key != null) {
                AFreeplaneAction action = context.getBuilder().getMode().getAction(key);
                if (action != null) {
                    String title = ActionUtils.getActionTitle(action);
                    ResizableIcon icon = ActionUtils.getActionIcon(action);
                    ActionListener listener = new RibbonActionContributorFactory.RibbonActionListener(action);
                    final RibbonApplicationMenuEntryFooter entry = new RibbonApplicationMenuEntryFooter(icon, title, listener);
                    KeyStroke ks = context.getBuilder().getAcceleratorManager().getAccelerator(key);
                    if (ks != null) {
                        RichTooltip tip = RibbonActionContributorFactory.getRichTooltip(action, ks);
                        if (tip != null) {
                            entry.setActionRichTooltip(tip);
                        }
                    }
                    parent.addChild(entry, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
                }
            }
        }

        public void addChild(Object child, ChildProperties properties) {
        }
    };
}
Also used : RichTooltip(org.pushingpixels.flamingo.api.common.RichTooltip) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ActionListener(java.awt.event.ActionListener) KeyStroke(javax.swing.KeyStroke) RibbonApplicationMenuEntryFooter(org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryFooter) ResizableIcon(org.pushingpixels.flamingo.api.common.icon.ResizableIcon)

Example 2 with RibbonApplicationMenuEntryFooter

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

the class RibbonMenuContributorFactory method getContributor.

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

        private RibbonApplicationMenu menu;

        public String getKey() {
            return "app_menu";
        }

        public void contribute(RibbonBuildContext context, ARibbonContributor parent) {
            menu = new RibbonApplicationMenu();
            context.processChildren(context.getCurrentPath(), this);
            parent.addChild(menu, null);
        }

        public void addChild(Object child, ChildProperties properties) {
            if (child instanceof RibbonApplicationMenuEntryFooter) {
                menu.addFooterEntry((RibbonApplicationMenuEntryFooter) child);
            } else if (child instanceof RibbonApplicationMenuEntryPrimary) {
                menu.addMenuEntry((RibbonApplicationMenuEntryPrimary) child);
            }
        }
    };
}
Also used : RibbonApplicationMenu(org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenu) RibbonApplicationMenuEntryFooter(org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryFooter) RibbonApplicationMenuEntryPrimary(org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryPrimary)

Aggregations

RibbonApplicationMenuEntryFooter (org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryFooter)2 ActionListener (java.awt.event.ActionListener)1 KeyStroke (javax.swing.KeyStroke)1 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)1 RichTooltip (org.pushingpixels.flamingo.api.common.RichTooltip)1 ResizableIcon (org.pushingpixels.flamingo.api.common.icon.ResizableIcon)1 RibbonApplicationMenu (org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenu)1 RibbonApplicationMenuEntryPrimary (org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryPrimary)1