Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSSelectFieldsPanel.java @ 4911

History | View | Annotate | Download (6.59 KB)

1 4911 jorpiell
package com.iver.cit.gvsig.gui.panels;
2
3
import javax.swing.ImageIcon;
4
import javax.swing.JButton;
5
import javax.swing.JCheckBox;
6
import javax.swing.JPanel;
7
import javax.swing.JScrollPane;
8
import javax.swing.JTextField;
9
10
import com.iver.andami.PluginServices;
11
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
12
import com.iver.cit.gvsig.gui.wizards.WFSWizardData;
13
import javax.swing.JList;
14
import java.awt.Dimension;
15
import java.util.ArrayList;
16
import java.util.Hashtable;
17
18
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
19
 *
20
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
21
 *
22
 * This program is free software; you can redistribute it and/or
23
 * modify it under the terms of the GNU General Public License
24
 * as published by the Free Software Foundation; either version 2
25
 * of the License, or (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
35
 *
36
 * For more information, contact:
37
 *
38
 *  Generalitat Valenciana
39
 *   Conselleria d'Infraestructures i Transport
40
 *   Av. Blasco Ib??ez, 50
41
 *   46010 VALENCIA
42
 *   SPAIN
43
 *
44
 *      +34 963862235
45
 *   gvsig@gva.es
46
 *      www.gvsig.gva.es
47
 *
48
 *    or
49
 *
50
 *   IVER T.I. S.A
51
 *   Salamanca 50
52
 *   46005 Valencia
53
 *   Spain
54
 *
55
 *   +34 963163400
56
 *   dac@iver.es
57
 */
58
/* CVS MESSAGES:
59
 *
60
 * $Id$
61
 * $Log$
62
 * Revision 1.1  2006-04-20 16:38:24  jorpiell
63
 * Ahora mismo ya se puede hacer un getCapabilities y un getDescribeType de la capa seleccionada para ver los atributos a dibujar. Queda implementar el panel de opciones y hacer el getFeature().
64
 *
65
 *
66
 */
67
/**
68
 * This panel shows the feature fields list
69
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
70
 */
71
public class WFSSelectFieldsPanel extends JPanel {
72
        private static final long serialVersionUID = 3073243334672620143L;
73
        private JButton btnAddTime = null;
74
        private JButton btnDelTime = null;
75
        private JScrollPane jScrollPane3 = null;
76
        private JScrollPane jScrollPane4 = null;
77
        private JList lstFeatures = null;
78
        private JList lstSelectedFeatures = null;
79
80
        public WFSSelectFieldsPanel(){
81
                super();
82
                initialize();
83
        }
84
85
        public void initialize(){
86
                this.setLayout(null);
87
                this.setBounds(5, 17, 464, 374);
88
                this.setBorder(javax.swing.BorderFactory.createTitledBorder(
89
                                null, PluginServices.getText(this, "select_fields"),
90
                                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
91
                                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
92
                this.add(getBtnAddTime(), null);
93
                this.add(getBtnDelTime(), null);
94
                this.add(getJScrollPane3(), null);
95
                this.add(getJScrollPane4(), null);
96
        }
97
98
        /**
99
         * This method initializes jButton2
100
         *
101
         * @return javax.swing.JButton
102
         */
103
        public JButton getBtnAddTime() {
104
                if (btnAddTime == null) {
105
                        btnAddTime = new JButton();
106
                        btnAddTime.setBounds(241, 175, 50, 20);
107
                        btnAddTime.setText(">");
108
                        btnAddTime.addActionListener(
109
                                new java.awt.event.ActionListener() {
110
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
111
                                                addFeature();
112
                                        }
113
                                });
114
                }
115
                return btnAddTime;
116
        }
117
118
        /**
119
         * This method initializes btnDelTemps
120
         *
121
         * @return javax.swing.JButton
122
         */
123
        public JButton getBtnDelTime() {
124
                if (btnDelTime == null) {
125
                        btnDelTime = new JButton();
126
                        btnDelTime.setText("<");
127
                        btnDelTime.setBounds(181, 175, 50, 20);
128
                        btnDelTime.addActionListener(
129
                                new java.awt.event.ActionListener() {
130
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
131
                                                delFeature();
132
                                        }
133
                                });
134
                }
135
                return btnDelTime;
136
        }
137
138
        /**
139
         * This method initializes jScrollPane3
140
         *
141
         * @return javax.swing.JScrollPane
142
         */
143
        private JScrollPane getJScrollPane3() {
144
                if (jScrollPane3 == null) {
145
                        jScrollPane3 = new JScrollPane();
146
                        jScrollPane3.setBounds(10, 30, 158, 334);
147
                        jScrollPane3.setViewportView(getLstFeatures());
148
                }
149
                return jScrollPane3;
150
        }
151
152
        /**
153
         * This method initializes jScrollPane4
154
         *
155
         * @return javax.swing.JScrollPane
156
         */
157
        private JScrollPane getJScrollPane4() {
158
                if (jScrollPane4 == null) {
159
                        jScrollPane4 = new JScrollPane();
160
                        jScrollPane4.setBounds(304, 30, 158, 334);
161
                        jScrollPane4.setViewportView(getLstSelectedFeatures());
162
                }
163
                return jScrollPane4;
164
        }
165
166
        /**
167
         * This method initializes lstTemps
168
         *
169
         * @return javax.swing.JList
170
         */
171
        public JList getLstFeatures() {
172
                if (lstFeatures == null) {
173
                        lstFeatures = new JList();
174
                }
175
                return lstFeatures;
176
        }
177
178
        /**
179
         * This method initializes lstSelectedFeatures
180
         *
181
         * @return javax.swing.JList
182
         */
183
        public JList getLstSelectedFeatures() {
184
                if (lstSelectedFeatures == null) {
185
                        lstSelectedFeatures = new JList();
186
                        lstSelectedFeatures.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
187
                                public void valueChanged(javax.swing.event.ListSelectionEvent e) {
188
//                                        lstSelectedFeatures.callStateChanged(isCorretlyConfigured());
189
                                }
190
                        });
191
                }
192
                return lstSelectedFeatures;
193
        }
194
195
        /**
196
         *
197
         * @param feature
198
         */
199
        public void setFields(WFSLayerNode feature){
200
                this.getLstSelectedFeatures().setListData(new Object[0]);
201
                Hashtable fields = feature.getFields();
202
                this.getLstFeatures().setListData(fields.values().toArray());
203
        }
204
205
        /**
206
         * Adds the selected items from the time list to the selected
207
         * features list.
208
         */
209
        public void addFeature(){
210
                ArrayList times = new ArrayList();
211
                for (int i = 0; i < getLstSelectedFeatures()
212
                                .getModel().getSize(); i++) {
213
                        times.add(getLstSelectedFeatures().getModel()
214
                                        .getElementAt(i));
215
                }
216
217
                Object[] obj = getLstFeatures().getSelectedValues();
218
                for (int i = 0; i < obj.length; i++) {
219
                        if (!times.contains(obj[i]))
220
                                times.add(obj[i]);
221
                }
222
                getLstSelectedFeatures()
223
                                .setListData(times.toArray());
224
225
        }
226
227
        /**
228
         * Removes the selected items from the selected features list.
229
         */
230
        public void delFeature(){
231
                ArrayList features = new ArrayList();
232
                Object[] obj = getLstSelectedFeatures()
233
                                .getSelectedValues();
234
                for (int i = 0; i < getLstSelectedFeatures()
235
                                .getModel().getSize(); i++)
236
                        features.add(getLstSelectedFeatures().getModel()
237
                                        .getElementAt(i));
238
239
                for (int j = 0; j < obj.length; j++)
240
                        if (features.contains(obj[j]))
241
                                features.remove(obj[j]);
242
                obj = new Object[features.size()];
243
                for (int i = 0; i < obj.length; i++) {
244
                        obj[i] = features.get(i);
245
                }
246
                getLstSelectedFeatures()
247
                                .setListData(features.toArray());
248
        }
249
250
251
}