Search in sources :

Example 1 with ResizableIcon

use of org.pushingpixels.flamingo.api.common.icon.ResizableIcon in project freeplane by freeplane.

the class RibbonBuilder method updateApplicationMenuButton.

public void updateApplicationMenuButton(JRibbon ribbon) {
    for (Component comp : ribbon.getComponents()) {
        if (comp instanceof JRibbonApplicationMenuButton) {
            String appName = ResourceController.getResourceController().getProperty("ApplicationName", "Freeplane");
            URL location = ResourceController.getResourceController().getResource("/images/" + appName.trim() + "_app_menu_128.png");
            if (location != null) {
                ResizableIcon icon = ImageWrapperResizableIcon.getIcon(location, new Dimension(32, 32));
                ((JRibbonApplicationMenuButton) comp).setIcon(icon);
                ((JRibbonApplicationMenuButton) comp).setBackground(Color.blue);
            }
        }
    }
}
Also used : JRibbonApplicationMenuButton(org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton) Dimension(java.awt.Dimension) Component(java.awt.Component) ImageWrapperResizableIcon(org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon) ResizableIcon(org.pushingpixels.flamingo.api.common.icon.ResizableIcon) URL(java.net.URL)

Example 2 with ResizableIcon

use of org.pushingpixels.flamingo.api.common.icon.ResizableIcon in project freeplane by freeplane.

the class RibbonActionContributorFactory method createCommandToggleMenuButton.

public static JCommandToggleMenuButton createCommandToggleMenuButton(final AFreeplaneAction action) {
    String title = ActionUtils.getActionTitle(action);
    ResizableIcon icon = ActionUtils.getActionIcon(action);
    final JCommandToggleMenuButton button = new JCommandToggleMenuButton(title, icon);
    updateRichTooltip(button, action, null);
    button.addActionListener(new RibbonActionListener(action));
    button.setFocusable(false);
    return button;
}
Also used : JCommandToggleMenuButton(org.pushingpixels.flamingo.api.common.JCommandToggleMenuButton) ImageWrapperResizableIcon(org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon) ResizableIcon(org.pushingpixels.flamingo.api.common.icon.ResizableIcon)

Example 3 with ResizableIcon

use of org.pushingpixels.flamingo.api.common.icon.ResizableIcon in project freeplane by freeplane.

the class RibbonActionContributorFactory method createButton.

public static JButton createButton(final AFreeplaneAction action) {
    String title = ActionUtils.getActionTitle(action);
    ResizableIcon icon = ActionUtils.getActionIcon(action);
    final JButton button = new JButton(title, icon);
    // updateRichTooltip(button, action, null);
    button.addActionListener(new RibbonActionListener(action));
    button.setFocusable(false);
    return button;
}
Also used : JButton(javax.swing.JButton) ImageWrapperResizableIcon(org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon) ResizableIcon(org.pushingpixels.flamingo.api.common.icon.ResizableIcon)

Example 4 with ResizableIcon

use of org.pushingpixels.flamingo.api.common.icon.ResizableIcon 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 5 with ResizableIcon

use of org.pushingpixels.flamingo.api.common.icon.ResizableIcon in project freeplane by freeplane.

the class RibbonActionContributorFactory method createCommandMenuButton.

public static JCommandMenuButton createCommandMenuButton(final AFreeplaneAction action) {
    String title = ActionUtils.getActionTitle(action);
    ResizableIcon icon = ActionUtils.getActionIcon(action);
    final JCommandMenuButton button = new JCommandMenuButton(title, icon);
    updateRichTooltip(button, action, null);
    button.addActionListener(new RibbonActionListener(action));
    button.setFocusable(false);
    return button;
}
Also used : JCommandMenuButton(org.pushingpixels.flamingo.api.common.JCommandMenuButton) ImageWrapperResizableIcon(org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon) ResizableIcon(org.pushingpixels.flamingo.api.common.icon.ResizableIcon)

Aggregations

ResizableIcon (org.pushingpixels.flamingo.api.common.icon.ResizableIcon)10 ImageWrapperResizableIcon (org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon)8 Dimension (java.awt.Dimension)2 URL (java.net.URL)2 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)2 JCommandMenuButton (org.pushingpixels.flamingo.api.common.JCommandMenuButton)2 Component (java.awt.Component)1 ActionListener (java.awt.event.ActionListener)1 ImageIcon (javax.swing.ImageIcon)1 JButton (javax.swing.JButton)1 KeyStroke (javax.swing.KeyStroke)1 ScriptMetaData (org.freeplane.plugin.script.ScriptingConfiguration.ScriptMetaData)1 JCommandButton (org.pushingpixels.flamingo.api.common.JCommandButton)1 JCommandToggleButton (org.pushingpixels.flamingo.api.common.JCommandToggleButton)1 JCommandToggleMenuButton (org.pushingpixels.flamingo.api.common.JCommandToggleMenuButton)1 RichTooltip (org.pushingpixels.flamingo.api.common.RichTooltip)1 RibbonApplicationMenuEntryFooter (org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryFooter)1 RibbonApplicationMenuEntryPrimary (org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryPrimary)1 JRibbonApplicationMenuButton (org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton)1