Revision 9153 branches/v10/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/WFSFilterPanel.java
WFSFilterPanel.java | ||
---|---|---|
49 | 49 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
50 | 50 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
51 | 51 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
52 |
import com.iver.cit.gvsig.gui.filter.DefaultExpressionDataSource; |
|
52 | 53 |
import com.iver.cit.gvsig.gui.filter.ExpressionDataSource; |
53 | 54 |
import com.iver.cit.gvsig.gui.filter.ExpressionListener; |
54 | 55 |
import com.iver.cit.gvsig.gui.filter.FilterException; |
... | ... | |
155 | 156 |
* Adds some more listener to the components of the panel |
156 | 157 |
*/ |
157 | 158 |
private void addNewListeners() { |
159 |
|
|
160 |
// Enable "Apply" button when user changes the filter query |
|
158 | 161 |
txtExpression.getDocument().addDocumentListener(new DocumentListener() { |
159 | 162 |
/* |
160 | 163 |
* (non-Javadoc) |
... | ... | |
229 | 232 |
* @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent) |
230 | 233 |
*/ |
231 | 234 |
public void valueChanged(TreeSelectionEvent e) { |
232 |
if (!panelAsATabForWFSLayersLoad) { |
|
235 |
if (!panelAsATabForWFSLayersLoad) {
|
|
233 | 236 |
DataReturnedOfDataLoadingFromActiveView data = DataLoadingFromActiveView.getDefaultExpressionDataSource(); |
234 | 237 |
|
235 | 238 |
if ((data != null) && (data.getData() != null)) { |
236 |
setModel(data.getData()); |
|
239 |
// setModel(data.getData());
|
|
237 | 240 |
currentPath = e.getPath(); |
238 | 241 |
fillValuesByPath(currentPath); |
239 | 242 |
} |
... | ... | |
246 | 249 |
* If there is a field selected, show its new values |
247 | 250 |
*/ |
248 | 251 |
public void updateFieldValues() { |
252 |
|
|
253 |
// If has selected and loaded another layer -> reset previous values |
|
254 |
// if (this.panelAsATabForWFSLayersLoad) { |
|
255 |
// this.getValuesJList().removeAll(); |
|
256 |
// } |
|
257 |
|
|
258 |
|
|
249 | 259 |
if (currentPath != null) { |
260 |
|
|
250 | 261 |
DataReturnedOfDataLoadingFromActiveView data = DataLoadingFromActiveView.getDefaultExpressionDataSource(); |
251 |
|
|
262 |
|
|
252 | 263 |
if ((data != null) && (data.getData() != null)) { |
253 | 264 |
setModel(data.getData()); |
254 | 265 |
fillValuesByPath(currentPath); |
255 | 266 |
|
256 |
// Update all tables that their data is about the changed view |
|
257 |
IWindow[] activeNoModalWindows = PluginServices.getMDIManager().getAllWindows(); |
|
267 |
// Updates all tables that their data is about the changed view |
|
268 |
this.updateTablesThatHasNewData(); |
|
269 |
} |
|
270 |
} |
|
271 |
} |
|
272 |
|
|
273 |
/** |
|
274 |
* Updates all tables that their data is about the changed view |
|
275 |
*/ |
|
276 |
private void updateTablesThatHasNewData() { |
|
277 |
IWindow[] activeNoModalWindows = PluginServices.getMDIManager().getAllWindows(); |
|
278 |
|
|
279 |
for (int i = 0; i < activeNoModalWindows.length; i++) { |
|
280 |
IWindow window = activeNoModalWindows[i]; |
|
281 |
if (window instanceof Table) { |
|
282 |
Table table = (Table) window; |
|
258 | 283 |
|
259 |
|
|
260 |
for (int i = 0; i < activeNoModalWindows.length; i++) { |
|
261 |
IWindow window = activeNoModalWindows[i]; |
|
262 |
if (window instanceof Table) { |
|
263 |
Table table = (Table) window; |
|
264 |
|
|
265 |
int pos1 = featureName.indexOf(':'); |
|
266 |
|
|
267 |
if ((pos1 >= 0) && (pos1 < featureName.length())) |
|
268 |
featureName = featureName.substring(pos1 +1, featureName.length()); |
|
269 |
|
|
270 |
// String featureOfTable = ((XMLElement)currentPath.getParentPath().getLastPathComponent()).getName(); |
|
271 |
String featureOfTable = table.getModel().getName(); |
|
272 |
int pos2 = featureOfTable.indexOf(':'); |
|
273 |
|
|
274 |
if ((pos2 >= 0) && (pos2 < featureName.length())) |
|
275 |
featureOfTable = featureOfTable.substring(pos2 +1, featureOfTable.length()); |
|
276 |
|
|
277 |
if (featureName.trim().compareTo(featureOfTable.trim()) == 0) { |
|
278 |
setNewDataToTable(); |
|
279 |
|
|
280 |
// Refresh the table with the new data |
|
281 |
table.refresh(); |
|
282 |
} |
|
283 |
} |
|
284 |
int pos1 = featureName.indexOf(':'); |
|
285 |
|
|
286 |
if ((pos1 >= 0) && (pos1 < featureName.length())) |
|
287 |
featureName = featureName.substring(pos1 +1, featureName.length()); |
|
288 |
|
|
289 |
// String featureOfTable = ((XMLElement)currentPath.getParentPath().getLastPathComponent()).getName(); |
|
290 |
String featureOfTable = table.getModel().getName(); |
|
291 |
int pos2 = featureOfTable.indexOf(':'); |
|
292 |
|
|
293 |
if ((pos2 >= 0) && (pos2 < featureName.length())) |
|
294 |
featureOfTable = featureOfTable.substring(pos2 +1, featureOfTable.length()); |
|
295 |
|
|
296 |
if (featureName.trim().compareTo(featureOfTable.trim()) == 0) { |
|
297 |
setNewDataToTable(); |
|
298 |
|
|
299 |
// Refresh the table with the new data |
|
300 |
table.refresh(); |
|
284 | 301 |
} |
285 | 302 |
} |
286 | 303 |
} |
287 |
} |
|
304 |
}
|
|
288 | 305 |
|
289 | 306 |
/** |
290 | 307 |
* This method is a modification of the "execute" method from the "ShowTable" class |
... | ... | |
350 | 367 |
super.getValuesJList().setBackground(new Color(220, 220, 220)); |
351 | 368 |
} |
352 | 369 |
else { |
370 |
// Unselect the selected path in the tree (if there was any selected) |
|
371 |
if (this.currentPath != null) { |
|
372 |
this.currentPath = null; |
|
373 |
this.getFieldsJTree().removeSelectionPath(this.getFieldsJTree().getSelectionPath()); |
|
374 |
} |
|
375 |
|
|
376 |
// Resets data loaded |
|
353 | 377 |
super.getValuesJList().setEnabled(true); |
354 | 378 |
super.getValuesJList().setBackground(Color.WHITE); |
379 |
|
|
380 |
this.getFieldsJTree().removeAll(); |
|
381 |
this.getValuesJList().removeAll(); |
|
382 |
|
|
383 |
// Updates data associated to view with the new layer data |
|
384 |
this.setNewDataToTable(); |
|
385 |
|
|
386 |
// If theres is any table associated to the current view -> update that table/s |
|
387 |
// this.updateTablesThatHasNewData(); |
|
388 |
|
|
389 |
// Reads that new data |
|
390 |
DataReturnedOfDataLoadingFromActiveView data = DataLoadingFromActiveView.getDefaultExpressionDataSource(); |
|
391 |
|
|
392 |
if ((data != null) && (data.getData() != null)) { |
|
393 |
setModel(data.getData()); |
|
394 |
// currentPath = e.getPath(); |
|
395 |
// fillValuesByPath(currentPath); |
|
396 |
} |
|
355 | 397 |
} |
356 | 398 |
} |
357 | 399 |
|
358 | 400 |
/** |
359 |
* Rellena la lista con los valores del campo seleccionado |
|
401 |
* Gets the value of the inner attribute: 'panelAsATabForWFSLayersLoad' |
|
402 |
* |
|
403 |
* @return A boolean value |
|
360 | 404 |
*/ |
405 |
public boolean getWFSFilterPanelIsAsTabForWFSLayersLoad() { |
|
406 |
return this.panelAsATabForWFSLayersLoad; |
|
407 |
} |
|
408 |
|
|
409 |
/** |
|
410 |
* FIlls list with the values of selected field |
|
411 |
* |
|
412 |
* @param treePath A path in the tree |
|
413 |
*/ |
|
361 | 414 |
private void fillValuesByPath(TreePath treePath) { |
362 | 415 |
// Duplicates are removed |
363 | 416 |
TreeSet conjunto = new TreeSet(new Comparator() { |
... | ... | |
597 | 650 |
} catch (DriverException e1) { |
598 | 651 |
NotificationManager.addError(e1.getMessage(), e1); |
599 | 652 |
} |
600 |
|
|
653 |
|
|
601 | 654 |
try { |
602 | 655 |
int numberOfFields = model.getFieldCount(); |
603 | 656 |
|
... | ... | |
700 | 753 |
expresion = expresion.substring(0, startIndex - 5) + |
701 | 754 |
expresion.substring(startIndex).replaceFirst(date + "\\)", |
702 | 755 |
new Long((filterButtonsJPanel.getDateFormat().parse(date)).getTime()).toString()); |
703 |
; |
|
756 |
|
|
704 | 757 |
} else { |
705 | 758 |
startIndex += date.length(); |
706 | 759 |
} |
... | ... | |
958 | 1011 |
} |
959 | 1012 |
} |
960 | 1013 |
|
961 |
if (fieldBranches.size() > 0){ |
|
962 |
attributesTreeTableModel = new AttributesTreeTableModel(fieldBranches.get(0)); |
|
963 |
fieldsJTree.setModel(new AttributesTreeTableModel(fieldBranches.get(0), false)); |
|
964 |
} |
|
1014 |
attributesTreeTableModel = new AttributesTreeTableModel(fieldBranches.get(0)); |
|
1015 |
fieldsJTree.setModel(new AttributesTreeTableModel(fieldBranches.get(0), false)); |
|
965 | 1016 |
} |
966 | 1017 |
} |
967 | 1018 |
|
Also available in: Unified diff