Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / TableEditStopExtension.java @ 11195

History | View | Annotate | Download (2.07 KB)

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