root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.gui / src / main / java / es / unex / sextante / gui / cmd / DeleteScriptAction.java @ 283
History | View | Annotate | Download (1.14 KB)
1 |
package es.unex.sextante.gui.cmd; |
---|---|
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 DeleteScriptAction |
13 |
implements
|
14 |
IToolboxRightButtonAction { |
15 |
|
16 |
public boolean canBeExecutedOnAlgorithm(final GeoAlgorithm alg) { |
17 |
|
18 |
return alg instanceof ScriptAlgorithm; |
19 |
|
20 |
} |
21 |
|
22 |
public void execute(final GeoAlgorithm alg) { |
23 |
|
24 |
int deleteScriptResult = JOptionPane.showConfirmDialog(null, Sextante.getText("are_you_sure_to_delete_the_selected_script"), Sextante.getText("Warning"), JOptionPane.YES_NO_OPTION); |
25 |
if (deleteScriptResult == JOptionPane.YES_OPTION) { |
26 |
final ScriptAlgorithm script = (ScriptAlgorithm) alg;
|
27 |
final File file = new File(script.getFilename()); |
28 |
file.delete(); |
29 |
SextanteGUI.updateAlgorithmProvider(ScriptAlgorithmProvider.class); |
30 |
SextanteGUI.getGUIFactory().updateToolbox(); |
31 |
} |
32 |
|
33 |
} |
34 |
|
35 |
public String getDescription() { |
36 |
|
37 |
return Sextante.getText("Delete"); |
38 |
|
39 |
} |
40 |
|
41 |
} |