Statistics
| Revision:

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

History | View | Annotate | Download (1.94 KB)

1 1830 fernando
package com.iver.cit.gvsig;
2
3 3940 caballero
import com.hardcode.driverManager.DriverLoadException;
4 2581 fernando
import com.hardcode.gdbms.engine.data.driver.DriverException;
5 1830 fernando
import com.iver.andami.PluginServices;
6 2581 fernando
import com.iver.andami.messages.NotificationManager;
7 1830 fernando
import com.iver.andami.plugins.Extension;
8 6877 cesar
import com.iver.andami.ui.mdiManager.IWindow;
9 7304 caballero
import com.iver.cit.gvsig.project.documents.table.ProjectTable;
10
import com.iver.cit.gvsig.project.documents.table.gui.Table;
11 1830 fernando
12
/**
13
 * @author Fernando Gonz?lez Cort?s
14
 */
15 5005 jorpiell
public class RemoveTableUnion extends Extension{
16 1830 fernando
17
        /**
18 5005 jorpiell
         * @see com.iver.andami.plugins.IExtension#initialize()
19 1830 fernando
         */
20 5005 jorpiell
        public void initialize() {
21 1830 fernando
                // TODO Auto-generated method stub
22 3940 caballero
23 1830 fernando
        }
24
25
        /**
26 5005 jorpiell
         * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
27 1830 fernando
         */
28
        public void execute(String actionCommand) {
29 6880 cesar
                Table t = (Table) PluginServices.getMDIManager().getActiveWindow();
30 1830 fernando
                ProjectTable pt = t.getModel();
31 2581 fernando
                try {
32
            pt.restoreDataSource();
33 2701 fjp
            // 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 3940 caballero
38 2581 fernando
        } catch (DriverException e) {
39
            NotificationManager.addError(e.getMessage(), e);
40 3940 caballero
        } catch (DriverLoadException e) {
41
                        // TODO Auto-generated catch block
42
                        e.printStackTrace();
43
                }
44 1830 fernando
        }
45
46
        /**
47 5005 jorpiell
         * @see com.iver.andami.plugins.IExtension#isEnabled()
48 1830 fernando
         */
49
        public boolean isEnabled() {
50 6880 cesar
                IWindow v = PluginServices.getMDIManager().getActiveWindow();
51 1830 fernando
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 5005 jorpiell
         * @see com.iver.andami.plugins.IExtension#isVisible()
67 1830 fernando
         */
68
        public boolean isVisible() {
69 6880 cesar
                IWindow v = PluginServices.getMDIManager().getActiveWindow();
70 1830 fernando
71
                if (v == null) {
72
                        return false;
73
                }
74
75 5900 jorpiell
                if (v instanceof Table) {
76 1830 fernando
                        return true;
77
                } else {
78
                        return false;
79
                }
80
81
        }
82
83
}