Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / RemoveTableUnion.java @ 7304

History | View | Annotate | Download (1.94 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
        }
45

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

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

    
56
                if (v.getClass() == Table.class) {
57
                        Table t = (Table) v;
58
                        if (t.getModel().getOriginal() != null){
59
                                return true;
60
                        }
61
                }
62
                return false;
63
        }
64

    
65
        /**
66
         * @see com.iver.andami.plugins.IExtension#isVisible()
67
         */
68
        public boolean isVisible() {
69
                IWindow v = PluginServices.getMDIManager().getActiveWindow();
70

    
71
                if (v == null) {
72
                        return false;
73
                }
74

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

    
81
        }
82

    
83
}