Statistics
| Revision:

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

History | View | Annotate | Download (7.71 KB)

1
package com.iver.cit.gvsig.gui.panels;
2

    
3
import javax.swing.JCheckBox;
4
import javax.swing.JPanel;
5
import javax.swing.JScrollPane;
6
import javax.swing.JTextField;
7

    
8
import com.iver.andami.PluginServices;
9
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
10
import com.iver.cit.gvsig.gui.wizards.WFSWizardData;
11

    
12
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
13
 *
14
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
29
 *
30
 * For more information, contact:
31
 *
32
 *  Generalitat Valenciana
33
 *   Conselleria d'Infraestructures i Transport
34
 *   Av. Blasco Ib??ez, 50
35
 *   46010 VALENCIA
36
 *   SPAIN
37
 *
38
 *      +34 963862235
39
 *   gvsig@gva.es
40
 *      www.gvsig.gva.es
41
 *
42
 *    or
43
 *
44
 *   IVER T.I. S.A
45
 *   Salamanca 50
46
 *   46005 Valencia
47
 *   Spain
48
 *
49
 *   +34 963163400
50
 *   dac@iver.es
51
 */
52
/* CVS MESSAGES:
53
 *
54
 * $Id: WFSSelectFeaturePanel.java 5339 2006-05-23 08:09:53Z jorpiell $
55
 * $Log$
56
 * Revision 1.4  2006-05-23 08:09:39  jorpiell
57
 * Se ha cambiado la forma en la que se leian los valores seleccionados en los paneles y se ha cambiado el comportamiento de los botones
58
 *
59
 * Revision 1.3  2006/05/19 12:57:08  jorpiell
60
 * Modificados algunos paneles
61
 *
62
 * Revision 1.2  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
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
69
 */
70
public class WFSSelectFeaturePanel extends JPanel {
71
        private JPanel coveragesListPanel = null;
72
        private JScrollPane jScrollPane = null;
73
        private LayerList lstFeatures = null;
74
        private JTextField txtName = null;
75
        private JCheckBox chkExtendedNames = null; 
76
        private WFSWizardData data = null;
77
        private WFSParamsPanel parent = null;
78
        private JPanel layerNamePanel = null;
79

    
80
        /**
81
         * This method initializes 
82
         * 
83
         */
84
        public WFSSelectFeaturePanel(WFSParamsPanel parent) {
85
                super();
86
                this.parent = parent;
87
                initialize();
88
        }
89

    
90
        /**
91
         * This method initializes this
92
         * 
93
         */
94
        private void initialize() {
95
                this.setLayout(null);
96
                this.setBounds(10, 5, 481, 427);                
97
                this.add(getFeaturesListPanel(), null);
98
                this.add(getChkExtendedNames(), null);
99
                this.add(getLayerNamePanel(), null);
100
                        
101
        }
102

    
103
        /**
104
         * This method initializes coveragesListPanel        
105
         *         
106
         * @return javax.swing.JPanel        
107
         */
108
        private JPanel getFeaturesListPanel() {
109
                if (coveragesListPanel == null) {
110
                        coveragesListPanel = new JPanel();
111
                        coveragesListPanel.setLayout(null);
112
                        coveragesListPanel.setLocation(new java.awt.Point(4,59));
113
                        coveragesListPanel.setSize(new java.awt.Dimension(457,302));
114
                        coveragesListPanel.add(getJScrollPane(), null);
115
                        coveragesListPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
116
                                        null, PluginServices.getText(this, "select_features"),
117
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
118
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
119
                }
120
                return coveragesListPanel;
121
        }
122
        
123
        /**
124
         * This method initializes jScrollPane        
125
         *         
126
         * @return javax.swing.JScrollPane        
127
         */    
128
        private JScrollPane getJScrollPane() {
129
                if (jScrollPane == null) {
130
                        jScrollPane = new JScrollPane();
131
                        jScrollPane.setBounds(6, 17, 446, 280);
132
                        jScrollPane.setViewportView(getLstFeatures());
133
                }
134
                return jScrollPane;
135
        }
136
        
137
        /**
138
         * This method initializes jList1        
139
         *         
140
         * @return javax.swing.JList        
141
         */    
142
        public LayerList getLstFeatures() {
143
                if (lstFeatures == null) {
144
                        lstFeatures = new LayerList();
145
                        lstFeatures.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
146
                        lstFeatures.addListSelectionListener(new javax.swing.event.ListSelectionListener() { 
147
                                public void valueChanged(javax.swing.event.ListSelectionEvent e) {    
148
                                        refreshData();
149
                                }
150
                        });
151
                }
152
                return lstFeatures;
153
        }
154
        
155
        /**
156
         * This method initializes jTextField        
157
         *         
158
         * @return javax.swing.JTextField        
159
         */    
160
        public JTextField getTxtName() {
161
                if (txtName == null) {
162
                        txtName = new JTextField();
163
                        txtName.setBounds(10, 19, 437, 20);
164
                        txtName.setText(PluginServices.getText(this, "WFSLayer"));
165
                        txtName.addKeyListener(new java.awt.event.KeyAdapter() { 
166
                                public void keyTyped(java.awt.event.KeyEvent e) {    
167
//                                        fireWizardComplete(isCorrectlyConfigured());
168
                                }
169
                        });
170
                }
171
                return txtName;
172
        }
173
        /**
174
         * This method initializes chkExtendedNames        
175
         *         
176
         * @return javax.swing.JCheckBox        
177
         */    
178
        private JCheckBox getChkExtendedNames() {
179
                if (chkExtendedNames == null) {
180
                        chkExtendedNames = new JCheckBox();
181
                        chkExtendedNames.setText(PluginServices.getText(this, "show_layer_names"));
182
                        chkExtendedNames.setBounds(10, 368, 150, 20);
183
                        chkExtendedNames.addItemListener(new java.awt.event.ItemListener() { 
184
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
185
                                        boolean b = chkExtendedNames.isSelected();
186
                                        getLstFeatures().showLayerNames = b;
187
                                        getLstFeatures().repaint();
188
                                }
189
                        });
190
                        chkExtendedNames.addActionListener(new java.awt.event.ActionListener() { 
191
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
192
//                                        fPrefs.putBoolean("show_layer_names", chkExtendedNames.isSelected());
193
                                }
194
                        });                        
195
//                        chkExtendedNames.setSelected(fPrefs.getBoolean("show_layer_names", false));
196
                        
197
                }
198
                return chkExtendedNames;
199
        }
200
        
201
        /**
202
         * 
203
         * @return The selected Feature
204
         */
205
        public WFSLayerNode getSelectedFeature(){
206
                return (WFSLayerNode)getLstFeatures().getSelectedValue();
207
        }
208
        
209
        /**
210
         * Sets the object that holds the wizard data.
211
         * 
212
         * Establece el objeto que contiene los datos del wizard.
213
         * 
214
         * @param data
215
         */
216
        public void setWizardData(WFSWizardData data) {
217
                this.data = data;
218
                refreshInfo();
219
        }
220
        
221
        /**
222
         * Refresh the features list
223
         *
224
         */
225
        public void refreshInfo(){
226
                getLstFeatures().addFeatures(data.getFeatures());
227
        }
228
        
229
        /**
230
         * Refreshes the wizard components data each time a feature
231
         * is selected. The describeFeatureType operation must be 
232
         * sent 
233
         */
234
        public void refreshData(){
235
                WFSLayerNode lyr = (WFSLayerNode)getLstFeatures().getSelectedValue();
236
                try{
237
                        getTxtName().setText(lyr.getTitle());
238
                }catch(NullPointerException e){
239
                        getTxtName().setText(PluginServices.getText(this,"default_name"));
240
                }
241
                parent.refreshData(lyr);                
242
        }
243

    
244
        /**
245
         * This method initializes layerNamePanel        
246
         *         
247
         * @return javax.swing.JPanel        
248
         */
249
        private JPanel getLayerNamePanel() {
250
                if (layerNamePanel == null) {
251
                        layerNamePanel = new JPanel();
252
                        layerNamePanel.setLayout(null);
253
                        layerNamePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
254
                                        null, PluginServices.getText(this, "layer_name"),
255
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
256
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
257
                        layerNamePanel.setBounds(new java.awt.Rectangle(4, 8, 457, 49));
258
                        layerNamePanel.add(getTxtName(), null);
259
                        
260
                }
261
                return layerNamePanel;
262
        }
263
        
264
        /**
265
         * 
266
         * @return the layer name
267
         */
268
        public String getLayerName(){
269
                return ((WFSLayerNode)getLstFeatures().getSelectedValue()).getName();
270
        }
271
        
272
        /**
273
         * 
274
         * @return the test that will be showed it the gvSIG
275
         * toc
276
         */
277
        public String getLayerText(){
278
                return getTxtName().getText();
279
        }
280
        
281
        
282
        
283

    
284
}  //  @jve:decl-index=0:visual-constraint="10,16"