Changeset 4114 in josm
- Timestamp:
- 2011-06-01T22:23:11+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SaveAction.java
r2323 r4114 37 37 } 38 38 39 // FIXME: why only for GpxLayer? 39 // Ask for overwrite in case of GpxLayer: GpxLayers usually are imports 40 // and modifying is an error most of the time. 40 41 if(f != null && layer instanceof GpxLayer) { 41 42 ExtendedDialog dialog = new ExtendedDialog( -
trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
r4045 r4114 46 46 47 47 public boolean doSave(Layer layer) { 48 if (layer == null) 49 return false; 50 if ( !(layer instanceof OsmDataLayer) && !(layer instanceof GpxLayer)) 51 return false; 52 if (!checkSaveConditions(layer)) 53 return false; 54 55 File file = getFile(layer); 48 if(!checkSaveConditions(layer)) 49 return false; 50 return doInternalSave(layer, getFile(layer)); 51 } 52 53 public boolean doSave(Layer layer, File file) { 54 if(!checkSaveConditions(layer)) 55 return false; 56 return doInternalSave(layer, file); 57 } 58 59 private boolean doInternalSave(Layer layer, File file) { 56 60 if (file == null) 57 61 return false; … … 91 95 */ 92 96 public boolean checkSaveConditions(Layer layer) { 93 if (layer instanceof OsmDataLayer && isDataSetEmpty((OsmDataLayer)layer)) {94 ExtendedDialog dialog = new ExtendedDialog(95 Main.parent,96 tr("Empty document"),97 new String[] {tr("Save anyway"), tr("Cancel")}98 );99 dialog.setContent(tr("The document contains no data."));100 dialog.setButtonIcons(new String[] {"save.png", "cancel.png"});101 dialog.showDialog();102 if (dialog.getValue() != 1) return false;103 }104 105 if (layer instanceof GpxLayer && ((GpxLayer)layer).data == null)106 return false;107 if (layer instanceof OsmDataLayer) { 97 if (layer instanceof GpxLayer) 98 return ((GpxLayer)layer).data != null; 99 else if (layer instanceof OsmDataLayer) { 100 if (isDataSetEmpty((OsmDataLayer)layer)) { 101 ExtendedDialog dialog = new ExtendedDialog( 102 Main.parent, 103 tr("Empty document"), 104 new String[] {tr("Save anyway"), tr("Cancel")} 105 ); 106 dialog.setContent(tr("The document contains no data.")); 107 dialog.setButtonIcons(new String[] {"save.png", "cancel.png"}); 108 dialog.showDialog(); 109 if (dialog.getValue() != 1) return false; 110 } 111 108 112 ConflictCollection conflicts = ((OsmDataLayer)layer).getConflicts(); 109 113 if (conflicts != null && !conflicts.isEmpty()) { … … 119 123 if (dialog.getValue() != 1) return false; 120 124 } 121 } 122 return true; 125 return true; 126 } 127 return false; 123 128 } 124 129 -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayerTask.java
r3083 r4114 48 48 try { 49 49 parentMonitor.subTask(tr("Saving layer to ''{0}'' ...", layerInfo.getFile().toString())); 50 layerInfo.getLayer().setAssociatedFile(layerInfo.getFile()); 51 if (!new SaveAction().doSave(layerInfo.getLayer())) { 50 if (!new SaveAction().doSave(layerInfo.getLayer(), layerInfo.getFile())) { 52 51 setFailed(true); 53 52 return; -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersModel.java
r3083 r4114 116 116 List<SaveLayerInfo> ret =new ArrayList<SaveLayerInfo>(); 117 117 for (SaveLayerInfo info: layerInfo) { 118 if (info.isDoSaveToFile() && info.getFile() != null && !info.getFile().canWrite()) {118 if (info.isDoSaveToFile() && info.getFile() != null && info.getFile().exists() && !info.getFile().canWrite()) { 119 119 ret.add(info); 120 120 }
Note:
See TracChangeset
for help on using the changeset viewer.