root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / TableEditStopExtension.java @ 9212
History | View | Annotate | Download (2.02 KB)
1 |
package com.iver.cit.gvsig; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import javax.swing.JOptionPane; |
6 |
|
7 |
import com.iver.andami.PluginServices; |
8 |
import com.iver.andami.plugins.Extension; |
9 |
import com.iver.andami.ui.mdiManager.IWindow; |
10 |
import com.iver.cit.gvsig.project.documents.table.gui.Table; |
11 |
|
12 |
|
13 |
/**
|
14 |
* DOCUMENT ME!
|
15 |
*
|
16 |
* @author Vicente Caballero Navarro
|
17 |
*/
|
18 |
public class TableEditStopExtension extends Extension { |
19 |
/**
|
20 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
21 |
*/
|
22 |
public void initialize() { |
23 |
} |
24 |
|
25 |
/**
|
26 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
27 |
*/
|
28 |
public void execute(String actionCommand) { |
29 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
30 |
Table table = (Table) v; |
31 |
if ("STOPEDITING".equals(actionCommand)) { |
32 |
stopEditing(table); |
33 |
} |
34 |
/* IEditableSource edTable = (IEditableSource) table.getModel().getAssociatedTable();
|
35 |
edTable.getCommandRecord().removeCommandListener(table); */
|
36 |
|
37 |
} |
38 |
|
39 |
/**
|
40 |
* DOCUMENT ME!
|
41 |
*/
|
42 |
public void stopEditing(Table table) { |
43 |
int resp = JOptionPane |
44 |
.showConfirmDialog(null, PluginServices.getText(this, |
45 |
"realmente_desea_guardar") +" : "+ table.getModel().getName(), "Guardar", |
46 |
JOptionPane.YES_NO_OPTION);
|
47 |
if (resp == JOptionPane.NO_OPTION) { // CANCEL EDITING |
48 |
try {
|
49 |
table.cancelEditing(); |
50 |
} catch (IOException e) { |
51 |
e.printStackTrace(); |
52 |
} |
53 |
} else { // GUARDAMOS LA TABLA |
54 |
table.stopEditing(); |
55 |
} |
56 |
} |
57 |
|
58 |
|
59 |
/**
|
60 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
61 |
*/
|
62 |
public boolean isEnabled() { |
63 |
return true; |
64 |
} |
65 |
|
66 |
/**
|
67 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
68 |
*/
|
69 |
public boolean isVisible() { |
70 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
71 |
|
72 |
if (v == null) { |
73 |
return false; |
74 |
} else if (v instanceof Table && ((Table) v).isEditing() && ((Table)v).getModel().getAssociatedTable()==null) { |
75 |
return true; |
76 |
} else {
|
77 |
return false; |
78 |
} |
79 |
} |
80 |
} |