Changeset 9510 in josm for trunk/src


Ignore:
Timestamp:
2016-01-17T20:09:12+01:00 (4 years ago)
Author:
bastiK
Message:

applied #12391 - saving renamed layer replaces name (patch by kolesar + cosmetic changes)

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

Legend:

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

    r9230 r9510  
    8686                if (Main.platform.rename(file, newFile)) {
    8787                    layer.setAssociatedFile(newFile);
    88                     nameText = newFile.getName();
     88                    if (!layer.isRenamed()) {
     89                        nameText = newFile.getName();
     90                    }
    8991                } else {
    9092                    JOptionPane.showMessageDialog(
     
    98100            }
    99101        }
    100         layer.setName(nameText);
     102        layer.rename(nameText);
    101103        Main.parent.repaint();
    102104    }
  • trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java

    r9466 r9510  
    9393                return false;
    9494            }
    95             layer.setName(file.getName());
     95            if (!layer.isRenamed()) {
     96                layer.setName(file.getName());
     97            }
    9698            layer.setAssociatedFile(file);
    9799            if (layer instanceof OsmDataLayer) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r9413 r9510  
    16011601                    break;
    16021602                case 2:
    1603                     l.setName((String) value);
     1603                    l.rename((String) value);
    16041604                    break;
    16051605                default: throw new RuntimeException();
  • trunk/src/org/openstreetmap/josm/gui/layer/Layer.java

    r9231 r9510  
    6262    /**
    6363     * Special class that can be returned by getMenuEntries when JSeparator needs to be created
    64      *
    6564     */
    6665    public static class SeparatorLayerAction extends AbstractAction implements LayerAction {
     
    9089    public static final int ICON_SIZE = 16;
    9190
    92     /** keeps track of property change listeners */
     91    /**
     92     * keeps track of property change listeners
     93     */
    9394    protected PropertyChangeSupport propertyChangeSupport;
    9495
    9596    /**
    9697     * The visibility state of the layer.
    97      *
    9898     */
    9999    private boolean visible = true;
     
    101101    /**
    102102     * The opacity of the layer.
    103      *
    104103     */
    105104    private double opacity = 1;
     
    107106    /**
    108107     * The layer should be handled as a background layer in automatic handling
    109      *
    110108     */
    111109    private boolean background;
     
    113111    /**
    114112     * The name of this layer.
    115      *
    116      */
    117     private  String name;
     113     */
     114    private String name;
     115
     116    /**
     117     * This is set if user renamed this layer.
     118     */
     119    private boolean renamed = false;
    118120
    119121    /**
     
    264266     * Sets the name of the layer
    265267     *
    266      *@param name the name. If null, the name is set to the empty string.
    267      *
     268     * @param name the name. If null, the name is set to the empty string.
    268269     */
    269270    public final void setName(String name) {
     
    276277            propertyChangeSupport.firePropertyChange(NAME_PROP, oldValue, this.name);
    277278        }
     279    }
     280
     281    /**
     282     * Rename layer and set renamed flag to mark it as renamed (has user given name).
     283     *
     284     * @param name the name. If null, the name is set to the empty string.
     285     */
     286    public final void rename(String name) {
     287        renamed = true;
     288        setName(name);
     289    }
     290
     291    /**
     292     * Replies true if this layer was renamed by user
     293     *
     294     * @return true if this layer was renamed by user
     295     */
     296    public boolean isRenamed() {
     297        return renamed;
    278298    }
    279299
     
    427447    /**
    428448     * The action to save a layer
    429      *
    430449     */
    431450    public static class LayerSaveAction extends AbstractAction {
Note: See TracChangeset for help on using the changeset viewer.