gvsig-raster / org.gvsig.raster.app / trunk / org.gvsig.raster.app / org.gvsig.raster.app.wcsclient / src / main / java / org / gvsig / raster / app / extension / wcsclient / gui / panel / LayerPanel.java @ 379
History | View | Annotate | Download (7.99 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
|
23 |
package org.gvsig.raster.app.extension.wcsclient.gui.panel; |
24 |
|
25 |
import java.awt.BorderLayout; |
26 |
import java.awt.GridBagConstraints; |
27 |
import java.awt.GridBagLayout; |
28 |
import java.util.prefs.Preferences; |
29 |
|
30 |
import javax.swing.JCheckBox; |
31 |
import javax.swing.JPanel; |
32 |
import javax.swing.JScrollPane; |
33 |
import javax.swing.JTextField; |
34 |
|
35 |
import org.gvsig.andami.PluginServices; |
36 |
import org.gvsig.fmap.dal.coverage.store.remote.RemoteWCSLayerNode; |
37 |
|
38 |
|
39 |
/**
|
40 |
* Layer Panel
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
42 |
*/
|
43 |
public class LayerPanel extends JPanel { |
44 |
private static final long serialVersionUID = 1L; |
45 |
public static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wcs-wizard" ); |
46 |
private JPanel jPanel4 = null; |
47 |
private JPanel pnlName = null; |
48 |
private LayerList lstCoverages = null; |
49 |
private JScrollPane jScrollPane = null; |
50 |
private JTextField txtName = null; |
51 |
private JCheckBox chkExtendedNames = null; |
52 |
private WCSParamsPanel parent = null; |
53 |
|
54 |
public LayerPanel() {
|
55 |
init(); |
56 |
} |
57 |
|
58 |
public void init() { |
59 |
setLayout(new GridBagLayout()); |
60 |
|
61 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
62 |
gridBagConstraints1.fill = GridBagConstraints.BOTH;
|
63 |
gridBagConstraints1.anchor = GridBagConstraints.CENTER;
|
64 |
gridBagConstraints1.weightx = 1.0;
|
65 |
gridBagConstraints1.weighty = 1.0;
|
66 |
gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2); |
67 |
gridBagConstraints1.gridy = 1;
|
68 |
add(getJPanel4(), gridBagConstraints1); |
69 |
|
70 |
gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
|
71 |
gridBagConstraints1.anchor = GridBagConstraints.CENTER;
|
72 |
gridBagConstraints1.weightx = 1.0;
|
73 |
gridBagConstraints1.weighty = 0;
|
74 |
gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2); |
75 |
gridBagConstraints1.gridy = 0;
|
76 |
add(getPnlName(), gridBagConstraints1); |
77 |
|
78 |
gridBagConstraints1.gridy = 2;
|
79 |
add(getChkExtendedNames(), gridBagConstraints1); |
80 |
} |
81 |
|
82 |
public void setWCSParamsPanel(WCSParamsPanel parent) { |
83 |
this.parent = parent;
|
84 |
} |
85 |
|
86 |
/**
|
87 |
* This method initializes chkExtendedNames
|
88 |
*
|
89 |
* @return javax.swing.JCheckBox
|
90 |
*/
|
91 |
private JCheckBox getChkExtendedNames() { |
92 |
if (chkExtendedNames == null) { |
93 |
chkExtendedNames = new JCheckBox(); |
94 |
chkExtendedNames.setText(PluginServices.getText(this, "show_layer_names")); |
95 |
chkExtendedNames.addItemListener(new java.awt.event.ItemListener() {
|
96 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
97 |
boolean b = chkExtendedNames.isSelected();
|
98 |
getLstCoverages().showLayerNames = b; |
99 |
getLstCoverages().repaint(); |
100 |
} |
101 |
}); |
102 |
chkExtendedNames.addActionListener(new java.awt.event.ActionListener() {
|
103 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
104 |
fPrefs.putBoolean("show_layer_names", chkExtendedNames.isSelected());
|
105 |
} |
106 |
}); |
107 |
chkExtendedNames.setSelected(fPrefs.getBoolean("show_layer_names", false)); |
108 |
|
109 |
} |
110 |
return chkExtendedNames;
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* This method initializes pnlName
|
115 |
*
|
116 |
* @return javax.swing.JPanel
|
117 |
*/
|
118 |
private JPanel getPnlName() { |
119 |
if (pnlName == null) { |
120 |
pnlName = new JPanel(new BorderLayout()); |
121 |
pnlName.setBorder(javax.swing.BorderFactory.createTitledBorder( |
122 |
null, PluginServices.getText(this, "nombre_cobertura"), |
123 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
124 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
125 |
pnlName.add(getTxtName(), BorderLayout.CENTER);
|
126 |
} |
127 |
return pnlName;
|
128 |
} |
129 |
|
130 |
/**
|
131 |
* This method initializes jTextField
|
132 |
*
|
133 |
* @return javax.swing.JTextField
|
134 |
*/
|
135 |
public JTextField getTxtName() { |
136 |
if (txtName == null) { |
137 |
txtName = new JTextField(); |
138 |
} |
139 |
return txtName;
|
140 |
} |
141 |
|
142 |
/**
|
143 |
* This method initializes jList1
|
144 |
*
|
145 |
* @return javax.swing.JList
|
146 |
*/
|
147 |
public LayerList getLstCoverages() {
|
148 |
if (lstCoverages == null) { |
149 |
lstCoverages = new LayerList();
|
150 |
lstCoverages.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
151 |
lstCoverages.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
152 |
public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
153 |
parent.refreshData(null);
|
154 |
} |
155 |
}); |
156 |
} |
157 |
return lstCoverages;
|
158 |
} |
159 |
|
160 |
/**
|
161 |
* This method initializes jScrollPane
|
162 |
*
|
163 |
* @return javax.swing.JScrollPane
|
164 |
*/
|
165 |
private JScrollPane getJScrollPane() { |
166 |
if (jScrollPane == null) { |
167 |
jScrollPane = new JScrollPane(); |
168 |
jScrollPane.setViewportView(getLstCoverages()); |
169 |
} |
170 |
return jScrollPane;
|
171 |
} |
172 |
|
173 |
/**
|
174 |
* This method initializes jPanel4
|
175 |
*
|
176 |
* @return javax.swing.JPanel
|
177 |
*/
|
178 |
private JPanel getJPanel4() { |
179 |
if (jPanel4 == null) { |
180 |
jPanel4 = new JPanel(new BorderLayout()); |
181 |
jPanel4.add(getJScrollPane(), BorderLayout.CENTER);
|
182 |
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder( |
183 |
null, PluginServices.getText(this, "seleccionar_coberturas"), |
184 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
185 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
186 |
} |
187 |
return jPanel4;
|
188 |
} |
189 |
|
190 |
/**
|
191 |
* Returns the index of the coverage within the coverages list
|
192 |
*
|
193 |
* @param coverageName
|
194 |
* @return The coverage's index if it exists, -1 if it not exists.
|
195 |
*/
|
196 |
public int getCoverageIndex(String coverageName) { |
197 |
for (int i = 0; i < getLstCoverages().getModel().getSize(); i++){ |
198 |
if (coverageName.equals(((RemoteWCSLayerNode)getLstCoverages().getModel().getElementAt(i)).getName())) {
|
199 |
return i;
|
200 |
} |
201 |
} |
202 |
return -1; |
203 |
} |
204 |
|
205 |
/**
|
206 |
* Returns the selected coverage name at the server. This is the value to use
|
207 |
* in a GetCoverage request
|
208 |
*
|
209 |
* @return String
|
210 |
*/
|
211 |
public String getSelectedInListCoverageName() { |
212 |
if (getLstCoverages().getSelectedValue() == null) { |
213 |
return null; |
214 |
} |
215 |
/*if(getTxtName().getText().compareTo("") == 0)
|
216 |
return null;
|
217 |
|
218 |
for (int i = 0; i < getLstCoverages().getModel().getSize(); i++) {
|
219 |
RemoteWCSLayerNode node = (RemoteWCSLayerNode)getLstCoverages().getModel().getElementAt(i);
|
220 |
if(node.getTitle().compareTo(getTxtName().getText()) == 0)
|
221 |
return node.getName();
|
222 |
}
|
223 |
return null;
|
224 |
*/
|
225 |
return ((RemoteWCSLayerNode) getLstCoverages().getSelectedValue()).getName();
|
226 |
} |
227 |
|
228 |
/**
|
229 |
* Returns the selected coverage name at the server. This is the value to use
|
230 |
* in a GetCoverage request
|
231 |
*
|
232 |
* @return String
|
233 |
*/
|
234 |
public String getSelectedCoverageName() { |
235 |
if(getTxtName().getText().compareTo("") == 0) |
236 |
return null; |
237 |
|
238 |
for (int i = 0; i < getLstCoverages().getModel().getSize(); i++) { |
239 |
RemoteWCSLayerNode node = (RemoteWCSLayerNode)getLstCoverages().getModel().getElementAt(i); |
240 |
if(node.getTitle().compareTo(getTxtName().getText()) == 0) |
241 |
return node.getName();
|
242 |
} |
243 |
return null; |
244 |
} |
245 |
|
246 |
public String getNameByTitle(String title) { |
247 |
for (int i = 0; i < getLstCoverages().getModel().getSize(); i++) { |
248 |
RemoteWCSLayerNode node = (RemoteWCSLayerNode)getLstCoverages().getModel().getElementAt(i); |
249 |
if(node.getTitle().compareTo(title) == 0) |
250 |
return node.getName();
|
251 |
} |
252 |
return null; |
253 |
} |
254 |
|
255 |
public String getTitleByName(String name) { |
256 |
for (int i = 0; i < getLstCoverages().getModel().getSize(); i++) { |
257 |
RemoteWCSLayerNode node = (RemoteWCSLayerNode)getLstCoverages().getModel().getElementAt(i); |
258 |
if(node.getName().compareTo(name) == 0) |
259 |
return node.getTitle();
|
260 |
} |
261 |
return null; |
262 |
} |
263 |
|
264 |
} |
265 |
|