Statistics
| Revision:

root / branches / v10 / applications / appgvSIG / src / com / iver / cit / gvsig / TableEditStopExtension.java @ 11143

History | View | Annotate | Download (2.02 KB)

1 2936 caballero
package com.iver.cit.gvsig;
2
3 3996 caballero
import java.io.IOException;
4
5 5318 caballero
import javax.swing.JOptionPane;
6
7 2936 caballero
import com.iver.andami.PluginServices;
8
import com.iver.andami.plugins.Extension;
9 6877 cesar
import com.iver.andami.ui.mdiManager.IWindow;
10 8765 jjdelcerro
import com.iver.cit.gvsig.project.documents.table.gui.Table;
11 2936 caballero
12
13
/**
14
 * DOCUMENT ME!
15
 *
16
 * @author Vicente Caballero Navarro
17
 */
18 5005 jorpiell
public class TableEditStopExtension extends Extension {
19 2936 caballero
    /**
20 5005 jorpiell
     * @see com.iver.andami.plugins.IExtension#initialize()
21 2936 caballero
     */
22 5005 jorpiell
    public void initialize() {
23 2936 caballero
    }
24
25
    /**
26 5005 jorpiell
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
27 2936 caballero
     */
28
    public void execute(String actionCommand) {
29 6880 cesar
            IWindow v = PluginServices.getMDIManager().getActiveWindow();
30 4475 fjp
            Table table = (Table) v;
31 5318 caballero
        if ("STOPEDITING".equals(actionCommand)) {
32
            stopEditing(table);
33 2936 caballero
        }
34 4535 fjp
                /* IEditableSource edTable = (IEditableSource) table.getModel().getAssociatedTable();
35
                edTable.getCommandRecord().removeCommandListener(table); */
36 4475 fjp
37 2936 caballero
    }
38
39
    /**
40 5318 caballero
         * 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 5005 jorpiell
     * @see com.iver.andami.plugins.IExtension#isEnabled()
61 2936 caballero
     */
62
    public boolean isEnabled() {
63 5081 caballero
       return true;
64 2936 caballero
    }
65
66
    /**
67 5005 jorpiell
     * @see com.iver.andami.plugins.IExtension#isVisible()
68 2936 caballero
     */
69
    public boolean isVisible() {
70 6880 cesar
        IWindow v = PluginServices.getMDIManager().getActiveWindow();
71 2936 caballero
72
        if (v == null) {
73
            return false;
74 5900 jorpiell
        } else if (v instanceof Table && ((Table) v).isEditing() && ((Table)v).getModel().getAssociatedTable()==null) {
75 2936 caballero
            return true;
76
        } else {
77
            return false;
78
        }
79
    }
80
}