Changeset 19116 in josm for trunk


Ignore:
Timestamp:
2024-06-19T05:42:07+02:00 (5 months ago)
Author:
GerdP
Message:

fix #23648: Not possible to save a layer after marked as "Discourage upload"

  • mark layer as changed and show notificaton when the toggle was triggered
  • remove overwrite of SaveActionBase.updateEnabledState() for "Save"
Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

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

    r18287 r19116  
    2323import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
    2424import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
    25 import org.openstreetmap.josm.gui.layer.SaveToFile;
    26 import org.openstreetmap.josm.gui.util.GuiHelper;
    2725import org.openstreetmap.josm.spi.preferences.Config;
    2826import org.openstreetmap.josm.tools.GBC;
     
    9088
    9189    @Override
    92     protected void updateEnabledState() {
    93         Layer activeLayer = getLayerManager().getActiveLayer();
    94         boolean en = activeLayer != null
    95                 && activeLayer.isSavable() && !(activeLayer.getAssociatedFile() != null
    96                 && activeLayer instanceof SaveToFile && !((SaveToFile) activeLayer).requiresSaveToFile());
    97         GuiHelper.runInEDT(() -> setEnabled(en));
    98     }
    99 
    100     @Override
    10190    public File getFile(Layer layer) {
    10291        File f = layer.getAssociatedFile();
  • trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java

    r18135 r19116  
    2323import org.openstreetmap.josm.gui.layer.AbstractModifiableLayer;
    2424import org.openstreetmap.josm.gui.layer.Layer;
     25import org.openstreetmap.josm.gui.layer.SaveToFile;
    2526import org.openstreetmap.josm.gui.util.GuiHelper;
    2627import org.openstreetmap.josm.gui.widgets.AbstractFileChooser;
     
    183184
    184185    @Override
    185     protected void updateEnabledState() {
     186    protected final void updateEnabledState() {
    186187        Layer activeLayer = getLayerManager().getActiveLayer();
    187         setEnabled(activeLayer != null && activeLayer.isSavable());
     188        boolean en = activeLayer != null && activeLayer.isSavable();
     189        // see #12669 and #23648
     190        if (en && this instanceof SaveAction && activeLayer instanceof SaveToFile) {
     191            en = activeLayer.getAssociatedFile() == null || ((SaveToFile) activeLayer).requiresSaveToFile();
     192        }
     193        setEnabled(en);
    188194    }
    189195
  • trunk/src/org/openstreetmap/josm/actions/ToggleUploadDiscouragedLayerAction.java

    r13130 r19116  
    1212import javax.swing.JCheckBoxMenuItem;
    1313
     14import org.openstreetmap.josm.gui.Notification;
    1415import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
    1516import org.openstreetmap.josm.gui.layer.Layer;
    1617import org.openstreetmap.josm.gui.layer.Layer.LayerAction;
    1718import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     19import org.openstreetmap.josm.gui.util.GuiHelper;
    1820import org.openstreetmap.josm.tools.ImageProvider;
    1921
     
    4143    public void actionPerformed(ActionEvent e) {
    4244        layer.setUploadDiscouraged(!layer.isUploadDiscouraged());
     45        String msg = layer.isUploadDiscouraged() ? tr("Upload is discouraged") : tr("Upload is encouraged");
     46        GuiHelper.runInEDT(() -> new Notification(msg).show());
    4347        LayerListDialog.getInstance().repaint();
    4448    }
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r18753 r19116  
    11961196                (uploadDiscouraged ^ isUploadDiscouraged())) {
    11971197            data.setUploadPolicy(uploadDiscouraged ? UploadPolicy.DISCOURAGED : UploadPolicy.NORMAL);
     1198            setRequiresSaveToFile(true);
    11981199            for (LayerStateChangeListener l : layerStateChangeListeners) {
    11991200                l.uploadDiscouragedChanged(this, uploadDiscouraged);
Note: See TracChangeset for help on using the changeset viewer.