Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / RemoveTableUnion.java @ 24962

History | View | Annotate | Download (2.65 KB)

1 1830 fernando
package com.iver.cit.gvsig;
2
3 24962 vcaballero
import org.gvsig.fmap.dal.DALLocator;
4 24759 jmvivo
import org.gvsig.fmap.dal.DataManager;
5
import org.gvsig.fmap.dal.DataStoreParameters;
6
import org.gvsig.fmap.dal.exception.CloseException;
7
import org.gvsig.fmap.dal.exception.InitializeException;
8
import org.gvsig.fmap.dal.feature.FeatureStore;
9 24962 vcaballero
import org.gvsig.project.document.table.FeatureTableDocument;
10
import org.gvsig.project.document.table.gui.FeatureTableDocumentPanel;
11 21354 vcaballero
12 1830 fernando
import com.iver.andami.PluginServices;
13 2581 fernando
import com.iver.andami.messages.NotificationManager;
14 1830 fernando
import com.iver.andami.plugins.Extension;
15 6877 cesar
import com.iver.andami.ui.mdiManager.IWindow;
16 1830 fernando
17
/**
18
 * @author Fernando Gonz?lez Cort?s
19
 */
20 5005 jorpiell
public class RemoveTableUnion extends Extension{
21 1830 fernando
22
        /**
23 5005 jorpiell
         * @see com.iver.andami.plugins.IExtension#initialize()
24 1830 fernando
         */
25 5005 jorpiell
        public void initialize() {
26 1830 fernando
                // TODO Auto-generated method stub
27 3940 caballero
28 1830 fernando
        }
29
30
        /**
31 5005 jorpiell
         * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
32 1830 fernando
         */
33
        public void execute(String actionCommand) {
34 24962 vcaballero
                FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) PluginServices.getMDIManager().getActiveWindow();
35
                FeatureTableDocument pt = t.getModel();
36
                FeatureStore fs = pt.getStore();
37 22932 jmvivo
                if (fs instanceof JoinFeatureStore) {
38 24962 vcaballero
                        DataManager dm = DALLocator.getDataManager();
39 22932 jmvivo
                        DataStoreParameters originalParams = ((JoinFeatureStoreParameters) fs
40
                                        .getParameters()).getStorePrimary();
41
                        FeatureStore original = null;
42
                        try {
43 24962 vcaballero
                                original = (FeatureStore) dm.createStore(originalParams);
44 22932 jmvivo
                        } catch (InitializeException e) {
45
                                NotificationManager.addError(e.getMessage(), e);
46
                                return;
47 22477 vcaballero
                        }
48
49 22932 jmvivo
                        pt.setModel(original);
50
                        try {
51
                                fs.dispose();
52
                        } catch (CloseException e) {
53
                                NotificationManager.addError(e);
54
                        }
55
                        t.setModel(pt);
56 3940 caballero
57 22932 jmvivo
                }
58
59
                t.clearSelectedFields();
60
                t.getModel().setModified(true);
61 1830 fernando
        }
62
63
        /**
64 5005 jorpiell
         * @see com.iver.andami.plugins.IExtension#isEnabled()
65 1830 fernando
         */
66
        public boolean isEnabled() {
67 6880 cesar
                IWindow v = PluginServices.getMDIManager().getActiveWindow();
68 1830 fernando
69
                if (v == null) {
70
                        return false;
71
                }
72
73 24962 vcaballero
                if (v.getClass() == FeatureTableDocumentPanel.class) {
74
                        FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) v;
75 22932 jmvivo
                        // FIXME !!!! Asi se hacia antes
76
                        //                        if (t.getModel().getOriginal() != null){
77
                        //                                return true;
78
                        //                        }
79
80 24962 vcaballero
                        FeatureTableDocument pt = t.getModel();
81
                        FeatureStore fs = pt.getStore();
82 22932 jmvivo
                        if (fs instanceof JoinFeatureStore) {
83 1830 fernando
                                return true;
84
                        }
85 22932 jmvivo
86 1830 fernando
                }
87
                return false;
88
        }
89
90
        /**
91 5005 jorpiell
         * @see com.iver.andami.plugins.IExtension#isVisible()
92 1830 fernando
         */
93
        public boolean isVisible() {
94 6880 cesar
                IWindow v = PluginServices.getMDIManager().getActiveWindow();
95 1830 fernando
96
                if (v == null) {
97
                        return false;
98
                }
99
100 24962 vcaballero
                if (v instanceof FeatureTableDocumentPanel) {
101 1830 fernando
                        return true;
102
                } else {
103
                        return false;
104
                }
105
106
        }
107
108
}