Changeset 6707 in josm for trunk/src


Ignore:
Timestamp:
2014-01-17T00:41:23+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #9028, see #6797 - load imagery layer icons in background

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r6248 r6707  
    2424import org.openstreetmap.josm.gui.layer.ImageryLayer;
    2525import org.openstreetmap.josm.gui.preferences.imagery.WMSLayerTree;
     26import org.openstreetmap.josm.gui.util.GuiHelper;
    2627import org.openstreetmap.josm.io.imagery.WMSImagery;
    2728import org.openstreetmap.josm.tools.GBC;
    2829import org.openstreetmap.josm.tools.ImageProvider;
     30import org.openstreetmap.josm.tools.ImageProvider.ImageCallback;
    2931
     32/**
     33 * Action displayed in imagery menu to add a new imagery layer.
     34 * @since 3715
     35 */
    3036public class AddImageryLayerAction extends JosmAction implements AdaptableAction {
    3137
     
    3339    private final ImageryInfo info;
    3440
     41    /**
     42     * Constructs a new {@code AddImageryLayerAction} for the given {@code ImageryInfo}.
     43     * If an http:// icon is specified, it is fetched asynchronously.
     44     * @param info The imagery info
     45     */
    3546    public AddImageryLayerAction(ImageryInfo info) {
    3647        super(info.getMenuName(), /* ICON */"imagery_menu", tr("Add imagery layer {0}",info.getName()), null, false, false);
     
    4253        try {
    4354            if (info.getIcon() != null) {
    44                 ImageIcon i = new ImageProvider(info.getIcon()).setOptional(true).
    45                         setMaxHeight(MAX_ICON_SIZE).setMaxWidth(MAX_ICON_SIZE).get();
    46                 if (i != null) {
    47                     putValue(Action.SMALL_ICON, i);
    48                 }
     55                new ImageProvider(info.getIcon()).setOptional(true).
     56                        setMaxHeight(MAX_ICON_SIZE).setMaxWidth(MAX_ICON_SIZE).getInBackground(new ImageCallback() {
     57                            @Override
     58                            public void finished(final ImageIcon result) {
     59                                if (result != null) {
     60                                    GuiHelper.runInEDT(new Runnable() {
     61                                        @Override
     62                                        public void run() {
     63                                            putValue(Action.SMALL_ICON, result);
     64                                        }
     65                                    });
     66                                }
     67                            }
     68                        });
    4969            }
    5070        } catch (Exception ex) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r6652 r6707  
    738738    public class MouseClickWatch extends MouseAdapter {
    739739        @Override public void mouseClicked(MouseEvent e) {
    740             if (e.getClickCount() < 2)
    741             {
     740            if (e.getClickCount() < 2) {
    742741                // single click, clear selection in other table not clicked in
    743742                if (e.getSource() == tagTable) {
     
    748747            }
    749748            // double click, edit or add tag
    750             else if (e.getSource() == tagTable)
    751             {
     749            else if (e.getSource() == tagTable) {
    752750                int row = tagTable.rowAtPoint(e.getPoint());
    753751                if (row > -1) {
     
    764762                }
    765763            }
    766             else
    767             {
     764            else {
    768765                editHelper.addTag();
    769766                btnAdd.requestFocusInWindow();
Note: See TracChangeset for help on using the changeset viewer.