Statistics
| Revision:

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

History | View | Annotate | Download (1.94 KB)

1
package com.iver.cit.gvsig;
2

    
3
import java.io.IOException;
4

    
5
import com.iver.andami.PluginServices;
6
import com.iver.andami.messages.NotificationManager;
7
import com.iver.andami.plugins.Extension;
8
import com.iver.andami.ui.mdiManager.View;
9
import com.iver.cit.gvsig.fmap.edition.IEditableSource;
10
import com.iver.cit.gvsig.gui.Table;
11

    
12

    
13
/**
14
 * DOCUMENT ME!
15
 *
16
 * @author Vicente Caballero Navarro
17
 */
18
public class TableEditStopExtension implements Extension {
19
    /**
20
     * @see com.iver.andami.plugins.Extension#inicializar()
21
     */
22
    public void inicializar() {
23
    }
24

    
25
    /**
26
     * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
27
     */
28
    public void execute(String actionCommand) {
29
            View v = PluginServices.getMDIManager().getActiveView();
30
            Table table = (Table) v;
31
        if ("ROLLBACK".equals(actionCommand)) {
32
             try {
33
                                table.cancelEditing();
34
                        } catch (IOException e) {
35
                                NotificationManager.addError("No se pudo cancelar la edici?n", e);
36
                        }
37
        } else if ("COMMIT".equals(actionCommand)) {
38
            table.stopEditing();
39

    
40
        }
41
                IEditableSource edTable = (IEditableSource) table.getModel().getAssociatedTable();
42
                edTable.getCommandRecord().removeCommandListener(table);
43

    
44
    }
45

    
46
    /**
47
     * @see com.iver.andami.plugins.Extension#isEnabled()
48
     */
49
    public boolean isEnabled() {
50
        View v = PluginServices.getMDIManager().getActiveView();
51

    
52
        if (v == null) {
53
            return false;
54
        } else if (v.getClass() == Table.class) {
55
            return ((Table) v).isEditing();
56
        } else {
57
            return false;
58
        }
59
    }
60

    
61
    /**
62
     * @see com.iver.andami.plugins.Extension#isVisible()
63
     */
64
    public boolean isVisible() {
65
        View v = PluginServices.getMDIManager().getActiveView();
66

    
67
        if (v == null) {
68
            return false;
69
        } else if (v.getClass() == Table.class) {
70
            return true;
71
        } else {
72
            return false;
73
        }
74
    }
75
}