Changeset 15513 in josm


Ignore:
Timestamp:
2019-11-05T22:07:11+01:00 (5 years ago)
Author:
Don-vip
Message:

fix #18296 - make sure "Upload selection" is always enabled if required after data change event

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
1 added
2 edited

Legend:

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

    r15404 r15513  
    77import java.awt.event.ActionEvent;
    88import java.awt.event.KeyEvent;
    9 import java.beans.PropertyChangeListener;
    109import java.util.LinkedList;
    1110import java.util.List;
     
    3130import org.openstreetmap.josm.gui.io.UploadPrimitivesTask;
    3231import org.openstreetmap.josm.gui.layer.AbstractModifiableLayer;
    33 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
    34 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
    3532import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3633import org.openstreetmap.josm.gui.util.GuiHelper;
     
    5249 * @author imi
    5350 */
    54 public class UploadAction extends JosmAction {
     51public class UploadAction extends AbstractUploadAction {
    5552    /**
    5653     * The list of upload hooks. These hooks will be called one after the other
     
    9491        LATE_UPLOAD_HOOKS.add(new DiscardTagsHook());
    9592    }
    96 
    97     private final PropertyChangeListener updateOnRequireUploadChange = evt -> {
    98         if (OsmDataLayer.REQUIRES_UPLOAD_TO_SERVER_PROP.equals(evt.getPropertyName())) {
    99             updateEnabledState();
    100         }
    101     };
    10293
    10394    /**
     
    153144                Shortcut.registerShortcut("file:upload", tr("File: {0}", tr("Upload data")), KeyEvent.VK_UP, Shortcut.CTRL_SHIFT), true);
    154145        setHelpId(ht("/Action/Upload"));
    155     }
    156 
    157     @Override
    158     protected LayerChangeAdapter buildLayerChangeAdapter() {
    159         return new LayerChangeAdapter() {
    160             @Override
    161             public void layerAdded(LayerAddEvent e) {
    162                 if (e.getAddedLayer() instanceof OsmDataLayer) {
    163                     e.getAddedLayer().addPropertyChangeListener(updateOnRequireUploadChange);
    164                 }
    165                 super.layerAdded(e);
    166             }
    167 
    168             @Override
    169             public void layerRemoving(LayerRemoveEvent e) {
    170                 if (e.getRemovedLayer() instanceof OsmDataLayer) {
    171                     e.getRemovedLayer().removePropertyChangeListener(updateOnRequireUploadChange);
    172                 }
    173                 super.layerRemoving(e);
    174             }
    175         };
    176146    }
    177147
  • trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java

    r15426 r15513  
    4040 * @since 2250
    4141 */
    42 public class UploadSelectionAction extends JosmAction {
     42public class UploadSelectionAction extends AbstractUploadAction {
    4343    /**
    4444     * Constructs a new {@code UploadSelectionAction}.
Note: See TracChangeset for help on using the changeset viewer.