root / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / layers / LinkSelectionListener.java @ 38581
History | View | Annotate | Download (4.02 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.fmap.mapcontext.layers; |
42 |
|
43 |
|
44 |
|
45 |
/**
|
46 |
* Listener que est? pendiente de la selecci?n que se haga sobre la tabla para
|
47 |
* poder seleccionar de la tabla linkada los registros oportunos.
|
48 |
*
|
49 |
* @author Vicente Caballero Navarro
|
50 |
* @deprecated TODO Esto tendr?a que estar en appgvSIG en las tablas
|
51 |
*/
|
52 |
public class LinkSelectionListener implements SelectionListener { |
53 |
// private SelectableDataSource modelo1;
|
54 |
// private SelectableDataSource modelo2;
|
55 |
private int index1; |
56 |
private int index2; |
57 |
|
58 |
/**
|
59 |
* Crea un nuevo LinkSelectionListener. Donde se pasan como par?metros dos
|
60 |
* SelectableDataSource, el primero de ellos(model1), representa la tabla
|
61 |
* sobre la que al seleccionar alg?n registro buscaremos en el modelo2
|
62 |
* para ver el valor del campo s1 y compararlo con el valor del campo s2 y
|
63 |
* de esta forma seleccionar instantanemente los registros oportunos en la
|
64 |
* tabla al que se representa con el modelo2.
|
65 |
*
|
66 |
* @param model1 SelectableDataSource de la tabla sobre la que se efectua
|
67 |
* el link.
|
68 |
* @param model2 SelectableDataSource de la tabla linkada.
|
69 |
* @param s1 nombre del campo de la tabla donde se efectua el link.
|
70 |
* @param s2 nombre del campo de la tabla linkada.
|
71 |
*/
|
72 |
// public LinkSelectionListener(SelectableDataSource model1,
|
73 |
// SelectableDataSource model2, String s1, String s2) {
|
74 |
// modelo1 = model1;
|
75 |
// modelo2 = model2;
|
76 |
//
|
77 |
// try {
|
78 |
// index1 = modelo1.getFieldIndexByName(s1);
|
79 |
// index2 = modelo2.getFieldIndexByName(s2);
|
80 |
// } catch (ReadDriverException e) {
|
81 |
// e.printStackTrace();
|
82 |
// }
|
83 |
//
|
84 |
// //field1 = s1;
|
85 |
// //field2 = s2;
|
86 |
// }
|
87 |
|
88 |
/**
|
89 |
* @see com.iver.cit.gvsig.fmap.layers.LegendListener#selectionChanged(com.iver.cit.gvsig.fmap.layers.LayerEvent)
|
90 |
*/
|
91 |
public void selectionChanged(SelectionEvent e) { |
92 |
// FBitSet bs1 = modelo1.getSelection();
|
93 |
// FBitSet bs2 = new FBitSet(); //(FBitSet)modelo2.getSelection().clone();
|
94 |
// HashMap idx = new HashMap(bs1.cardinality());
|
95 |
// //int index1 = -1;
|
96 |
// //int index2 = -1;
|
97 |
//
|
98 |
// try {
|
99 |
// // Construimos el ?ndice
|
100 |
// for (int i = bs1.nextSetBit(0); i >= 0;
|
101 |
// i = bs1.nextSetBit(i + 1)) {
|
102 |
// Value v = modelo1.getFieldValue((long) i, index1);
|
103 |
//
|
104 |
// if (idx.get(v) == null) {
|
105 |
// idx.put(v, new Integer(i));
|
106 |
// }
|
107 |
// }
|
108 |
// } catch (ReadDriverException e2) {
|
109 |
// e2.printStackTrace();
|
110 |
// }
|
111 |
//
|
112 |
// try {
|
113 |
// for (int i = 0; i < modelo2.getRowCount(); i++) {
|
114 |
// Value v = modelo2.getFieldValue(i, index2);
|
115 |
// Integer pi = (Integer) idx.get(v);
|
116 |
//
|
117 |
// if (pi != null) {
|
118 |
// bs2.set(i);
|
119 |
// }
|
120 |
// }
|
121 |
// } catch (ReadDriverException e1) {
|
122 |
// e1.printStackTrace();
|
123 |
// }
|
124 |
//
|
125 |
// // this applies the selection to the linked table
|
126 |
// if (modelo1!=modelo2)
|
127 |
// modelo2.setSelection(bs2);
|
128 |
// //modelo2.fireSelectionEvents();
|
129 |
} |
130 |
} |