Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.api / src / main / java / org / gvsig / fmap / mapcontext / layers / LinkSelectionListener.java @ 40559

History | View | Annotate | Download (3.75 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.mapcontext.layers;
25

    
26

    
27

    
28
/**
29
 * Listener que est? pendiente de la selecci?n que se haga sobre la tabla para
30
 * poder seleccionar de la tabla linkada los registros oportunos.
31
 *
32
 * @author Vicente Caballero Navarro
33
 * @deprecated TODO Esto tendr?a que estar en appgvSIG en las tablas
34
 */
35
public class LinkSelectionListener implements SelectionListener {
36
//        private SelectableDataSource modelo1;
37
//        private SelectableDataSource modelo2;
38
        private int index1;
39
        private int index2;
40

    
41
        /**
42
         * Crea un nuevo LinkSelectionListener. Donde se pasan como par?metros dos
43
         * SelectableDataSource, el primero de ellos(model1), representa la tabla
44
         * sobre la que al seleccionar alg?n registro buscaremos en el modelo2
45
         * para ver el valor del campo s1 y compararlo con el valor del campo s2 y
46
         * de esta forma seleccionar instantanemente los registros oportunos en la
47
         * tabla al que se representa con el modelo2.
48
         *
49
         * @param model1 SelectableDataSource de la tabla sobre la que se efectua
50
         *                   el link.
51
         * @param model2 SelectableDataSource de la tabla linkada.
52
         * @param s1 nombre del campo de la tabla donde se efectua el link.
53
         * @param s2 nombre del campo de la tabla linkada.
54
         */
55
//        public LinkSelectionListener(SelectableDataSource model1,
56
//                SelectableDataSource model2, String s1, String s2) {
57
//                modelo1 = model1;
58
//                modelo2 = model2;
59
//
60
//                try {
61
//                        index1 = modelo1.getFieldIndexByName(s1);
62
//                        index2 = modelo2.getFieldIndexByName(s2);
63
//                } catch (ReadDriverException e) {
64
//                        e.printStackTrace();
65
//                }
66
//
67
//                //field1 = s1;
68
//                //field2 = s2;
69
//        }
70

    
71
        /**
72
         * @see com.iver.cit.gvsig.fmap.layers.LegendListener#selectionChanged(com.iver.cit.gvsig.fmap.layers.LayerEvent)
73
         */
74
        public void selectionChanged(SelectionEvent e) {
75
//                FBitSet bs1 = modelo1.getSelection();
76
//                FBitSet bs2 = new FBitSet(); //(FBitSet)modelo2.getSelection().clone();
77
//                HashMap idx = new HashMap(bs1.cardinality());
78
//                //int index1 = -1;
79
//                //int index2 = -1;
80
//
81
//                try {
82
//                        //                Construimos el ?ndice
83
//                        for (int i = bs1.nextSetBit(0); i >= 0;
84
//                                        i = bs1.nextSetBit(i + 1)) {
85
//                                Value v = modelo1.getFieldValue((long) i, index1);
86
//
87
//                                if (idx.get(v) == null) {
88
//                                        idx.put(v, new Integer(i));
89
//                                }
90
//                        }
91
//                } catch (ReadDriverException e2) {
92
//                        e2.printStackTrace();
93
//                }
94
//
95
//                try {
96
//                        for (int i = 0; i < modelo2.getRowCount(); i++) {
97
//                                Value v = modelo2.getFieldValue(i, index2);
98
//                                Integer pi = (Integer) idx.get(v);
99
//
100
//                                if (pi != null) {
101
//                                        bs2.set(i);
102
//                                }
103
//                        }
104
//                } catch (ReadDriverException e1) {
105
//                        e1.printStackTrace();
106
//                }
107
//
108
//                // this applies the selection to the linked table
109
//                if (modelo1!=modelo2)
110
//                        modelo2.setSelection(bs2);
111
//                //modelo2.fireSelectionEvents();
112
        }
113
}