Revision 10626 trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/gui/AbstractGeoprocessPanel.java
AbstractGeoprocessPanel.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.7 2006-09-15 10:42:54 caballero |
|
48 |
* Revision 1.8 2007-03-06 16:47:58 caballero |
|
49 |
* Exceptions |
|
50 |
* |
|
51 |
* Revision 1.7 2006/09/15 10:42:54 caballero |
|
49 | 52 |
* extensibilidad de documentos |
50 | 53 |
* |
51 | 54 |
* Revision 1.6 2006/07/21 09:10:34 azabala |
... | ... | |
104 | 107 |
import javax.swing.JPanel; |
105 | 108 |
import javax.swing.JTextField; |
106 | 109 |
|
110 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
107 | 111 |
import com.iver.andami.PluginServices; |
108 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
109 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
110 | 112 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
111 | 113 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
112 | 114 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
... | ... | |
124 | 126 |
protected FLayers layers = null; |
125 | 127 |
protected JComboBox layersComboBox = null; |
126 | 128 |
protected JTextField fileNameResultTextField = null; |
127 |
|
|
129 |
|
|
128 | 130 |
public FLyrVect getInputLayer() { |
129 | 131 |
FLyrVect solution = null; |
130 | 132 |
String selectedLayer = (String)layersComboBox.getSelectedItem(); |
131 | 133 |
solution = (FLyrVect)layers.getLayer(selectedLayer); |
132 | 134 |
return solution; |
133 | 135 |
} |
134 |
|
|
136 |
|
|
135 | 137 |
public void setFLayers(FLayers layers){ |
136 | 138 |
this.layers = layers; |
137 | 139 |
} |
138 |
|
|
140 |
|
|
139 | 141 |
public FLayers getFLayers(){ |
140 | 142 |
return layers; |
141 | 143 |
} |
142 |
|
|
144 |
|
|
143 | 145 |
protected FLyrVect[] getVectorialLayers(FLayers layers){ |
144 | 146 |
FLyrVect[] solution = null; |
145 | 147 |
ArrayList list = new ArrayList(); |
... | ... | |
154 | 156 |
solution = new FLyrVect[list.size()]; |
155 | 157 |
list.toArray(solution); |
156 | 158 |
return solution; |
157 |
|
|
159 |
|
|
158 | 160 |
} |
159 |
|
|
161 |
|
|
160 | 162 |
protected String[] getLayerNames() { |
161 | 163 |
String[] solution = null; |
162 | 164 |
int numLayers = layers.getLayersCount(); |
... | ... | |
179 | 181 |
} |
180 | 182 |
return solution; |
181 | 183 |
} |
182 |
|
|
184 |
|
|
183 | 185 |
/** |
184 | 186 |
* Shows to the user a dialog error, whith the title and message body |
185 | 187 |
* specified as parameters. |
186 |
*
|
|
188 |
* |
|
187 | 189 |
* @param message body of the error message |
188 | 190 |
* @param title title of the error message |
189 | 191 |
*/ |
... | ... | |
193 | 195 |
JOptionPane.showMessageDialog(parentComponent, message, title, |
194 | 196 |
JOptionPane.ERROR_MESSAGE); |
195 | 197 |
} |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
198 | 200 |
/** |
199 | 201 |
* Asks to the user for the creation of a spatial index for the |
200 | 202 |
* specified layer. |
201 | 203 |
* It will be of help for certain geoprocesses. |
202 |
*
|
|
204 |
* |
|
203 | 205 |
* FLyrVect default spatial index is MapServer quadtree, that hasnt |
204 | 206 |
* the ability to do nearest neighbour searches. |
205 |
*
|
|
207 |
* |
|
206 | 208 |
* For those geoprocesses that needs it (NN searches) overwrite this |
207 | 209 |
* method and use JSI RTree, or SIL RTree. |
208 |
*
|
|
210 |
* |
|
209 | 211 |
* It returns an IMonitorableTask, a task to build the spatial |
210 | 212 |
* index in background. |
211 |
*
|
|
213 |
* |
|
212 | 214 |
* @param layer |
213 | 215 |
* @return an ITask |
214 | 216 |
*/ |
215 | 217 |
public IMonitorableTask askForSpatialIndexCreation(FLyrVect layer){ |
216 | 218 |
String title = PluginServices.getText(this, "Crear_Indice"); |
217 |
String confirmDialogText =
|
|
219 |
String confirmDialogText = |
|
218 | 220 |
PluginServices.getText(this, "Crear_Indice_Pregunta_1")+ |
219 | 221 |
" " + |
220 | 222 |
layer.getName()+ |
221 | 223 |
" " + |
222 | 224 |
PluginServices.getText(this, "Crear_Indice_Pregunta_2"); |
223 |
int option = JOptionPane.showConfirmDialog(this,
|
|
225 |
int option = JOptionPane.showConfirmDialog(this, |
|
224 | 226 |
confirmDialogText, |
225 |
title,
|
|
226 |
JOptionPane.YES_NO_OPTION,
|
|
227 |
title, |
|
228 |
JOptionPane.YES_NO_OPTION, |
|
227 | 229 |
JOptionPane.QUESTION_MESSAGE, null); |
228 | 230 |
if(option == JOptionPane.YES_OPTION){ |
229 | 231 |
//Usually we want task like spatial index creation dont block |
... | ... | |
234 | 236 |
CreateSpatialIndexMonitorableTask task |
235 | 237 |
= new CreateSpatialIndexMonitorableTask(layer); |
236 | 238 |
return task; |
237 |
} catch (DriverIOException e) { |
|
238 |
// TODO Auto-generated catch block |
|
239 |
} catch (ReadDriverException e) { |
|
239 | 240 |
e.printStackTrace(); |
240 | 241 |
return null; |
241 |
} catch (DriverException e) { |
|
242 |
// TODO Auto-generated catch block |
|
243 |
e.printStackTrace(); |
|
244 |
return null; |
|
245 | 242 |
} |
246 |
}else
|
|
247 |
return null;
|
|
248 |
|
|
243 |
} |
|
244 |
return null; |
|
245 |
|
|
249 | 246 |
} |
250 | 247 |
/** |
251 | 248 |
* Confirm overwrite the output file |
252 | 249 |
* if it allready exist. |
253 |
*
|
|
254 |
*
|
|
250 |
* |
|
251 |
* |
|
255 | 252 |
* @param outputFile |
256 | 253 |
* @return answer |
257 | 254 |
*/ |
258 | 255 |
public boolean askForOverwriteOutputFile(File outputFile){ |
259 | 256 |
String title = PluginServices.getText(this, "Sobreescribir_fichero"); |
260 |
String confirmDialogText =
|
|
257 |
String confirmDialogText = |
|
261 | 258 |
PluginServices.getText(this, "Sobreescribir_fichero_Pregunta_1")+ |
262 | 259 |
"\n'" + |
263 | 260 |
outputFile.getAbsolutePath()+ |
264 | 261 |
"'\n" + |
265 | 262 |
PluginServices.getText(this, "Sobreescribir_fichero_Pregunta_2"); |
266 |
int option = JOptionPane.showConfirmDialog(this,
|
|
263 |
int option = JOptionPane.showConfirmDialog(this, |
|
267 | 264 |
confirmDialogText, |
268 |
title,
|
|
269 |
JOptionPane.YES_NO_OPTION,
|
|
265 |
title, |
|
266 |
JOptionPane.YES_NO_OPTION, |
|
270 | 267 |
JOptionPane.QUESTION_MESSAGE, null); |
271 | 268 |
if(option == JOptionPane.YES_OPTION){ |
272 | 269 |
return true; |
273 | 270 |
} |
274 | 271 |
return false; |
275 | 272 |
} |
276 |
|
|
273 |
|
|
277 | 274 |
public void openResultFile() { |
278 | 275 |
JFileChooser jfc = new JFileChooser(); |
279 | 276 |
jfc.addChoosableFileFilter(new GenericFileFilter("shp", |
280 | 277 |
"Ficheros SHP")); |
281 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) ==
|
|
278 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == |
|
282 | 279 |
JFileChooser.APPROVE_OPTION) { |
283 | 280 |
File file = jfc.getSelectedFile(); |
284 | 281 |
if (!(file.getPath().endsWith(".shp") || file.getPath().endsWith(".SHP"))){ |
... | ... | |
289 | 286 |
getFileNameResultTextField().setText( |
290 | 287 |
jfc.getSelectedFile().getAbsolutePath()); |
291 | 288 |
} |
292 |
|
|
289 |
|
|
293 | 290 |
} |
294 |
|
|
291 |
|
|
295 | 292 |
/** |
296 | 293 |
* Gives access to the text field where user could enter the result |
297 | 294 |
* file path. |
... | ... | |
305 | 302 |
} |
306 | 303 |
return fileNameResultTextField; |
307 | 304 |
} |
308 |
|
|
309 |
|
|
305 |
|
|
306 |
|
|
310 | 307 |
public File getOutputFile() throws FileNotFoundException{ |
311 | 308 |
String fileName = getFileNameResultTextField().getText(); |
312 | 309 |
if(fileName.length() == 0){ |
Also available in: Unified diff