150 |
150 |
*
|
151 |
151 |
*
|
152 |
152 |
*/
|
153 |
|
|
154 |
|
|
155 |
153 |
/**
|
156 |
|
* <p>Panel where user can select a feature type to load as a WFS layer.</p>
|
157 |
|
*
|
|
154 |
* <p>
|
|
155 |
* Panel where user can select a feature type to load as a WFS layer.</p>
|
|
156 |
*
|
158 |
157 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
159 |
158 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
160 |
159 |
*/
|
161 |
160 |
public class WFSSelectFeaturePanel extends AbstractWFSPanel {
|
162 |
|
private static final long serialVersionUID = -3781080396069038450L;
|
163 |
|
private JPanel featureListPanel = null;
|
164 |
|
private JScrollPane jScrollPane = null;
|
165 |
|
private LayerTable lstFeatures = null;
|
166 |
|
private JTextField txtName = null;
|
167 |
|
private JCheckBox chkExtendedNames = null;
|
168 |
|
private JPanel layerNamePanel = null;
|
169 |
|
private WFSSelectedFeature layerNode = null;
|
170 |
|
private ListSelectionListener listSelectionListener = null;
|
171 |
161 |
|
172 |
|
/**
|
173 |
|
* Creates a new WFS select feature panel.
|
174 |
|
*/
|
175 |
|
public WFSSelectFeaturePanel() {
|
176 |
|
super();
|
177 |
|
initialize();
|
178 |
|
}
|
|
162 |
private static final long serialVersionUID = -3781080396069038450L;
|
|
163 |
private JPanel featureListPanel = null;
|
|
164 |
private JScrollPane jScrollPane = null;
|
|
165 |
private LayerTable lstFeatures = null;
|
|
166 |
private JTextField txtName = null;
|
|
167 |
private JCheckBox chkExtendedNames = null;
|
|
168 |
private JPanel layerNamePanel = null;
|
|
169 |
private WFSSelectedFeature layerNode = null;
|
|
170 |
private ListSelectionListener listSelectionListener = null;
|
179 |
171 |
|
180 |
|
/**
|
181 |
|
* This method initializes coveragesListPanel
|
182 |
|
*
|
183 |
|
* @return javax.swing.JPanel
|
184 |
|
*/
|
185 |
|
private JPanel getFeaturesListPanel() {
|
186 |
|
if (featureListPanel == null) {
|
187 |
|
java.awt.GridBagConstraints gridBagConstraints;
|
188 |
|
featureListPanel = new JPanel();
|
189 |
|
featureListPanel.setLayout(new java.awt.GridBagLayout());
|
190 |
|
featureListPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
191 |
|
null, PluginServices.getText(this, "select_features"),
|
192 |
|
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
193 |
|
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
|
172 |
/**
|
|
173 |
* Creates a new WFS select feature panel.
|
|
174 |
*/
|
|
175 |
public WFSSelectFeaturePanel() {
|
|
176 |
super();
|
|
177 |
initialize();
|
|
178 |
}
|
194 |
179 |
|
195 |
|
gridBagConstraints = new java.awt.GridBagConstraints();
|
196 |
|
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
|
197 |
|
gridBagConstraints.weightx = 1.0;
|
198 |
|
gridBagConstraints.weighty = 1.0;
|
199 |
|
featureListPanel.add(getJScrollPane(), gridBagConstraints);
|
200 |
|
}
|
|
180 |
/**
|
|
181 |
* This method initializes coveragesListPanel
|
|
182 |
*
|
|
183 |
* @return javax.swing.JPanel
|
|
184 |
*/
|
|
185 |
private JPanel getFeaturesListPanel() {
|
|
186 |
if (featureListPanel == null) {
|
|
187 |
java.awt.GridBagConstraints gridBagConstraints;
|
|
188 |
featureListPanel = new JPanel();
|
|
189 |
featureListPanel.setLayout(new java.awt.GridBagLayout());
|
|
190 |
featureListPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
|
191 |
null, PluginServices.getText(this, "select_features"),
|
|
192 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
|
193 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
201 |
194 |
|
202 |
|
return featureListPanel;
|
203 |
|
}
|
|
195 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
196 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
|
|
197 |
gridBagConstraints.weightx = 1.0;
|
|
198 |
gridBagConstraints.weighty = 1.0;
|
|
199 |
featureListPanel.add(getJScrollPane(), gridBagConstraints);
|
|
200 |
}
|
204 |
201 |
|
205 |
|
/**
|
206 |
|
* This method initializes jScrollPane
|
207 |
|
*
|
208 |
|
* @return javax.swing.JScrollPane
|
209 |
|
*/
|
210 |
|
private JScrollPane getJScrollPane() {
|
211 |
|
if (jScrollPane == null) {
|
212 |
|
jScrollPane = new JScrollPane();
|
213 |
|
jScrollPane.setViewportView(getLstFeatures());
|
214 |
|
jScrollPane.setToolTipText(PluginServices.getText(jScrollPane, "feature_Selection_Info"));
|
215 |
|
}
|
|
202 |
return featureListPanel;
|
|
203 |
}
|
216 |
204 |
|
217 |
|
return jScrollPane;
|
218 |
|
}
|
|
205 |
/**
|
|
206 |
* This method initializes jScrollPane
|
|
207 |
*
|
|
208 |
* @return javax.swing.JScrollPane
|
|
209 |
*/
|
|
210 |
private JScrollPane getJScrollPane() {
|
|
211 |
if (jScrollPane == null) {
|
|
212 |
jScrollPane = new JScrollPane();
|
|
213 |
jScrollPane.setViewportView(getLstFeatures());
|
|
214 |
jScrollPane.setToolTipText(PluginServices.getText(jScrollPane, "feature_Selection_Info"));
|
|
215 |
}
|
219 |
216 |
|
220 |
|
/**
|
221 |
|
* This method initializes lstFeatures
|
222 |
|
*
|
223 |
|
* @return javax.swing.LayerTable
|
224 |
|
*/
|
225 |
|
public LayerTable getLstFeatures() {
|
226 |
|
if (lstFeatures == null) {
|
227 |
|
lstFeatures = new LayerTable();
|
228 |
|
lstFeatures.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
229 |
|
lstFeatures.getSelectionModel().addListSelectionListener(getListSelectionListener());
|
230 |
|
lstFeatures.setToolTipText(PluginServices.getText(lstFeatures, "feature_Selection_Info"));
|
|
217 |
return jScrollPane;
|
|
218 |
}
|
231 |
219 |
|
232 |
|
// Double-click -> click the 'Next' button
|
233 |
|
lstFeatures.addMouseListener(new MouseAdapter() {
|
234 |
|
/*
|
235 |
|
* (non-Javadoc)
|
236 |
|
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
237 |
|
*/
|
238 |
|
public void mouseClicked(MouseEvent e) {
|
239 |
|
if (e.getClickCount() == 2) {
|
240 |
|
Object obj = getPanelGroup();
|
|
220 |
/**
|
|
221 |
* This method initializes lstFeatures
|
|
222 |
*
|
|
223 |
* @return javax.swing.LayerTable
|
|
224 |
*/
|
|
225 |
public LayerTable getLstFeatures() {
|
|
226 |
if (lstFeatures == null) {
|
|
227 |
lstFeatures = new LayerTable();
|
|
228 |
lstFeatures.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
|
229 |
lstFeatures.getSelectionModel().addListSelectionListener(getListSelectionListener());
|
|
230 |
lstFeatures.setToolTipText(PluginServices.getText(lstFeatures, "feature_Selection_Info"));
|
241 |
231 |
|
242 |
|
if ((obj != null) && (obj instanceof WFSParamsPanel))
|
243 |
|
((WFSParamsPanel)obj).doClickOnNextButton();
|
244 |
|
}
|
245 |
|
}
|
246 |
|
});
|
247 |
|
}
|
|
232 |
// Double-click -> click the 'Next' button
|
|
233 |
lstFeatures.addMouseListener(new MouseAdapter() {
|
|
234 |
/*
|
|
235 |
* (non-Javadoc)
|
|
236 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
|
237 |
*/
|
|
238 |
public void mouseClicked(MouseEvent e) {
|
|
239 |
if (e.getClickCount() == 2) {
|
|
240 |
Object obj = getPanelGroup();
|
248 |
241 |
|
249 |
|
return lstFeatures;
|
250 |
|
}
|
251 |
|
|
|
242 |
if ((obj != null) && (obj instanceof WFSParamsPanel)) {
|
|
243 |
((WFSParamsPanel) obj).doClickOnNextButton();
|
|
244 |
}
|
|
245 |
}
|
|
246 |
}
|
|
247 |
});
|
|
248 |
}
|
|
249 |
|
|
250 |
return lstFeatures;
|
|
251 |
}
|
|
252 |
|
252 |
253 |
public int getSelectedFeaturesCount() {
|
253 |
254 |
|
254 |
255 |
if (lstFeatures == null) {
|
255 |
256 |
return 0;
|
256 |
257 |
}
|
257 |
|
|
|
258 |
|
258 |
259 |
ListSelectionModel m = lstFeatures.getSelectionModel();
|
259 |
260 |
if (m == null || m.isSelectionEmpty()) {
|
260 |
261 |
return 0;
|
261 |
262 |
} else {
|
262 |
263 |
int resp = 0;
|
263 |
264 |
for (int i = m.getMinSelectionIndex();
|
264 |
|
i <= m.getMaxSelectionIndex();
|
265 |
|
i++) {
|
|
265 |
i <= m.getMaxSelectionIndex();
|
|
266 |
i++) {
|
266 |
267 |
|
267 |
268 |
if (m.isSelectedIndex(i)) {
|
268 |
269 |
resp++;
|
... | ... | |
273 |
274 |
|
274 |
275 |
}
|
275 |
276 |
|
276 |
|
/**
|
277 |
|
* Creates the list selection listener for the layers list
|
278 |
|
*
|
279 |
|
* @return the listener
|
280 |
|
*/
|
281 |
|
private ListSelectionListener getListSelectionListener(){
|
282 |
|
if (listSelectionListener == null){
|
283 |
|
listSelectionListener = new ListSelectionListener(){
|
284 |
|
public void valueChanged(javax.swing.event.ListSelectionEvent e) {
|
285 |
|
DefaultListSelectionModel model = (DefaultListSelectionModel) e.getSource();
|
286 |
|
LayerTableModel t_model = ((LayerTableModel)lstFeatures.getModel());
|
287 |
|
if (t_model.isUpdatingSelection())
|
288 |
|
return;
|
|
277 |
/**
|
|
278 |
* Creates the list selection listener for the layers list
|
|
279 |
*
|
|
280 |
* @return the listener
|
|
281 |
*/
|
|
282 |
private ListSelectionListener getListSelectionListener() {
|
|
283 |
if (listSelectionListener == null) {
|
|
284 |
listSelectionListener = new ListSelectionListener() {
|
|
285 |
public void valueChanged(javax.swing.event.ListSelectionEvent e) {
|
|
286 |
DefaultListSelectionModel model = (DefaultListSelectionModel) e.getSource();
|
|
287 |
LayerTableModel t_model = ((LayerTableModel) lstFeatures.getModel());
|
|
288 |
if (t_model.isUpdatingSelection()) {
|
|
289 |
return;
|
|
290 |
}
|
289 |
291 |
|
290 |
|
// With this condition we force to execute the updating only when a row has been selected by the user
|
291 |
|
if ((model.getMinSelectionIndex() > -1) && (e.getValueIsAdjusting() == false)) {
|
292 |
|
// Indicate that now we are loading a new layer
|
293 |
|
IPanelGroup panelGroup = getPanelGroup();
|
|
292 |
// With this condition we force to execute the updating only when a row has been selected by the user
|
|
293 |
if ((model.getMinSelectionIndex() > -1) && (e.getValueIsAdjusting() == false)) {
|
|
294 |
// Indicate that now we are loading a new layer
|
|
295 |
IPanelGroup panelGroup = getPanelGroup();
|
294 |
296 |
|
295 |
|
if (panelGroup == null)
|
296 |
|
return;
|
|
297 |
if (panelGroup == null) {
|
|
298 |
return;
|
|
299 |
}
|
297 |
300 |
|
298 |
|
/*
|
299 |
|
if (((WFSParamsPanel)panelGroup).getFilterPanel() == null)
|
300 |
|
return;
|
301 |
|
*/
|
302 |
|
|
303 |
|
refreshData();
|
304 |
|
}
|
305 |
|
|
|
301 |
/*
|
|
302 |
if (((WFSParamsPanel)panelGroup).getFilterPanel() == null)
|
|
303 |
return;
|
|
304 |
*/
|
|
305 |
refreshData();
|
|
306 |
}
|
|
307 |
|
306 |
308 |
// =============================================
|
307 |
309 |
// If zero selected, settings are invalid
|
308 |
|
int n_sel = getSelectedFeaturesCount();
|
309 |
|
if (n_sel == 0) {
|
310 |
|
Object obj = getPanelGroup();
|
311 |
|
if (obj != null && obj instanceof WFSParamsPanel) {
|
312 |
|
obj = ((WFSParamsPanel) obj).getParent();
|
313 |
|
if (obj instanceof WFSWizard) {
|
314 |
|
((WFSWizard) obj).callStateChanged(false);
|
315 |
|
}
|
316 |
|
}
|
317 |
|
}
|
318 |
|
// =============================================
|
319 |
|
}
|
320 |
|
};
|
321 |
|
}
|
|
310 |
int n_sel = getSelectedFeaturesCount();
|
|
311 |
if (n_sel == 0) {
|
|
312 |
Object obj = getPanelGroup();
|
|
313 |
if (obj != null && obj instanceof WFSParamsPanel) {
|
|
314 |
obj = ((WFSParamsPanel) obj).getParent();
|
|
315 |
if (obj instanceof WFSWizard) {
|
|
316 |
((WFSWizard) obj).callStateChanged(false);
|
|
317 |
}
|
|
318 |
}
|
|
319 |
}
|
|
320 |
// =============================================
|
|
321 |
}
|
|
322 |
};
|
|
323 |
}
|
322 |
324 |
|
323 |
|
return listSelectionListener;
|
324 |
|
}
|
|
325 |
return listSelectionListener;
|
|
326 |
}
|
325 |
327 |
|
326 |
|
/**
|
327 |
|
* This method initializes jTextField
|
328 |
|
*
|
329 |
|
* @return javax.swing.JTextField
|
330 |
|
*/
|
331 |
|
public JTextField getTxtName() {
|
332 |
|
if (txtName == null) {
|
333 |
|
txtName = new JTextField();
|
334 |
|
txtName.setBounds(6, 19, 472, 20);
|
335 |
|
txtName.setText(PluginServices.getText(this, "WFSLayer"));
|
336 |
|
txtName.setEditable(false);
|
337 |
|
txtName.setBackground(Color.WHITE);
|
338 |
|
txtName.setToolTipText(PluginServices.getText(txtName, "feature_to_load"));
|
|
328 |
/**
|
|
329 |
* This method initializes jTextField
|
|
330 |
*
|
|
331 |
* @return javax.swing.JTextField
|
|
332 |
*/
|
|
333 |
public JTextField getTxtName() {
|
|
334 |
if (txtName == null) {
|
|
335 |
txtName = new JTextField();
|
|
336 |
txtName.setBounds(6, 19, 472, 20);
|
|
337 |
txtName.setText(PluginServices.getText(this, "WFSLayer"));
|
|
338 |
txtName.setEditable(false);
|
|
339 |
txtName.setBackground(Color.WHITE);
|
|
340 |
txtName.setToolTipText(PluginServices.getText(txtName, "feature_to_load"));
|
339 |
341 |
|
340 |
|
txtName.getDocument().addDocumentListener(new DocumentListener() {
|
341 |
|
/*
|
342 |
|
* (non-Javadoc)
|
343 |
|
* @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
|
344 |
|
*/
|
345 |
|
public void changedUpdate(DocumentEvent e) {
|
346 |
|
}
|
|
342 |
txtName.getDocument().addDocumentListener(new DocumentListener() {
|
|
343 |
/*
|
|
344 |
* (non-Javadoc)
|
|
345 |
* @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
|
|
346 |
*/
|
|
347 |
public void changedUpdate(DocumentEvent e) {
|
|
348 |
}
|
347 |
349 |
|
348 |
|
/*
|
349 |
|
* (non-Javadoc)
|
350 |
|
* @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
|
351 |
|
*/
|
352 |
|
public void insertUpdate(DocumentEvent e) {
|
353 |
|
IPanelGroup panelGroup = getPanelGroup();
|
|
350 |
/*
|
|
351 |
* (non-Javadoc)
|
|
352 |
* @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
|
|
353 |
*/
|
|
354 |
public void insertUpdate(DocumentEvent e) {
|
|
355 |
IPanelGroup panelGroup = getPanelGroup();
|
354 |
356 |
|
355 |
|
if (panelGroup == null)
|
356 |
|
return;
|
|
357 |
if (panelGroup == null) {
|
|
358 |
return;
|
|
359 |
}
|
357 |
360 |
|
358 |
|
((WFSParamsPanel)panelGroup).setApplicable(true);
|
359 |
|
}
|
|
361 |
((WFSParamsPanel) panelGroup).setApplicable(true);
|
|
362 |
}
|
360 |
363 |
|
361 |
|
/*
|
362 |
|
* (non-Javadoc)
|
363 |
|
* @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
|
364 |
|
*/
|
365 |
|
public void removeUpdate(DocumentEvent e) {
|
366 |
|
}
|
367 |
|
});
|
368 |
|
}
|
|
364 |
/*
|
|
365 |
* (non-Javadoc)
|
|
366 |
* @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
|
|
367 |
*/
|
|
368 |
public void removeUpdate(DocumentEvent e) {
|
|
369 |
}
|
|
370 |
});
|
|
371 |
}
|
369 |
372 |
|
370 |
|
return txtName;
|
371 |
|
}
|
|
373 |
return txtName;
|
|
374 |
}
|
372 |
375 |
|
373 |
|
/**
|
374 |
|
* This method initializes chkExtendedNames
|
375 |
|
*
|
376 |
|
* @return javax.swing.JCheckBox
|
377 |
|
*/
|
378 |
|
private JCheckBox getChkExtendedNames() {
|
379 |
|
if (chkExtendedNames == null) {
|
380 |
|
chkExtendedNames = new JCheckBox();
|
381 |
|
chkExtendedNames.setText(PluginServices.getText(this, "show_layer_names"));
|
382 |
|
chkExtendedNames.setBounds(10, 372, 382, 20);
|
383 |
|
chkExtendedNames.addItemListener(new java.awt.event.ItemListener() {
|
384 |
|
/*
|
385 |
|
* (non-Javadoc)
|
386 |
|
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
387 |
|
*/
|
388 |
|
public void itemStateChanged(java.awt.event.ItemEvent e) {
|
389 |
|
boolean b = chkExtendedNames.isSelected();
|
390 |
|
getLstFeatures().setShowLayerNames(b);
|
391 |
|
getLstFeatures().repaint();
|
392 |
|
}
|
393 |
|
});
|
394 |
|
}
|
|
376 |
/**
|
|
377 |
* This method initializes chkExtendedNames
|
|
378 |
*
|
|
379 |
* @return javax.swing.JCheckBox
|
|
380 |
*/
|
|
381 |
private JCheckBox getChkExtendedNames() {
|
|
382 |
if (chkExtendedNames == null) {
|
|
383 |
chkExtendedNames = new JCheckBox();
|
|
384 |
chkExtendedNames.setText(PluginServices.getText(this, "show_layer_names"));
|
|
385 |
chkExtendedNames.setBounds(10, 372, 382, 20);
|
|
386 |
chkExtendedNames.addItemListener(new java.awt.event.ItemListener() {
|
|
387 |
/*
|
|
388 |
* (non-Javadoc)
|
|
389 |
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
|
390 |
*/
|
|
391 |
public void itemStateChanged(java.awt.event.ItemEvent e) {
|
|
392 |
boolean b = chkExtendedNames.isSelected();
|
|
393 |
getLstFeatures().setShowLayerNames(b);
|
|
394 |
getLstFeatures().repaint();
|
|
395 |
}
|
|
396 |
});
|
|
397 |
}
|
395 |
398 |
|
396 |
|
return chkExtendedNames;
|
397 |
|
}
|
|
399 |
return chkExtendedNames;
|
|
400 |
}
|
398 |
401 |
|
399 |
|
/**
|
400 |
|
* Set the selected layer node
|
401 |
|
*
|
402 |
|
* @param layerNode the layer to select
|
403 |
|
*/
|
404 |
|
public void setSelectedFeature(WFSSelectedFeature layerNode){
|
405 |
|
int index = -1;
|
|
402 |
/**
|
|
403 |
* Set the selected layer node
|
|
404 |
*
|
|
405 |
* @param layerNode the layer to select
|
|
406 |
*/
|
|
407 |
public void setSelectedFeature(WFSSelectedFeature layerNode) {
|
|
408 |
int index = -1;
|
406 |
409 |
|
407 |
|
for (int i=0; i<getLstFeatures().getRowCount(); i++){
|
408 |
|
WFSSelectedFeature node = (WFSSelectedFeature)getLstFeatures().getValueAt(i);
|
|
410 |
for (int i = 0; i < getLstFeatures().getRowCount(); i++) {
|
|
411 |
WFSSelectedFeature node = (WFSSelectedFeature) getLstFeatures().getValueAt(i);
|
409 |
412 |
|
410 |
|
if (node != null && layerNode.getName().equals(node.getName())){
|
411 |
|
index = i;
|
412 |
|
}
|
413 |
|
}
|
|
413 |
if (node != null && layerNode.getName().equals(node.getName())) {
|
|
414 |
index = i;
|
|
415 |
}
|
|
416 |
}
|
414 |
417 |
|
415 |
|
if (index != -1){
|
416 |
|
getLstFeatures().changeSelection(index, 0, false, false);
|
417 |
|
}
|
418 |
|
}
|
|
418 |
if (index != -1) {
|
|
419 |
getLstFeatures().changeSelection(index, 0, false, false);
|
|
420 |
}
|
|
421 |
}
|
419 |
422 |
|
420 |
|
/**
|
421 |
|
* Refresh the features list
|
422 |
|
*/
|
423 |
|
public void refresh(WFSSelectedFeature layer) {
|
424 |
|
// Unselects all features
|
425 |
|
unselectAllFeatures();
|
|
423 |
/**
|
|
424 |
* Refresh the features list
|
|
425 |
*/
|
|
426 |
public void refresh(WFSSelectedFeature layer) {
|
|
427 |
// Unselects all features
|
|
428 |
unselectAllFeatures();
|
426 |
429 |
|
427 |
|
// Add the new features
|
428 |
|
getLstFeatures().addFeatures(getSelectedFeatureManager().getLayerList());
|
|
430 |
// Add the new features
|
|
431 |
getLstFeatures().addFeatures(getSelectedFeatureManager().getLayerList());
|
429 |
432 |
|
430 |
|
if (layer != null) {
|
431 |
|
layerNode = layer;
|
432 |
|
setLayerName(layer.getName());
|
433 |
|
setSelectedFeature(layer);
|
434 |
|
}
|
435 |
|
}
|
|
433 |
if (layer != null) {
|
|
434 |
layerNode = layer;
|
|
435 |
setLayerName(layer.getName());
|
|
436 |
setSelectedFeature(layer);
|
|
437 |
}
|
|
438 |
}
|
436 |
439 |
|
437 |
|
/**
|
438 |
|
* Refreshes the wizard components data each time a feature
|
439 |
|
* is selected. The <i>describeFeatureType</i> operation must be sent.
|
440 |
|
*/
|
441 |
|
public void refreshData() {
|
442 |
|
WFSSelectedFeature lyr = (WFSSelectedFeature)getLstFeatures().getSelectedValue();
|
|
440 |
/**
|
|
441 |
* Refreshes the wizard components data each time a feature is selected. The
|
|
442 |
* <i>describeFeatureType</i> operation must be sent.
|
|
443 |
*/
|
|
444 |
public void refreshData() {
|
|
445 |
WFSSelectedFeature lyr = (WFSSelectedFeature) getLstFeatures().getSelectedValue();
|
443 |
446 |
|
444 |
|
try {
|
445 |
|
getTxtName().setText(lyr.getTitle());
|
446 |
|
} catch (NullPointerException e){
|
447 |
|
getTxtName().setText(PluginServices.getText(this,"default_name"));
|
448 |
|
NotificationManager.addError(PluginServices.getText(this,"default_name"), e);
|
449 |
|
}
|
|
447 |
try {
|
|
448 |
getTxtName().setText(lyr.getTitle());
|
|
449 |
} catch (NullPointerException e) {
|
|
450 |
getTxtName().setText(PluginServices.getText(this, "default_name"));
|
|
451 |
NotificationManager.addError(PluginServices.getText(this, "default_name"), e);
|
|
452 |
}
|
450 |
453 |
|
451 |
|
IPanelGroup panelGroup = getPanelGroup();
|
|
454 |
IPanelGroup panelGroup = getPanelGroup();
|
452 |
455 |
|
453 |
|
if (panelGroup == null)
|
454 |
|
return;
|
|
456 |
if (panelGroup == null) {
|
|
457 |
return;
|
|
458 |
}
|
455 |
459 |
|
456 |
460 |
WFSParamsPanel wfspp = (WFSParamsPanel) panelGroup;
|
457 |
|
|
|
461 |
|
458 |
462 |
String url = wfspp.getServerExplorer().getUrl();
|
459 |
|
List sel_ver = null;
|
460 |
|
|
461 |
|
try {
|
462 |
|
sel_ver = WFSProtocolHandlerFactory.getRequestableVersions(url);
|
|
463 |
List sel_ver = null;
|
|
464 |
|
|
465 |
try {
|
|
466 |
sel_ver = WFSProtocolHandlerFactory.getRequestableVersions(url,false);
|
463 |
467 |
wfspp.refresh(lyr, sel_ver);
|
464 |
468 |
} catch (Exception e) {
|
465 |
469 |
ApplicationLocator.getManager().message(
|
466 |
|
Messages.getText("_Unable_to_get_server_version"),
|
467 |
|
JOptionPane.ERROR_MESSAGE);
|
|
470 |
Messages.getText("_Unable_to_get_server_version"),
|
|
471 |
JOptionPane.ERROR_MESSAGE);
|
468 |
472 |
}
|
469 |
|
|
470 |
473 |
|
471 |
|
repaint();
|
472 |
|
}
|
|
474 |
repaint();
|
|
475 |
}
|
473 |
476 |
|
474 |
|
/**
|
475 |
|
* This method initializes layerNamePanel
|
476 |
|
*
|
477 |
|
* @return javax.swing.JPanel
|
478 |
|
*/
|
479 |
|
private JPanel getLayerNamePanel() {
|
480 |
|
if (layerNamePanel == null) {
|
481 |
|
java.awt.GridBagConstraints gridBagConstraints;
|
482 |
|
layerNamePanel = new JPanel();
|
483 |
|
layerNamePanel.setLayout(new java.awt.GridBagLayout());
|
484 |
|
layerNamePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
485 |
|
null, PluginServices.getText(this, "layer_name"),
|
486 |
|
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
487 |
|
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
488 |
|
gridBagConstraints = new java.awt.GridBagConstraints();
|
489 |
|
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
490 |
|
gridBagConstraints.weightx = 1.0;
|
491 |
|
layerNamePanel.add(getTxtName(), gridBagConstraints);
|
492 |
|
}
|
|
477 |
/**
|
|
478 |
* This method initializes layerNamePanel
|
|
479 |
*
|
|
480 |
* @return javax.swing.JPanel
|
|
481 |
*/
|
|
482 |
private JPanel getLayerNamePanel() {
|
|
483 |
if (layerNamePanel == null) {
|
|
484 |
java.awt.GridBagConstraints gridBagConstraints;
|
|
485 |
layerNamePanel = new JPanel();
|
|
486 |
layerNamePanel.setLayout(new java.awt.GridBagLayout());
|
|
487 |
layerNamePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
|
488 |
null, PluginServices.getText(this, "layer_name"),
|
|
489 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
|
490 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
|
491 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
492 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
|
493 |
gridBagConstraints.weightx = 1.0;
|
|
494 |
layerNamePanel.add(getTxtName(), gridBagConstraints);
|
|
495 |
}
|
493 |
496 |
|
494 |
|
return layerNamePanel;
|
495 |
|
}
|
|
497 |
return layerNamePanel;
|
|
498 |
}
|
496 |
499 |
|
497 |
|
/**
|
498 |
|
* Gets the name of the layer (feature) selected.
|
499 |
|
*
|
500 |
|
* @return the layer name
|
501 |
|
*/
|
502 |
|
public String getLayerName() {
|
503 |
|
if ((WFSSelectedFeature)getLstFeatures().getSelectedValue() != null){
|
504 |
|
return ((WFSSelectedFeature)getLstFeatures().getSelectedValue()).getName();
|
505 |
|
}
|
506 |
|
return "";
|
507 |
|
}
|
|
500 |
/**
|
|
501 |
* Gets the name of the layer (feature) selected.
|
|
502 |
*
|
|
503 |
* @return the layer name
|
|
504 |
*/
|
|
505 |
public String getLayerName() {
|
|
506 |
if ((WFSSelectedFeature) getLstFeatures().getSelectedValue() != null) {
|
|
507 |
return ((WFSSelectedFeature) getLstFeatures().getSelectedValue()).getName();
|
|
508 |
}
|
|
509 |
return "";
|
|
510 |
}
|
508 |
511 |
|
509 |
|
/**
|
510 |
|
* Gets the name space of the layer (feature) selected.
|
511 |
|
*
|
512 |
|
* @return the name space
|
513 |
|
*/
|
514 |
|
public String getLayerNameSpace(){
|
515 |
|
return ((WFSSelectedFeature)getLstFeatures().getSelectedValue()).getNameSpace();
|
516 |
|
}
|
|
512 |
/**
|
|
513 |
* Gets the name space of the layer (feature) selected.
|
|
514 |
*
|
|
515 |
* @return the name space
|
|
516 |
*/
|
|
517 |
public String getLayerNameSpace() {
|
|
518 |
return ((WFSSelectedFeature) getLstFeatures().getSelectedValue()).getNameSpace();
|
|
519 |
}
|
517 |
520 |
|
518 |
|
/**
|
519 |
|
* Gets the selected feature.
|
520 |
|
*
|
521 |
|
* @return the selected feature
|
522 |
|
*/
|
523 |
|
public WFSSelectedFeature getSelectedFeature() {
|
524 |
|
WFSSelectedFeature selectedFeature = (WFSSelectedFeature)getLstFeatures().getSelectedValue();
|
|
521 |
/**
|
|
522 |
* Gets the selected feature.
|
|
523 |
*
|
|
524 |
* @return the selected feature
|
|
525 |
*/
|
|
526 |
public WFSSelectedFeature getSelectedFeature() {
|
|
527 |
WFSSelectedFeature selectedFeature = (WFSSelectedFeature) getLstFeatures().getSelectedValue();
|
525 |
528 |
|
526 |
|
if (selectedFeature != null) {
|
527 |
|
layerNode = selectedFeature;
|
528 |
|
}
|
|
529 |
if (selectedFeature != null) {
|
|
530 |
layerNode = selectedFeature;
|
|
531 |
}
|
529 |
532 |
|
530 |
|
return layerNode;
|
531 |
|
}
|
|
533 |
return layerNode;
|
|
534 |
}
|
532 |
535 |
|
533 |
|
/**
|
534 |
|
* Sets the name of the feature selected.
|
535 |
|
*
|
536 |
|
* @param name the name of the feature selected
|
537 |
|
*/
|
538 |
|
public void setLayerName(String name) {
|
539 |
|
getTxtName().setText(name);
|
540 |
|
}
|
|
536 |
/**
|
|
537 |
* Sets the name of the feature selected.
|
|
538 |
*
|
|
539 |
* @param name the name of the feature selected
|
|
540 |
*/
|
|
541 |
public void setLayerName(String name) {
|
|
542 |
getTxtName().setText(name);
|
|
543 |
}
|
541 |
544 |
|
542 |
|
/*
|
543 |
|
* (non-Javadoc)
|
544 |
|
* @see com.iver.cit.gvsig.gui.panels.AbstractWFSPanel#initialize()
|
545 |
|
*/
|
546 |
|
protected void initialize() {
|
547 |
|
setLabel(PluginServices.getText(this, "feature"));
|
548 |
|
setLabelGroup(PluginServices.getText(this, "wfs"));
|
549 |
|
java.awt.GridBagConstraints gridBagConstraints;
|
550 |
|
this.setLayout(new java.awt.GridBagLayout());
|
|
545 |
/*
|
|
546 |
* (non-Javadoc)
|
|
547 |
* @see com.iver.cit.gvsig.gui.panels.AbstractWFSPanel#initialize()
|
|
548 |
*/
|
|
549 |
protected void initialize() {
|
|
550 |
setLabel(PluginServices.getText(this, "feature"));
|
|
551 |
setLabelGroup(PluginServices.getText(this, "wfs"));
|
|
552 |
java.awt.GridBagConstraints gridBagConstraints;
|
|
553 |
this.setLayout(new java.awt.GridBagLayout());
|
551 |
554 |
|
552 |
|
gridBagConstraints = new java.awt.GridBagConstraints();
|
553 |
|
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
554 |
|
gridBagConstraints.weightx = 1.0;
|
555 |
|
this.add(getLayerNamePanel(), gridBagConstraints);
|
|
555 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
556 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
|
557 |
gridBagConstraints.weightx = 1.0;
|
|
558 |
this.add(getLayerNamePanel(), gridBagConstraints);
|
556 |
559 |
|
557 |
|
gridBagConstraints = new java.awt.GridBagConstraints();
|
558 |
|
gridBagConstraints.gridx = 0;
|
559 |
|
gridBagConstraints.gridy = 1;
|
560 |
|
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
|
561 |
|
gridBagConstraints.weightx = 1.0;
|
562 |
|
gridBagConstraints.weighty = 1.0;
|
563 |
|
this.add(getFeaturesListPanel(), gridBagConstraints);
|
|
560 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
561 |
gridBagConstraints.gridx = 0;
|
|
562 |
gridBagConstraints.gridy = 1;
|
|
563 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
|
|
564 |
gridBagConstraints.weightx = 1.0;
|
|
565 |
gridBagConstraints.weighty = 1.0;
|
|
566 |
this.add(getFeaturesListPanel(), gridBagConstraints);
|
564 |
567 |
|
565 |
|
gridBagConstraints = new java.awt.GridBagConstraints();
|
566 |
|
gridBagConstraints.gridx = 0;
|
567 |
|
gridBagConstraints.gridy = 2;
|
568 |
|
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
569 |
|
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
|
570 |
|
gridBagConstraints.weightx = 1.0;
|
571 |
|
this.add(getChkExtendedNames(), gridBagConstraints);
|
|
568 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
569 |
gridBagConstraints.gridx = 0;
|
|
570 |
gridBagConstraints.gridy = 2;
|
|
571 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
|
572 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
|
|
573 |
gridBagConstraints.weightx = 1.0;
|
|
574 |
this.add(getChkExtendedNames(), gridBagConstraints);
|
572 |
575 |
|
573 |
|
}
|
|
576 |
}
|
574 |
577 |
|
575 |
|
/*
|
576 |
|
* (non-Javadoc)
|
577 |
|
* @see com.iver.cit.gvsig.gui.panels.AbstractWFSPanel#setReference(java.lang.Object)
|
578 |
|
*/
|
579 |
|
public void setReference(Object ref) {
|
580 |
|
super.setReference(ref);
|
|
578 |
/*
|
|
579 |
* (non-Javadoc)
|
|
580 |
* @see com.iver.cit.gvsig.gui.panels.AbstractWFSPanel#setReference(java.lang.Object)
|
|
581 |
*/
|
|
582 |
public void setReference(Object ref) {
|
|
583 |
super.setReference(ref);
|
581 |
584 |
// if (ref instanceof FLyrWFS){
|
582 |
|
// getPanelGroup().setEnabledApplyButton(false);
|
583 |
|
// }
|
584 |
|
}
|
|
585 |
// getPanelGroup().setEnabledApplyButton(false);
|
|
586 |
// }
|
|
587 |
}
|
585 |
588 |
|
586 |
|
/**
|
587 |
|
* Updates the list with no feature selected.
|
588 |
|
*/
|
589 |
|
public void unselectAllFeatures() {
|
590 |
|
// Reset the last row selection of the features table
|
591 |
|
int numberOfFeatures = getLstFeatures().getRowCount();
|
|
589 |
/**
|
|
590 |
* Updates the list with no feature selected.
|
|
591 |
*/
|
|
592 |
public void unselectAllFeatures() {
|
|
593 |
// Reset the last row selection of the features table
|
|
594 |
int numberOfFeatures = getLstFeatures().getRowCount();
|
592 |
595 |
|
593 |
|
if (numberOfFeatures > 0) {
|
594 |
|
ListSelectionModel model = getLstFeatures().getSelectionModel();
|
595 |
|
model.removeSelectionInterval(0, numberOfFeatures - 1); // whatever row selection
|
596 |
|
}
|
597 |
|
}
|
|
596 |
if (numberOfFeatures > 0) {
|
|
597 |
ListSelectionModel model = getLstFeatures().getSelectionModel();
|
|
598 |
model.removeSelectionInterval(0, numberOfFeatures - 1); // whatever row selection
|
|
599 |
}
|
|
600 |
}
|
598 |
601 |
|
599 |
|
/**
|
600 |
|
* Table with the information of all layers which could be selected from the server connected.
|
601 |
|
*
|
602 |
|
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
603 |
|
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
604 |
|
*/
|
605 |
|
public class LayerTable extends JTable {
|
606 |
|
private static final long serialVersionUID = 4700375945858283696L;
|
607 |
|
private int headerSelected = -1;
|
|
602 |
/**
|
|
603 |
* Table with the information of all layers which could be selected from the
|
|
604 |
* server connected.
|
|
605 |
*
|
|
606 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
|
607 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
|
608 |
*/
|
|
609 |
public class LayerTable extends JTable {
|
608 |
610 |
|
609 |
|
/**
|
610 |
|
* Creates a new instance of <code>LayerTable</code>
|
611 |
|
*/
|
612 |
|
public LayerTable() {
|
613 |
|
super();
|
|
611 |
private static final long serialVersionUID = 4700375945858283696L;
|
|
612 |
private int headerSelected = -1;
|
614 |
613 |
|
615 |
|
setModel(new LayerTableModel());
|
|
614 |
/**
|
|
615 |
* Creates a new instance of <code>LayerTable</code>
|
|
616 |
*/
|
|
617 |
public LayerTable() {
|
|
618 |
super();
|
616 |
619 |
|
617 |
|
getTableHeader().setUI(new BasicTableHeaderSelectableUI());
|
|
620 |
setModel(new LayerTableModel());
|
618 |
621 |
|
619 |
|
getTableHeader().addMouseListener(new MouseAdapter() {
|
620 |
|
/*
|
621 |
|
* (non-Javadoc)
|
622 |
|
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
623 |
|
*/
|
624 |
|
public void mouseClicked(MouseEvent e) {
|
625 |
|
// Sorts according the selected column
|
626 |
|
((LayerTableModel)getModel()).sort(getTableHeader().getColumnModel().getColumnIndexAtX(e.getX()));
|
627 |
|
}
|
|
622 |
getTableHeader().setUI(new BasicTableHeaderSelectableUI());
|
628 |
623 |
|
629 |
|
/*
|
630 |
|
* (non-Javadoc)
|
631 |
|
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
|
632 |
|
*/
|
633 |
|
public void mousePressed(MouseEvent e) {
|
634 |
|
headerSelected = getTableHeader().getColumnModel().getColumnIndexAtX(e.getX());
|
635 |
|
getTableHeader().repaint();
|
636 |
|
}
|
|
624 |
getTableHeader().addMouseListener(new MouseAdapter() {
|
|
625 |
/*
|
|
626 |
* (non-Javadoc)
|
|
627 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
|
628 |
*/
|
|
629 |
public void mouseClicked(MouseEvent e) {
|
|
630 |
// Sorts according the selected column
|
|
631 |
((LayerTableModel) getModel()).sort(getTableHeader().getColumnModel().getColumnIndexAtX(e.getX()));
|
|
632 |
}
|
637 |
633 |
|
638 |
|
/*
|
639 |
|
* (non-Javadoc)
|
640 |
|
* @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
|
641 |
|
*/
|
642 |
|
public void mouseReleased(MouseEvent e) {
|
643 |
|
headerSelected = -1;
|
644 |
|
}
|
645 |
|
});
|
646 |
|
}
|
|
634 |
/*
|
|
635 |
* (non-Javadoc)
|
|
636 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
|
|
637 |
*/
|
|
638 |
public void mousePressed(MouseEvent e) {
|
|
639 |
headerSelected = getTableHeader().getColumnModel().getColumnIndexAtX(e.getX());
|
|
640 |
getTableHeader().repaint();
|
|
641 |
}
|
647 |
642 |
|
648 |
|
/*
|
649 |
|
* (non-Javadoc)
|
650 |
|
* @see javax.swing.JTable#createDefaultColumnsFromModel()
|
651 |
|
*/
|
652 |
|
public void createDefaultColumnsFromModel() {
|
653 |
|
TableModel m = getModel();
|
654 |
|
if (m != null) {
|
655 |
|
// Remove any current columns
|
656 |
|
TableColumnModel cm = getColumnModel();
|
657 |
|
while (cm.getColumnCount() > 0) {
|
658 |
|
cm.removeColumn(cm.getColumn(0));
|
659 |
|
}
|
|
643 |
/*
|
|
644 |
* (non-Javadoc)
|
|
645 |
* @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
|
|
646 |
*/
|
|
647 |
public void mouseReleased(MouseEvent e) {
|
|
648 |
headerSelected = -1;
|
|
649 |
}
|
|
650 |
});
|
|
651 |
}
|
660 |
652 |
|
661 |
|
// Create new columns from the data model info
|
662 |
|
for (int i = 0; i < m.getColumnCount(); i++) {
|
663 |
|
TableColumn newColumn = new TableColumn(i);
|
|
653 |
/*
|
|
654 |
* (non-Javadoc)
|
|
655 |
* @see javax.swing.JTable#createDefaultColumnsFromModel()
|
|
656 |
*/
|
|
657 |
public void createDefaultColumnsFromModel() {
|
|
658 |
TableModel m = getModel();
|
|
659 |
if (m != null) {
|
|
660 |
// Remove any current columns
|
|
661 |
TableColumnModel cm = getColumnModel();
|
|
662 |
while (cm.getColumnCount() > 0) {
|
|
663 |
cm.removeColumn(cm.getColumn(0));
|
|
664 |
}
|
664 |
665 |
|
665 |
|
// Special renderer for supporting selection of a particular column header
|
666 |
|
newColumn.setHeaderRenderer(new DefaultTableSelectableCellRenderer());
|
667 |
|
addColumn(newColumn);
|
668 |
|
}
|
669 |
|
}
|
670 |
|
}
|
|
666 |
// Create new columns from the data model info
|
|
667 |
for (int i = 0; i < m.getColumnCount(); i++) {
|
|
668 |
TableColumn newColumn = new TableColumn(i);
|
671 |
669 |
|
672 |
|
/**
|
673 |
|
* Gets the selected <i>WFS</i> layer.
|
674 |
|
*
|
675 |
|
* @return node of the selected <i>WFS</i> layer
|
676 |
|
*/
|
677 |
|
public WFSSelectedFeature getSelectedValue() {
|
678 |
|
int selectedRow = getSelectedRow();
|
679 |
|
LayerTableModel model = (LayerTableModel)getModel();
|
|
670 |
// Special renderer for supporting selection of a particular column header
|
|
671 |
newColumn.setHeaderRenderer(new DefaultTableSelectableCellRenderer());
|
|
672 |
addColumn(newColumn);
|
|
673 |
}
|
|
674 |
}
|
|
675 |
}
|
680 |
676 |
|
681 |
|
return model.getLayerAt(selectedRow);
|
682 |
|
}
|
|
677 |
/**
|
|
678 |
* Gets the selected <i>WFS</i> layer.
|
|
679 |
*
|
|
680 |
* @return node of the selected <i>WFS</i> layer
|
|
681 |
*/
|
|
682 |
public WFSSelectedFeature getSelectedValue() {
|
|
683 |
int selectedRow = getSelectedRow();
|
|
684 |
LayerTableModel model = (LayerTableModel) getModel();
|
683 |
685 |
|
684 |
|
/**
|
685 |
|
* Gets the layer at a row position.
|
686 |
|
*
|
687 |
|
* @return node of the selected <i>WFS</i> layer
|
688 |
|
*/
|
689 |
|
public WFSSelectedFeature getValueAt(int position) {
|
690 |
|
if (position < this.getRowCount()) {
|
691 |
|
LayerTableModel model = (LayerTableModel)getModel();
|
|
686 |
return model.getLayerAt(selectedRow);
|
|
687 |
}
|
692 |
688 |
|
693 |
|
return model.getLayerAt(position);
|
694 |
|
}
|
|
689 |
/**
|
|
690 |
* Gets the layer at a row position.
|
|
691 |
*
|
|
692 |
* @return node of the selected <i>WFS</i> layer
|
|
693 |
*/
|
|
694 |
public WFSSelectedFeature getValueAt(int position) {
|
|
695 |
if (position < this.getRowCount()) {
|
|
696 |
LayerTableModel model = (LayerTableModel) getModel();
|
695 |
697 |
|
696 |
|
return null;
|
697 |
|
}
|
|
698 |
return model.getLayerAt(position);
|
|
699 |
}
|
698 |
700 |
|
699 |
|
/**
|
700 |
|
* Adds the available features to load as a <i>WFS</i> layer.
|
701 |
|
*
|
702 |
|
* @param features available features
|
703 |
|
*/
|
704 |
|
public void addFeatures(WFSSelectedFeature[] features) {
|
705 |
|
LayerTableModel model = (LayerTableModel)getModel();
|
706 |
|
model.deleteAllRows();
|
|
701 |
return null;
|
|
702 |
}
|
707 |
703 |
|
708 |
|
for (int i=0 ; i < features.length ; i++){
|
709 |
|
model.addRow(features[i]);
|
710 |
|
}
|
711 |
|
}
|
|
704 |
/**
|
|
705 |
* Adds the available features to load as a <i>WFS</i> layer.
|
|
706 |
*
|
|
707 |
* @param features available features
|
|
708 |
*/
|
|
709 |
public void addFeatures(WFSSelectedFeature[] features) {
|
|
710 |
LayerTableModel model = (LayerTableModel) getModel();
|
|
711 |
model.deleteAllRows();
|
712 |
712 |
|
713 |
|
/**
|
714 |
|
* Shows the names of the features.
|
715 |
|
*
|
716 |
|
* @param showFeatureNameType The showLayerNames to set.
|
717 |
|
*/
|
718 |
|
public void setShowLayerNames(boolean showFeatureNameType) {
|
719 |
|
LayerTableModel model = (LayerTableModel)getModel();
|
720 |
|
model.setShowedFeatureNameType(showFeatureNameType);
|
721 |
|
}
|
|
713 |
for (int i = 0; i < features.length; i++) {
|
|
714 |
model.addRow(features[i]);
|
|
715 |
}
|
|
716 |
}
|
722 |
717 |
|
723 |
|
/**
|
724 |
|
* Model of the <code>LayerTable</code> that stores the features available to load as a WFS layer.
|
725 |
|
*
|
726 |
|
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
727 |
|
* @author Pablo Piqueras Bartolome (pablo.piqueras@iver.es)
|
728 |
|
*/
|
729 |
|
public class LayerTableModel extends AbstractTableModel {
|
730 |
|
private static final long serialVersionUID = 2722138264867593508L;
|
731 |
|
private Vector<WFSSelectedFeature> layers = new Vector<WFSSelectedFeature>();
|
732 |
|
private boolean showFeatureNameType = false;
|
733 |
|
private WFSLayerStringComparator stringComparator;
|
734 |
|
private boolean updatingSelection;
|
735 |
|
private short previousColumnSorted;
|
|
718 |
/**
|
|
719 |
* Shows the names of the features.
|
|
720 |
*
|
|
721 |
* @param showFeatureNameType The showLayerNames to set.
|
|
722 |
*/
|
|
723 |
public void setShowLayerNames(boolean showFeatureNameType) {
|
|
724 |
LayerTableModel model = (LayerTableModel) getModel();
|
|
725 |
model.setShowedFeatureNameType(showFeatureNameType);
|
|
726 |
}
|
736 |
727 |
|
|
728 |
/**
|
|
729 |
* Model of the <code>LayerTable</code> that stores the features
|
|
730 |
* available to load as a WFS layer.
|
|
731 |
*
|
|
732 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
|
733 |
* @author Pablo Piqueras Bartolome (pablo.piqueras@iver.es)
|
|
734 |
*/
|
|
735 |
public class LayerTableModel extends AbstractTableModel {
|
737 |
736 |
|
738 |
|
/**
|
739 |
|
* Constructs an investment table model.
|
740 |
|
*/
|
741 |
|
public LayerTableModel(){
|
742 |
|
super();
|
|
737 |
private static final long serialVersionUID = 2722138264867593508L;
|
|
738 |
private Vector<WFSSelectedFeature> layers = new Vector<WFSSelectedFeature>();
|
|
739 |
private boolean showFeatureNameType = false;
|
|
740 |
private WFSLayerStringComparator stringComparator;
|
|
741 |
private boolean updatingSelection;
|
|
742 |
private short previousColumnSorted;
|
743 |
743 |
|
744 |
|
// Alphabetical sort ordering support
|
745 |
|
updatingSelection = false;
|
746 |
|
previousColumnSorted = -1;
|
747 |
|
Collator collator = Collator.getInstance(new Locale("en_EN"));
|
748 |
|
stringComparator = new WFSLayerStringComparator();
|
749 |
|
stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
|
750 |
|
stringComparator.setCaseSensitive(false);
|
751 |
|
stringComparator.setAscendingOrdering(true);
|
752 |
|
}
|
|
744 |
/**
|
|
745 |
* Constructs an investment table model.
|
|
746 |
*/
|
|
747 |
public LayerTableModel() {
|
|
748 |
super();
|
753 |
749 |
|
|
750 |
// Alphabetical sort ordering support
|
|
751 |
updatingSelection = false;
|
|
752 |
previousColumnSorted = -1;
|
|
753 |
Collator collator = Collator.getInstance(new Locale("en_EN"));
|
|
754 |
stringComparator = new WFSLayerStringComparator();
|
|
755 |
stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
|
|
756 |
stringComparator.setCaseSensitive(false);
|
|
757 |
stringComparator.setAscendingOrdering(true);
|
|
758 |
}
|
754 |
759 |
|
755 |
|
/*
|
756 |
|
* (non-Javadoc)
|
757 |
|
* @see javax.swing.table.TableModel#getRowCount()
|
758 |
|
*/
|
759 |
|
public int getRowCount(){
|
760 |
|
return layers.size();
|
761 |
|
}
|
762 |
760 |
|
763 |
|
/*
|
764 |
|
* (non-Javadoc)
|
765 |
|
* @see javax.swing.table.TableModel#getColumnCount()
|
766 |
|
*/
|
767 |
|
public int getColumnCount(){
|
768 |
|
return 2;
|
769 |
|
}
|
|
761 |
/*
|
|
762 |
* (non-Javadoc)
|
|
763 |
* @see javax.swing.table.TableModel#getRowCount()
|
|
764 |
*/
|
|
765 |
public int getRowCount() {
|
|
766 |
return layers.size();
|
|
767 |
}
|
770 |
768 |
|
771 |
|
/*
|
772 |
|
* (non-Javadoc)
|
773 |
|
* @see javax.swing.table.TableModel#getValueAt(int, int)
|
774 |
|
*/
|
775 |
|
public Object getValueAt(int rowNumber, int columnNumber){
|
776 |
|
if (rowNumber < layers.size()) {
|
777 |
|
WFSSelectedFeature layer = (WFSSelectedFeature)layers.get(rowNumber);
|
|
769 |
/*
|
|
770 |
* (non-Javadoc)
|
|
771 |
* @see javax.swing.table.TableModel#getColumnCount()
|
|
772 |
*/
|
|
773 |
public int getColumnCount() {
|
|
774 |
return 2;
|
|
775 |
}
|
778 |
776 |
|
779 |
|
if (columnNumber == 0) {
|
780 |
|
return getLayerName(layer);
|
781 |
|
} else {
|
782 |
|
if (layer.getGeometryField() != null){
|
783 |
|
return PluginServices.getText(this, layer.getGeometryField().getType());
|
784 |
|
}
|
785 |
|
return "";
|
786 |
|
}
|
787 |
|
} else {
|
788 |
|
return "";
|
789 |
|
}
|
790 |
|
}
|
|
777 |
/*
|
|
778 |
* (non-Javadoc)
|
|
779 |
* @see javax.swing.table.TableModel#getValueAt(int, int)
|
|
780 |
*/
|
|
781 |
public Object getValueAt(int rowNumber, int columnNumber) {
|
|
782 |
if (rowNumber < layers.size()) {
|
|
783 |
WFSSelectedFeature layer = (WFSSelectedFeature) layers.get(rowNumber);
|
791 |
784 |
|
792 |
|
/**
|
793 |
|
* Gets the layer name displaying the type name of the feature collection associated if it's needed.
|
794 |
|
*
|
795 |
|
* @param layer a <i>WFS</i> layer
|
796 |
|
* @return the layer name
|
797 |
|
*/
|
798 |
|
private String getLayerName(WFSSelectedFeature layer){
|
799 |
|
if (showFeatureNameType){
|
800 |
|
return "[" + layer.getName() + "] " + layer.getTitle();
|
801 |
|
} else {
|
802 |
|
return layer.getTitle();
|
803 |
|
}
|
804 |
|
}
|
|
785 |
if (columnNumber == 0) {
|
|
786 |
return getLayerName(layer);
|
|
787 |
} else {
|
|
788 |
if (layer.getGeometryField() != null) {
|
|
789 |
return PluginServices.getText(this, layer.getGeometryField().getType());
|
|
790 |
}
|
|
791 |
return "";
|
|
792 |
}
|
|
793 |
} else {
|
|
794 |
return "";
|
|
795 |
}
|
|
796 |
}
|
805 |
797 |
|
806 |
|
/**
|
807 |
|
* Gets the layer at the specified position.
|
808 |
|
*
|
809 |
|
* @param rowNumber row position
|
810 |
|
* @return <i>WFS</i> layer node
|
811 |
|
*/
|
812 |
|
public WFSSelectedFeature getLayerAt(int rowNumber){
|
813 |
|
try {
|
814 |
|
if (rowNumber == -1)
|
815 |
|
return null;
|
|
798 |
/**
|
|
799 |
* Gets the layer name displaying the type name of the feature
|
|
800 |
* collection associated if it's needed.
|
|
801 |
*
|
|
802 |
* @param layer a <i>WFS</i> layer
|
|
803 |
* @return the layer name
|
|
804 |
*/
|
|
805 |
private String getLayerName(WFSSelectedFeature layer) {
|
|
806 |
if (showFeatureNameType) {
|
|
807 |
return "[" + layer.getName() + "] " + layer.getTitle();
|
|
808 |
} else {
|
|
809 |
return layer.getTitle();
|
|
810 |
}
|
|
811 |
}
|
816 |
812 |
|
817 |
|
return (WFSSelectedFeature)layers.get(rowNumber);
|
818 |
|
} catch (ArrayIndexOutOfBoundsException e) {
|
819 |
|
NotificationManager.addError(e);
|
820 |
|
return null;
|
821 |
|
}
|
822 |
|
}
|
|
813 |
/**
|
|
814 |
* Gets the layer at the specified position.
|
|
815 |
*
|
|
816 |
* @param rowNumber row position
|
|
817 |
* @return <i>WFS</i> layer node
|
|
818 |
*/
|
|
819 |
public WFSSelectedFeature getLayerAt(int rowNumber) {
|
|
820 |
try {
|
|
821 |
if (rowNumber == -1) {
|
|
822 |
return null;
|
|
823 |
}
|
823 |
824 |
|
824 |
|
/**
|
825 |
|
* Adds a new layer to the table model, each table will be represented as a row.
|
826 |
|
*
|
827 |
|
* @param layer a new <i>WFS</i> layer
|
828 |
|
*/
|
829 |
|
public void addRow(WFSSelectedFeature layer){
|
830 |
|
layers.add(layer);
|
831 |
|
fireTableRowsInserted(getRowCount(), getRowCount());
|
832 |
|
fireTableRowsUpdated(0,getRowCount());
|
833 |
|
}
|
|
825 |
return (WFSSelectedFeature) layers.get(rowNumber);
|
|
826 |
} catch (ArrayIndexOutOfBoundsException e) {
|
|
827 |
NotificationManager.addError(e);
|
|
828 |
return null;
|
|
829 |
}
|
|
830 |
}
|
834 |
831 |
|
835 |
|
/**
|
836 |
|
* Deletes all the table rows.
|
837 |
|
*/
|
838 |
|
public void deleteAllRows(){
|
839 |
|
layers.clear();
|
840 |
|
int rows = getRowCount();
|
|
832 |
/**
|
|
833 |
* Adds a new layer to the table model, each table will be
|
|
834 |
* represented as a row.
|
|
835 |
*
|
|
836 |
* @param layer a new <i>WFS</i> layer
|
|
837 |
*/
|
|
838 |
public void addRow(WFSSelectedFeature layer) {
|
|
839 |
layers.add(layer);
|
|
840 |
fireTableRowsInserted(getRowCount(), getRowCount());
|
|
841 |
fireTableRowsUpdated(0, getRowCount());
|
|
842 |
}
|
841 |
843 |
|
842 |
|
if (rows >= 1){
|
843 |
|
fireTableRowsDeleted(0, rows - 1);
|
844 |
|
}
|
845 |
|
}
|
|
844 |
/**
|
|
845 |
* Deletes all the table rows.
|
|
846 |
*/
|
|
847 |
public void deleteAllRows() {
|
|
848 |
layers.clear();
|
|
849 |
int rows = getRowCount();
|
846 |
850 |
|
847 |
|
/**
|
848 |
|
* Delete all the table rows
|
849 |
|
*/
|
850 |
|
public void deleteRow(int rowPosition){
|
851 |
|
layers.remove(rowPosition);
|
852 |
|
fireTableRowsDeleted(rowPosition, rowPosition);
|
853 |
|
fireTableRowsUpdated(0,getRowCount());
|
854 |
|
}
|
|
851 |
if (rows >= 1) {
|
|
852 |
fireTableRowsDeleted(0, rows - 1);
|
|
853 |
}
|
|
854 |
}
|
855 |
855 |
|
856 |
|
/*
|
857 |
|
* (non-Javadoc)
|
858 |
|
* @see javax.swing.table.TableModel#getColumnName(int)
|
859 |
|
*/
|
860 |
|
public String getColumnName(int columnIndex){
|
861 |
|
if (columnIndex == 0){
|
862 |
|
return PluginServices.getText(this, "layerName");
|
863 |
|
}else{
|
864 |
|
return PluginServices.getText(this, "layerType");
|
865 |
|
}
|
866 |
|
}
|
|
856 |
/**
|
|
857 |
* Delete all the table rows
|
|
858 |
*/
|
|
859 |
public void deleteRow(int rowPosition) {
|
|
860 |
layers.remove(rowPosition);
|
|
861 |
fireTableRowsDeleted(rowPosition, rowPosition);
|
|
862 |
fireTableRowsUpdated(0, getRowCount());
|
|
863 |
}
|
867 |
864 |
|
868 |
|
/**
|
869 |
|
* Gets if shows the feature name type.
|
870 |
|
*
|
871 |
|
* @return <code>true</code> if shows the feature name type; <code>false</code> otherwise
|
872 |
|
*/
|
873 |
|
public boolean isShowedFeatureNameType() {
|
874 |
|
return showFeatureNameType;
|
875 |
|
}
|
|
865 |
/*
|
|
866 |
* (non-Javadoc)
|
|
867 |
* @see javax.swing.table.TableModel#getColumnName(int)
|
|
868 |
*/
|
|
869 |
public String getColumnName(int columnIndex) {
|
|
870 |
if (columnIndex == 0) {
|
|
871 |
return PluginServices.getText(this, "layerName");
|
|
872 |
} else {
|
|
873 |
return PluginServices.getText(this, "layerType");
|
|
874 |
}
|
|
875 |
}
|
876 |
876 |
|
877 |
|
/**
|
878 |
|
* Gets if shows the feature name type.
|
879 |
|
*
|
880 |
|
* @param showFeatureNameType <code>true</code> if shows the feature name type; <code>false</code> otherwise
|
881 |
|
*/
|
882 |
|
public void setShowedFeatureNameType(boolean showFeatureNameType) {
|
883 |
|
this.showFeatureNameType = showFeatureNameType;
|
|
877 |
/**
|
|
878 |
* Gets if shows the feature name type.
|
|
879 |
*
|
|
880 |
* @return <code>true</code> if shows the feature name type;
|
|
881 |
* <code>false</code> otherwise
|
|
882 |
*/
|
|
883 |
public boolean isShowedFeatureNameType() {
|
|
884 |
return showFeatureNameType;
|
|
885 |
}
|
884 |
886 |
|
885 |
|
this.stringComparator.setShowFeatureNameType(showFeatureNameType);
|
886 |
|
}
|
|
887 |
/**
|
|
888 |
* Gets if shows the feature name type.
|
|
889 |
*
|
|
890 |
* @param showFeatureNameType <code>true</code> if shows the feature
|
|
891 |
* name type; <code>false</code> otherwise
|
|
892 |
*/
|
|
893 |
public void setShowedFeatureNameType(boolean showFeatureNameType) {
|
|
894 |
this.showFeatureNameType = showFeatureNameType;
|
887 |
895 |
|
888 |
|
/**
|
889 |
|
* Sorts the rows of the table alphabetically.
|
890 |
|
*
|
891 |
|
* @param column index of the column to sort. In this table there are only 2 columns.
|
892 |
|
*/
|
893 |
|
public void sort(int column) {
|
894 |
|
// Orders the layer alphabetically according the Spanish alphabetically rules
|
895 |
|
switch(column) {
|
896 |
|
case 0:
|
897 |
|
stringComparator.setColumn(WFSLayerStringComparator.LAYER_NAME);
|
898 |
|
break;
|
899 |
|
case 1:
|
900 |
|
stringComparator.setColumn(WFSLayerStringComparator.GEOMETRY_TYPE);
|
901 |
|
break;
|
902 |
|
}
|
|
896 |
this.stringComparator.setShowFeatureNameType(showFeatureNameType);
|
|
897 |
}
|
903 |
898 |
|
904 |
|
if (previousColumnSorted != column)
|
905 |
|
stringComparator.setAscendingOrdering(true);
|
|
899 |
/**
|
|
900 |
* Sorts the rows of the table alphabetically.
|
|
901 |
*
|
|
902 |
* @param column index of the column to sort. In this table there
|
|
903 |
* are only 2 columns.
|
|
904 |
*/
|
|
905 |
public void sort(int column) {
|
|
906 |
// Orders the layer alphabetically according the Spanish alphabetically rules
|
|
907 |
switch (column) {
|
|
908 |
case 0:
|
|
909 |
stringComparator.setColumn(WFSLayerStringComparator.LAYER_NAME);
|
|
910 |
break;
|
|
911 |
case 1:
|
|
912 |
stringComparator.setColumn(WFSLayerStringComparator.GEOMETRY_TYPE);
|
|
913 |
break;
|
|
914 |
}
|
906 |
915 |
|
907 |
|
previousColumnSorted = (short) column;
|
|
916 |
if (previousColumnSorted != column) {
|
|
917 |
stringComparator.setAscendingOrdering(true);
|
|
918 |
}
|
908 |
919 |
|
909 |
|
WFSSelectedFeature layer = getSelectedValue();
|
|
920 |
previousColumnSorted = (short) column;
|
910 |
921 |
|
911 |
|
Collections.sort(layers, stringComparator);
|
|
922 |
WFSSelectedFeature layer = getSelectedValue();
|
912 |
923 |
|
913 |
|
if (layer != null) {
|
914 |
|
updatingSelection = true;
|
915 |
|
unselectAllFeatures();
|
916 |
|
int row = Collections.binarySearch(layers, layer, stringComparator);
|
|
924 |
Collections.sort(layers, stringComparator);
|
917 |
925 |
|
918 |
|
if (row != -1) {
|
919 |
|
ListSelectionModel model = getSelectionModel();
|
920 |
|
model.setLeadSelectionIndex(row);
|
921 |
|
}
|
|
926 |
if (layer != null) {
|
|
927 |
updatingSelection = true;
|
|
928 |
unselectAllFeatures();
|
|
929 |
int row = Collections.binarySearch(layers, layer, stringComparator);
|
922 |
930 |
|
923 |
|
updatingSelection = false;
|
924 |
|
}
|
925 |
|
stringComparator.setAscendingOrdering(!stringComparator.isAscendingOrdering());
|
926 |
|
}
|
|
931 |
if (row != -1) {
|
|
932 |
ListSelectionModel model = getSelectionModel();
|
|
933 |
model.setLeadSelectionIndex(row);
|
|
934 |
}
|
927 |
935 |
|
928 |
|
/**
|
929 |
|
* Determines if now is updating the selection of the previous selected item.
|
930 |
|
*
|
931 |
|
* @return <code>true</code> if now is updating the selection of the previous selected item; otherwise <code>false</code>
|
932 |
|
*/
|
933 |
|
public boolean isUpdatingSelection() {
|
934 |
|
return updatingSelection;
|
935 |
|
}
|
936 |
|
}
|
|
936 |
updatingSelection = false;
|
|
937 |
}
|
|
938 |
stringComparator.setAscendingOrdering(!stringComparator.isAscendingOrdering());
|
|
939 |
}
|
937 |
940 |
|
938 |
|
/**
|
939 |
|
* <p>Enhances {@link BasicTableHeaderUI BasicTableHeaderUI} adding support for column head selection.</p>
|
940 |
|
*
|
941 |
|
* @see BasicTableHeaderUI
|
942 |
|
*
|
943 |
|
* @version 29/01/2008
|
944 |
|
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
945 |
|
*/
|
946 |
|
private class BasicTableHeaderSelectableUI extends BasicTableHeaderUI {
|
947 |
|
/**
|
948 |
|
* Creates a new BasicTableHeaderSelectableUI object
|
949 |
|
*/
|
950 |
|
public BasicTableHeaderSelectableUI() {
|
951 |
|
super();
|
952 |
|
}
|
|
941 |
/**
|
|
942 |
* Determines if now is updating the selection of the previous
|
|
943 |
* selected item.
|
|
944 |
*
|
|
945 |
* @return <code>true</code> if now is updating the selection of the
|
|
946 |
* previous selected item; otherwise <code>false</code>
|
|
947 |
*/
|
|
948 |
public boolean isUpdatingSelection() {
|
|
949 |
return updatingSelection;
|
|
950 |
}
|
|
951 |
}
|
953 |
952 |
|
|
953 |
/**
|
|
954 |
* <p>
|
|
955 |
* Enhances {@link BasicTableHeaderUI BasicTableHeaderUI} adding support
|
|
956 |
* for column head selection.</p>
|
|
957 |
*
|
|
958 |
* @see BasicTableHeaderUI
|
|
959 |
*
|
|
960 |
* @version 29/01/2008
|
|
961 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
|
962 |
*/
|
|
963 |
private class BasicTableHeaderSelectableUI extends BasicTableHeaderUI {
|
|
964 |
|
|
965 |
/**
|
|
966 |
* Creates a new BasicTableHeaderSelectableUI object
|
|
967 |
*/
|
|
968 |
public BasicTableHeaderSelectableUI() {
|
|
969 |
super();
|
|
970 |
}
|
|
971 |
|
954 |
972 |
//
|
955 |
|
// Some Paint Methods and support re-implemented
|
956 |
|
//
|