Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / RemoveTableUnion.java @ 9532

History | View | Annotate | Download (1.98 KB)

1
package com.iver.cit.gvsig;
2

    
3
import com.hardcode.driverManager.DriverLoadException;
4
import com.hardcode.gdbms.engine.data.driver.DriverException;
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.IWindow;
9
import com.iver.cit.gvsig.project.documents.table.ProjectTable;
10
import com.iver.cit.gvsig.project.documents.table.gui.Table;
11

    
12
/**
13
 * @author Fernando Gonz?lez Cort?s
14
 */
15
public class RemoveTableUnion extends Extension{
16

    
17
        /**
18
         * @see com.iver.andami.plugins.IExtension#initialize()
19
         */
20
        public void initialize() {
21
                // TODO Auto-generated method stub
22

    
23
        }
24

    
25
        /**
26
         * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
27
         */
28
        public void execute(String actionCommand) {
29
                Table t = (Table) PluginServices.getMDIManager().getActiveWindow();
30
                ProjectTable pt = t.getModel();
31
                try {
32
            pt.restoreDataSource();
33
            // Por si acaso ten?amos seleccionado un campo
34
            // de los de la uni?n, no seleccionamos
35
            // ning?n campo.
36
            t.clearSelectedFields();
37

    
38
        } catch (DriverException e) {
39
            NotificationManager.addError(e.getMessage(), e);
40
        } catch (DriverLoadException e) {
41
                        // TODO Auto-generated catch block
42
                        e.printStackTrace();
43
                }
44
        t.getModel().setModified(true);
45
        }
46

    
47
        /**
48
         * @see com.iver.andami.plugins.IExtension#isEnabled()
49
         */
50
        public boolean isEnabled() {
51
                IWindow v = PluginServices.getMDIManager().getActiveWindow();
52

    
53
                if (v == null) {
54
                        return false;
55
                }
56

    
57
                if (v.getClass() == Table.class) {
58
                        Table t = (Table) v;
59
                        if (t.getModel().getOriginal() != null){
60
                                return true;
61
                        }
62
                }
63
                return false;
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
                }
75

    
76
                if (v instanceof Table) {
77
                        return true;
78
                } else {
79
                        return false;
80
                }
81

    
82
        }
83

    
84
}