Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / applications / appgvSIG / src / com / iver / cit / gvsig / TableEditStopExtension.java @ 7365

History | View | Annotate | Download (2.36 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.messages.NotificationManager;
9
import com.iver.andami.plugins.Extension;
10
import com.iver.andami.ui.mdiManager.IWindow;
11
import com.iver.cit.gvsig.fmap.MapControl;
12
import com.iver.cit.gvsig.fmap.edition.EditionEvent;
13
import com.iver.cit.gvsig.fmap.edition.EditionException;
14
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter;
15
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
16
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
17
import com.iver.cit.gvsig.gui.Table;
18

    
19

    
20
/**
21
 * DOCUMENT ME!
22
 *
23
 * @author Vicente Caballero Navarro
24
 */
25
public class TableEditStopExtension extends Extension {
26
    /**
27
     * @see com.iver.andami.plugins.IExtension#initialize()
28
     */
29
    public void initialize() {
30
    }
31

    
32
    /**
33
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
34
     */
35
    public void execute(String actionCommand) {
36
            IWindow v = PluginServices.getMDIManager().getActiveWindow();
37
            Table table = (Table) v;
38
        if ("STOPEDITING".equals(actionCommand)) {
39
            stopEditing(table);
40
        }
41
                /* IEditableSource edTable = (IEditableSource) table.getModel().getAssociatedTable();
42
                edTable.getCommandRecord().removeCommandListener(table); */
43

    
44
    }
45

    
46
    /**
47
         * DOCUMENT ME!
48
         */
49
        public void stopEditing(Table table) {
50
                int resp = JOptionPane
51
                                .showConfirmDialog(null, PluginServices.getText(this,
52
                                                "realmente_desea_guardar") +" : "+ table.getModel().getName(), "Guardar",
53
                                                JOptionPane.YES_NO_OPTION);
54
                        if (resp == JOptionPane.NO_OPTION) { // CANCEL EDITING
55
                                try {
56
                                        table.cancelEditing();
57
                                } catch (IOException e) {
58
                                        e.printStackTrace();
59
                                }
60
                        } else { // GUARDAMOS LA TABLA
61
                                table.stopEditing();
62
                        }
63
        }
64

    
65

    
66
    /**
67
     * @see com.iver.andami.plugins.IExtension#isEnabled()
68
     */
69
    public boolean isEnabled() {
70
       return true;
71
    }
72

    
73
    /**
74
     * @see com.iver.andami.plugins.IExtension#isVisible()
75
     */
76
    public boolean isVisible() {
77
        IWindow v = PluginServices.getMDIManager().getActiveWindow();
78

    
79
        if (v == null) {
80
            return false;
81
        } else if (v instanceof Table && ((Table) v).isEditing() && ((Table)v).getModel().getAssociatedTable()==null) {
82
            return true;
83
        } else {
84
            return false;
85
        }
86
    }
87
}