root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.gui / src / main / java / es / unex / sextante / gui / modeler / DeleteModelAction.java @ 283
History | View | Annotate | Download (1.14 KB)
1 |
package es.unex.sextante.gui.modeler; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
|
5 |
import javax.swing.JOptionPane; |
6 |
|
7 |
import es.unex.sextante.core.GeoAlgorithm; |
8 |
import es.unex.sextante.core.Sextante; |
9 |
import es.unex.sextante.gui.core.IToolboxRightButtonAction; |
10 |
import es.unex.sextante.gui.core.SextanteGUI; |
11 |
|
12 |
public class DeleteModelAction |
13 |
implements
|
14 |
IToolboxRightButtonAction { |
15 |
|
16 |
public boolean canBeExecutedOnAlgorithm(final GeoAlgorithm alg) { |
17 |
|
18 |
return alg instanceof ModelAlgorithm; |
19 |
|
20 |
} |
21 |
|
22 |
|
23 |
public void execute(final GeoAlgorithm alg) { |
24 |
|
25 |
int deleteModelResult = JOptionPane.showConfirmDialog(null, Sextante.getText("are_you_sure_to_delete_the_selected_model"), Sextante.getText("Warning"), JOptionPane.YES_NO_OPTION); |
26 |
if (deleteModelResult == JOptionPane.YES_OPTION) { |
27 |
final ModelAlgorithm model = (ModelAlgorithm) alg;
|
28 |
final File file = new File(model.getFilename()); |
29 |
file.delete(); |
30 |
SextanteGUI.updateAlgorithmProvider(ModelerAlgorithmProvider.class); |
31 |
SextanteGUI.getGUIFactory().updateToolbox(); |
32 |
} |
33 |
|
34 |
} |
35 |
|
36 |
|
37 |
public String getDescription() { |
38 |
|
39 |
return Sextante.getText("Delete"); |
40 |
|
41 |
} |
42 |
|
43 |
} |