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