Statistics
| Revision:

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

History | View | Annotate | Download (1.98 KB)

1 1830 fernando
package com.iver.cit.gvsig;
2
3 3940 caballero
import com.hardcode.driverManager.DriverLoadException;
4 10626 caballero
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
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 10626 caballero
        } catch (ReadDriverException e) {
39 2581 fernando
            NotificationManager.addError(e.getMessage(), e);
40 3940 caballero
        } catch (DriverLoadException e) {
41
                        // TODO Auto-generated catch block
42
                        e.printStackTrace();
43
                }
44 9532 caballero
        t.getModel().setModified(true);
45 1830 fernando
        }
46
47
        /**
48 5005 jorpiell
         * @see com.iver.andami.plugins.IExtension#isEnabled()
49 1830 fernando
         */
50
        public boolean isEnabled() {
51 6880 cesar
                IWindow v = PluginServices.getMDIManager().getActiveWindow();
52 1830 fernando
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 5005 jorpiell
         * @see com.iver.andami.plugins.IExtension#isVisible()
68 1830 fernando
         */
69
        public boolean isVisible() {
70 6880 cesar
                IWindow v = PluginServices.getMDIManager().getActiveWindow();
71 1830 fernando
72
                if (v == null) {
73
                        return false;
74
                }
75
76 5900 jorpiell
                if (v instanceof Table) {
77 1830 fernando
                        return true;
78
                } else {
79
                        return false;
80
                }
81
82
        }
83
84
}