Revision 17861
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/saveraster/ui/listener/SaveRasterDialogListener.java | ||
---|---|---|
112 | 112 |
|
113 | 113 |
//Comprobamos que el en la ruta de destino tengamos permisos de escritura |
114 | 114 |
File f = new File(fName); |
115 |
if(!f.exists()) { |
|
116 |
if(!checkFileExists(fName)) |
|
117 |
return false; |
|
118 |
} |
|
119 |
f = new File(fName.substring(0, fName.lastIndexOf(File.separator))); |
|
120 |
|
|
121 | 115 |
if(f.exists()) |
122 | 116 |
if(!RasterToolsUtil.messageBoxYesOrNot("raster_error_file_exists", dialog)) |
123 | 117 |
return false; |
124 | 118 |
|
119 |
f = new File(fName.substring(0, fName.lastIndexOf(File.separator))); |
|
120 |
|
|
125 | 121 |
if(f.exists() && f.isDirectory() && !f.canWrite()) { |
126 | 122 |
RasterToolsUtil.messageBoxError("error_file_not_writable", dialog); |
127 | 123 |
return false; |
... | ... | |
171 | 167 |
return true; |
172 | 168 |
} |
173 | 169 |
|
174 |
/** |
|
175 |
* Comprueba si existe el fichero pasado por par?metro existe solicitando confirmaci?n |
|
176 |
* de sobreescritura. Si el usuario acepta devolver? true y si no acepta devuelve false. |
|
177 |
* Si se acepta la sobreescritura el fichero es borrado. |
|
178 |
* @param file Cadena con el nombre del fichero a comprobar su existencia. |
|
179 |
* @return Devuelve true si el fichero existe y va a ser sobreescrito |
|
180 |
*/ |
|
181 |
private boolean checkFileExists(String file){ |
|
182 |
File f = new File(file); |
|
183 |
if(f.exists()){ |
|
184 |
String string1 = PluginServices.getText(this, "yes"); |
|
185 |
String string2 = PluginServices.getText(this, "no"); |
|
186 |
Object[] options = {string1, string2}; |
|
187 |
int n = JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(), |
|
188 |
PluginServices.getText(this, "raster_error_file_exists"), |
|
189 |
PluginServices.getText(this, "confirmacion"), |
|
190 |
JOptionPane.YES_NO_OPTION, |
|
191 |
JOptionPane.QUESTION_MESSAGE, |
|
192 |
null, |
|
193 |
options, |
|
194 |
string1); |
|
195 |
if (n == JOptionPane.YES_OPTION){ |
|
196 |
f.delete(); |
|
197 |
return true; |
|
198 |
}else |
|
199 |
return false; |
|
200 |
} |
|
201 |
return true; |
|
202 |
} |
|
203 |
|
|
204 | 170 |
/** |
205 | 171 |
* Funci?n a ejecutar cuando se pulsa el bot?n de propiedades. |
206 | 172 |
* @param e ActionEvent |
Also available in: Unified diff