Ignore:
Timestamp:
2014-11-02T01:19:59+01:00 (5 years ago)
Author:
stoecker
Message:

see #10684 - no double loading of images, cleanup action icons - menu icon size defaults now to 16x16 (previously most time 24x24) with some errors - maybe 24x24 should be default?

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r7692 r7693  
    1212
    1313import javax.swing.Action;
    14 import javax.swing.ImageIcon;
    1514import javax.swing.JComboBox;
    1615import javax.swing.JOptionPane;
     
    2928import org.openstreetmap.josm.tools.GBC;
    3029import org.openstreetmap.josm.tools.ImageProvider;
    31 import org.openstreetmap.josm.tools.ImageProvider.ImageCallback;
     30import org.openstreetmap.josm.tools.ImageProvider.ImageResourceCallback;
     31import org.openstreetmap.josm.tools.ImageResource;
    3232
    3333/**
     
    5252        // change toolbar icon from if specified
    5353        try {
    54             if (info.getIcon() != null) {
    55                 new ImageProvider(info.getIcon()).setOptional(true).
    56                         setMaxSize(ImageProvider.ImageSizes.SMALLICON).getInBackground(new ImageCallback() {
     54            String icon = info.getIcon();
     55            if (icon != null) {
     56                new ImageProvider(icon).setOptional(true).getInBackground(new ImageResourceCallback() {
    5757                            @Override
    58                             public void finished(final ImageIcon result) {
     58                            public void finished(final ImageResource result) {
    5959                                if (result != null) {
    6060                                    GuiHelper.runInEDT(new Runnable() {
    6161                                        @Override
    6262                                        public void run() {
    63                                             putValue(Action.SMALL_ICON, result);
    64                                         }
    65                                     });
    66                                 }
    67                             }
    68                         });
    69                 new ImageProvider(info.getIcon()).setOptional(true).
    70                         setMaxSize(ImageProvider.ImageSizes.LARGEICON).getInBackground(new ImageCallback() {
    71                             @Override
    72                             public void finished(final ImageIcon result) {
    73                                 if (result != null) {
    74                                     GuiHelper.runInEDT(new Runnable() {
    75                                         @Override
    76                                         public void run() {
    77                                             putValue(Action.LARGE_ICON_KEY, result);
     63                                            result.getImageIcon(AddImageryLayerAction.this);
    7864                                        }
    7965                                    });
  • trunk/src/org/openstreetmap/josm/actions/JosmAction.java

    r7534 r7693  
    7272     * @param toolbarId identifier for the toolbar preferences. The iconName is used, if this parameter is null
    7373     * @param installAdapters false, if you don't want to install layer changed and selection changed adapters
    74      */
     74     * @deprecated do not pass Icon, pass ImageProvider instead
     75     */
     76    @Deprecated
    7577    public JosmAction(String name, Icon icon, String tooltip, Shortcut shortcut, boolean registerInToolbar, String toolbarId, boolean installAdapters) {
    7678        super(name, icon);
     
    9395
    9496    /**
     97     * Constructs a {@code JosmAction}.
     98     *
     99     * @param name the action's text as displayed on the menu (if it is added to a menu)
     100     * @param icon the icon to use
     101     * @param tooltip  a longer description of the action that will be displayed in the tooltip. Please note
     102     *           that html is not supported for menu actions on some platforms.
     103     * @param shortcut a ready-created shortcut object or null if you don't want a shortcut. But you always
     104     *            do want a shortcut, remember you can always register it with group=none, so you
     105     *            won't be assigned a shortcut unless the user configures one. If you pass null here,
     106     *            the user CANNOT configure a shortcut for your action.
     107     * @param registerInToolbar register this action for the toolbar preferences?
     108     * @param toolbarId identifier for the toolbar preferences. The iconName is used, if this parameter is null
     109     * @param installAdapters false, if you don't want to install layer changed and selection changed adapters
     110     * TODO: do not pass Icon, pass ImageProvider instead
     111     */
     112    public JosmAction(String name, ImageProvider icon, String tooltip, Shortcut shortcut, boolean registerInToolbar, String toolbarId, boolean installAdapters) {
     113        super(name);
     114        if(icon != null)
     115            icon.getResource().getImageIcon(this);
     116        setHelpId();
     117        sc = shortcut;
     118        if (sc != null) {
     119            Main.registerActionShortcut(this, sc);
     120        }
     121        setTooltip(tooltip);
     122        if (getValue("toolbar") == null) {
     123            putValue("toolbar", toolbarId);
     124        }
     125        if (registerInToolbar && Main.toolbar != null) {
     126            Main.toolbar.register(this);
     127        }
     128        if (installAdapters) {
     129            installAdapters();
     130        }
     131    }
     132
     133    /**
    95134     * The new super for all actions.
    96135     *
     
    110149     */
    111150    public JosmAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean registerInToolbar, String toolbarId, boolean installAdapters) {
    112         this(name, iconName == null ? null : ImageProvider.get(iconName), tooltip, shortcut, registerInToolbar,
     151        this(name, iconName == null ? null : new ImageProvider(iconName), tooltip, shortcut, registerInToolbar,
    113152                toolbarId == null ? iconName : toolbarId, installAdapters);
    114153    }
  • trunk/src/org/openstreetmap/josm/actions/JumpToAction.java

    r7081 r7693  
    99import java.awt.event.KeyEvent;
    1010
    11 import javax.swing.Icon;
    1211import javax.swing.JLabel;
    1312import javax.swing.JOptionPane;
     
    2423import org.openstreetmap.josm.gui.widgets.JosmTextField;
    2524import org.openstreetmap.josm.tools.GBC;
     25import org.openstreetmap.josm.tools.ImageProvider;
    2626import org.openstreetmap.josm.tools.OsmUrlToBounds;
    2727import org.openstreetmap.josm.tools.Shortcut;
     
    3737     */
    3838    public JumpToAction() {
    39         super(tr("Jump To Position"), (Icon) null, tr("Opens a dialog that allows to jump to a specific location"),
     39        super(tr("Jump To Position"), (ImageProvider) null, tr("Opens a dialog that allows to jump to a specific location"),
    4040                Shortcut.registerShortcut("tools:jumpto", tr("Tool: {0}", tr("Jump To Position")),
    4141                        KeyEvent.VK_J, Shortcut.CTRL), true, "action/jumpto", true);
Note: See TracChangeset for help on using the changeset viewer.