diff --git a/src/org/openstreetmap/josm/actions/RenameLayerAction.java b/src/org/openstreetmap/josm/actions/RenameLayerAction.java
index b5bd308..c459b50 100644
a
|
b
|
public class RenameLayerAction extends AbstractAction { |
85 | 85 | File newFile = new File(newname); |
86 | 86 | if (Main.platform.rename(file, newFile)) { |
87 | 87 | layer.setAssociatedFile(newFile); |
88 | | nameText = newFile.getName(); |
| 88 | if (!layer.isRenamed()) nameText = newFile.getName(); |
89 | 89 | } else { |
90 | 90 | JOptionPane.showMessageDialog( |
91 | 91 | Main.parent, |
… |
… |
public class RenameLayerAction extends AbstractAction { |
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
100 | | layer.setName(nameText); |
| 100 | layer.rename(nameText); |
101 | 101 | Main.parent.repaint(); |
102 | 102 | } |
103 | 103 | } |
diff --git a/src/org/openstreetmap/josm/actions/SaveActionBase.java b/src/org/openstreetmap/josm/actions/SaveActionBase.java
index 0eebdae..70bba1f 100644
a
|
b
|
public abstract class SaveActionBase extends DiskAccessAction { |
92 | 92 | } else if (canceled) { |
93 | 93 | return false; |
94 | 94 | } |
95 | | layer.setName(file.getName()); |
| 95 | if (!layer.isRenamed()) layer.setName(file.getName()); |
96 | 96 | layer.setAssociatedFile(file); |
97 | 97 | if (layer instanceof OsmDataLayer) { |
98 | 98 | ((OsmDataLayer) layer).onPostSaveToFile(); |
diff --git a/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java b/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
index 0ea557b..4223c02 100644
a
|
b
|
public class LayerListDialog extends ToggleDialog { |
1600 | 1600 | l.setVisible((Boolean) value); |
1601 | 1601 | break; |
1602 | 1602 | case 2: |
1603 | | l.setName((String) value); |
| 1603 | l.rename((String) value); |
1604 | 1604 | break; |
1605 | 1605 | default: throw new RuntimeException(); |
1606 | 1606 | } |
diff --git a/src/org/openstreetmap/josm/gui/layer/Layer.java b/src/org/openstreetmap/josm/gui/layer/Layer.java
index 2357a2f..00ef037 100644
a
|
b
|
public abstract class Layer implements Destroyable, MapViewPaintable, Projection |
114 | 114 | * The name of this layer. |
115 | 115 | * |
116 | 116 | */ |
117 | | private String name; |
| 117 | private String name; |
| 118 | |
| 119 | /** |
| 120 | * This is set if user renamed this layer. |
| 121 | */ |
| 122 | private boolean renamed = false; |
118 | 123 | |
119 | 124 | /** |
120 | 125 | * If a file is associated with this layer, this variable should be set to it. |
… |
… |
public abstract class Layer implements Destroyable, MapViewPaintable, Projection |
263 | 268 | /** |
264 | 269 | * Sets the name of the layer |
265 | 270 | * |
266 | | *@param name the name. If null, the name is set to the empty string. |
| 271 | * @param name the name. If null, the name is set to the empty string. |
267 | 272 | * |
268 | 273 | */ |
269 | 274 | public final void setName(String name) { |
… |
… |
public abstract class Layer implements Destroyable, MapViewPaintable, Projection |
278 | 283 | } |
279 | 284 | |
280 | 285 | /** |
| 286 | * Rename layer and set renamed flag to mark it as renamed (has user given name). |
| 287 | * |
| 288 | * @param name the name. If null, the name is set to the empty string. |
| 289 | * |
| 290 | */ |
| 291 | public final void rename(String name) { |
| 292 | renamed = true; |
| 293 | setName(name); |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * Replies true if this layer was renamed by user |
| 298 | * |
| 299 | * @return true if this layer was renamed by user |
| 300 | */ |
| 301 | public boolean isRenamed() { |
| 302 | return renamed; |
| 303 | } |
| 304 | |
| 305 | /** |
281 | 306 | * Replies true if this layer is a background layer |
282 | 307 | * |
283 | 308 | * @return true if this layer is a background layer |