Revision 24965
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/project/document/table/FeatureTableDocument.java | ||
---|---|---|
29 | 29 |
import org.gvsig.fmap.dal.exception.DataException; |
30 | 30 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
31 | 31 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
32 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
32 | 33 |
import org.gvsig.project.document.table.gui.FeatureTableDocumentPanel; |
33 | 34 |
|
34 | 35 |
import com.iver.andami.ui.mdiManager.IWindow; |
... | ... | |
36 | 37 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
37 | 38 |
import com.iver.cit.gvsig.project.documents.exceptions.OpenException; |
38 | 39 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
39 |
import com.iver.cit.gvsig.project.documents.table.LinkSelectionObserver; |
|
40 | 40 |
import com.iver.utiles.XMLEntity; |
41 | 41 |
import com.iver.utiles.XMLException; |
42 | 42 |
|
... | ... | |
59 | 59 |
|
60 | 60 |
private LinkSelectionObserver linkSelectionObserver; |
61 | 61 |
|
62 |
private FLyrVect associatedTable; |
|
62 | 63 |
|
63 | 64 |
|
64 | 65 |
public FeatureTableDocument(FeatureStore store) { |
... | ... | |
189 | 190 |
|
190 | 191 |
} |
191 | 192 |
|
193 |
public FLyrVect getAssociatedLayer() { |
|
194 |
return associatedTable; |
|
195 |
} |
|
192 | 196 |
|
197 |
/** |
|
198 |
* DOCUMENT ME! |
|
199 |
* |
|
200 |
* @param associatedTable |
|
201 |
* DOCUMENT ME! |
|
202 |
*/ |
|
203 |
public void setAssociatedLayer(FLyrVect associatedTable) { |
|
204 |
this.associatedTable = associatedTable; |
|
205 |
} |
|
193 | 206 |
|
207 |
|
|
208 |
|
|
209 |
|
|
194 | 210 |
} |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/project/document/table/LinkSelectionObserver.java | ||
---|---|---|
1 |
package org.gvsig.project.document.table; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
|
|
6 |
import org.gvsig.fmap.dal.exception.DataException; |
|
7 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
8 |
import org.gvsig.fmap.dal.feature.Feature; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
12 |
import org.gvsig.tools.observer.Observable; |
|
13 |
import org.gvsig.tools.observer.Observer; |
|
14 |
|
|
15 |
public class LinkSelectionObserver implements Observer{ |
|
16 |
private int field1; |
|
17 |
private int field2; |
|
18 |
private FeatureStore fs1; |
|
19 |
private FeatureStore fs2; |
|
20 |
public LinkSelectionObserver(FeatureStore modelo, FeatureStore modelo2, String field1, String field2) { |
|
21 |
this.fs1=modelo; |
|
22 |
this.fs2=modelo2; |
|
23 |
try { |
|
24 |
this.field1=fs1.getDefaultFeatureType().getIndex(field1); |
|
25 |
this.field2=fs2.getDefaultFeatureType().getIndex(field2); |
|
26 |
} catch (DataException e) { |
|
27 |
// TODO Auto-generated catch block |
|
28 |
e.printStackTrace(); |
|
29 |
} |
|
30 |
} |
|
31 |
public void update(Observable arg0, Object arg1) { |
|
32 |
try{ |
|
33 |
FeatureSet fCollection1 = (FeatureSet)fs1.getSelection(); |
|
34 |
FeatureSelection fCollection2 = (FeatureSelection)fs2.createSelection(); |
|
35 |
ArrayList idx = new ArrayList(); |
|
36 |
|
|
37 |
// Construimos el ?ndice |
|
38 |
Iterator iterator1=fCollection1.iterator(); |
|
39 |
while (iterator1.hasNext()) { |
|
40 |
Feature feature = (Feature) iterator1.next(); |
|
41 |
Object obj=feature.get(field1); |
|
42 |
if (!idx.contains(obj)) { |
|
43 |
idx.add(obj); |
|
44 |
} |
|
45 |
} |
|
46 |
// for (int i = bs1.nextSetBit(0); i >= 0; |
|
47 |
// i = bs1.nextSetBit(i + 1)) { |
|
48 |
// Value v = modelo1.getFieldValue((long) i, index1); |
|
49 |
|
|
50 |
// if (idx.get(v) == null) { |
|
51 |
// idx.put(v, new Integer(i)); |
|
52 |
// } |
|
53 |
// } |
|
54 |
|
|
55 |
try { |
|
56 |
Iterator iterator2=fs2.getFeatureSet().iterator(); |
|
57 |
while (iterator2.hasNext()) { |
|
58 |
Feature feature = (Feature) iterator2.next(); |
|
59 |
Object obj=feature.get(field2); |
|
60 |
if (idx.contains(obj)){ |
|
61 |
fCollection2.select(feature); |
|
62 |
} |
|
63 |
} |
|
64 |
// Integer pi = (Integer) idx.get(obj); |
|
65 |
// if (pi != null) { |
|
66 |
// bs2.set(i); |
|
67 |
// } |
|
68 |
|
|
69 |
// for (int i = 0; i < modelo2.getRowCount(); i++) { |
|
70 |
// Value v = modelo2.getFieldValue(i, index2); |
|
71 |
// Integer pi = (Integer) idx.get(v); |
|
72 |
|
|
73 |
// if (pi != null) { |
|
74 |
// bs2.set(i); |
|
75 |
// } |
|
76 |
// } |
|
77 |
} catch (ReadException e1) { |
|
78 |
e1.printStackTrace(); |
|
79 |
} |
|
80 |
|
|
81 |
// this applies the selection to the linked table |
|
82 |
if (fs1!=fs2) { |
|
83 |
try { |
|
84 |
fs2.setSelection(fCollection2); |
|
85 |
} catch (DataException e) { |
|
86 |
// TODO Auto-generated catch block |
|
87 |
e.printStackTrace(); |
|
88 |
} |
|
89 |
//modelo2.fireSelectionEvents(); |
|
90 |
} |
|
91 |
} catch (DataException e2) { |
|
92 |
// TODO Auto-generated catch block |
|
93 |
e2.printStackTrace(); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
} |
Also available in: Unified diff