Revision 36036 branches/v2_0_0_prep/extensions/extWFS2/src/org/gvsig/wfs/gui/panels/WFSFilterPanel.java
WFSFilterPanel.java | ||
---|---|---|
37 | 37 |
import org.gvsig.app.gui.filter.ExpressionDataSource; |
38 | 38 |
import org.gvsig.app.gui.filter.FilterException; |
39 | 39 |
import org.gvsig.app.sqlQueryValidation.SQLQueryValidation; |
40 |
import org.gvsig.fmap.dal.DataStore; |
|
40 | 41 |
import org.gvsig.fmap.dal.feature.Feature; |
41 | 42 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
42 | 43 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
43 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
44 | 44 |
import org.gvsig.gui.beans.Messages; |
45 | 45 |
import org.gvsig.gui.beans.filterPanel.filterQueryPanel.FilterQueryJPanel; |
46 | 46 |
import org.gvsig.gui.beans.panelGroup.IPanelGroup; |
... | ... | |
112 | 112 |
private FieldsTreeTableModel fieldsTreeTableModel; |
113 | 113 |
private boolean panelAsATabForWFSLayersLoad; |
114 | 114 |
private TreePath currentPath; |
115 |
private String featureName; |
|
116 | 115 |
private Map<String, Map<String, String>> allFieldsAndValuesKnownOfCurrentLayer; // This will have all values (not repeated) known of all fields (not repeated) |
117 | 116 |
|
118 |
private FLyrVect selectedLayer = null;
|
|
117 |
private DataStore dataStore = null;
|
|
119 | 118 |
|
120 | 119 |
///// GUI METHODS //// |
121 | 120 |
|
... | ... | |
126 | 125 |
*/ |
127 | 126 |
public WFSFilterPanel() { |
128 | 127 |
super(); |
129 |
currentPath = null; |
|
130 |
featureName = null; |
|
128 |
currentPath = null; |
|
131 | 129 |
allFieldsAndValuesKnownOfCurrentLayer = new HashMap<String, Map<String, String>>(); // Initial capacity = 0 |
132 | 130 |
|
133 | 131 |
// At beginning, the JList is disabled (and its set a particular color for user could knew it) |
... | ... | |
256 | 254 |
* @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent) |
257 | 255 |
*/ |
258 | 256 |
public void valueChanged(TreeSelectionEvent e) { |
259 |
if (selectedLayer != null){
|
|
257 |
if (dataStore != null){
|
|
260 | 258 |
currentPath = e.getPath(); |
261 | 259 |
fillValuesByPath(currentPath); |
262 | 260 |
} |
... | ... | |
356 | 354 |
} |
357 | 355 |
|
358 | 356 |
/** |
359 |
* Sets the value of the inner attribute: 'panelAsATabForWFSLayersLoad' |
|
360 |
* |
|
361 |
* @param b A boolean value |
|
362 |
*/ |
|
363 |
public void setWFSFilterPanelIsAsTabForWFSLayersLoad (boolean b) { |
|
364 |
// this.panelAsATabForWFSLayersLoad = b; |
|
365 |
// |
|
366 |
// if (this.panelAsATabForWFSLayersLoad == true) { |
|
367 |
// // At beginning, the JList is disabled (and its set a particular color for user could knew it) |
|
368 |
// super.getValuesJList().setEnabled(false); |
|
369 |
// super.getValuesJList().setBackground(new Color(220, 220, 220)); // a grey color |
|
370 |
// |
|
371 |
// this.allFieldsAndValuesKnownOfCurrentLayer.clear(); |
|
372 |
// getValidateFilterExpressionJCheckBox().setSelected(true); |
|
373 |
// } |
|
374 |
// else { |
|
375 |
// // Unselect the selected path in the tree (if there was any selected) |
|
376 |
// if (this.currentPath != null) { |
|
377 |
// this.currentPath = null; |
|
378 |
// this.getFieldsJTree().removeSelectionPath(this.getFieldsJTree().getSelectionPath()); |
|
379 |
// } |
|
380 |
// |
|
381 |
// // Resets data loaded |
|
382 |
// super.getValuesJList().setEnabled(true); |
|
383 |
// super.getValuesJList().setBackground(Color.WHITE); |
|
384 |
// |
|
385 |
// this.getFieldsJTree().removeAll(); |
|
386 |
// this.getValuesJList().removeAll(); |
|
387 |
// |
|
388 |
// // Updates data associated to view with the new layer data |
|
389 |
// this.setNewDataToTable(); |
|
390 |
// |
|
391 |
// // Reads that new data |
|
392 |
// DefaultExpression data = DataLoadingFromActiveView.getDefaultExpressionDataSource(); |
|
393 |
// |
|
394 |
// if (data != null) { |
|
395 |
// setModel(data); |
|
396 |
// } |
|
397 |
// |
|
398 |
// // Loads values known of fields |
|
399 |
// this.setValuesKnownOfFields(); |
|
400 |
// } |
|
401 |
} |
|
402 |
|
|
403 |
/** |
|
404 | 357 |
* Refresh all information about fields |
405 | 358 |
* |
406 | 359 |
* @param feature a feature with fields |
407 | 360 |
*/ |
408 | 361 |
public void refresh(WFSSelectedFeature feature) { |
409 |
featureName = feature.getTitle(); |
|
410 |
setFields(feature); |
|
411 |
setFilterExpressionIntoInterface(feature.getFilter()); |
|
362 |
setFields(feature); |
|
412 | 363 |
} |
413 | 364 |
|
414 |
///// END GUI METHODS ///// |
|
415 |
|
|
416 |
///// METHODS FOR THE FILTER QUERY ///// |
|
417 |
|
|
418 | 365 |
/** |
419 | 366 |
* Gets the query that will be send to the server |
420 | 367 |
* @return SQL query (just the where part) |
... | ... | |
434 | 381 |
return null; |
435 | 382 |
} |
436 | 383 |
// Codify expression (only if the validation has been successful) |
437 |
return this.codifyExpression(writtenQuery); // Ignores the spaces at beginning and end of the chain of characters
|
|
384 |
return formatResutl(writtenQuery); // Ignores the spaces at beginning and end of the chain of characters
|
|
438 | 385 |
} |
439 | 386 |
} |
440 | 387 |
|
... | ... | |
459 | 406 |
public void removeFilterExpression() { |
460 | 407 |
getTxtExpression().setText(""); |
461 | 408 |
} |
462 |
|
|
463 |
/** |
|
464 |
* Codifies the expression to ISO ISO-8859_1 and a format that the SQL parser could validate |
|
465 |
* |
|
466 |
* @param expression The expression to be codified |
|
467 |
* |
|
468 |
* @return The expression codified |
|
469 |
*/ |
|
470 |
private String codifyExpression(String expression) { |
|
471 |
String result = new String(""); |
|
472 |
|
|
473 |
// Encode each string of the query |
|
474 |
int index = 0; |
|
475 |
int lastIndex = 0; |
|
476 |
boolean endInnerLoop; |
|
477 |
|
|
478 |
// Encodes all inner strings to the equivalent codification in ISO-8859_1 with each ' symbol converted to '' |
|
479 |
while (index != -1) { |
|
480 |
index = expression.indexOf("'", index); |
|
481 |
|
|
482 |
// Add the parts of the chain of characters that not are string |
|
483 |
if (index == -1) { |
|
484 |
result += expression.substring(lastIndex, expression.length()); |
|
485 |
} |
|
486 |
else { |
|
487 |
result += expression.substring(lastIndex, index).replaceAll(" [ ]+", " "); |
|
488 |
} |
|
489 |
|
|
490 |
lastIndex = index; |
|
491 |
endInnerLoop = false; |
|
492 |
|
|
493 |
// Tries to find each first apostrophe of each string of the query |
|
494 |
if ((index > 0) && (expression.charAt(index - 1) == ' ')) { |
|
495 |
index++; |
|
496 |
|
|
497 |
// Ignore all inner apostrophes and try to find the last of the string |
|
498 |
while (!endInnerLoop) { |
|
499 |
index = expression.indexOf("'", index); |
|
500 |
index++; |
|
501 |
|
|
502 |
// If we haven't arrived to the finish of the string |
|
503 |
if (index != expression.length()) { |
|
504 |
if ((index == -1) || (expression.charAt(index) == ' ')) { |
|
505 |
result += translateString(expression.substring(lastIndex, index)); |
|
506 |
endInnerLoop = true; |
|
507 |
} |
|
508 |
} |
|
509 |
else { |
|
510 |
result += translateString(expression.substring(lastIndex, index)); |
|
511 |
endInnerLoop = true; |
|
512 |
index = -1; // Force to finish the external loop |
|
513 |
} |
|
514 |
} |
|
515 |
lastIndex = index; |
|
516 |
} |
|
517 |
} |
|
518 |
|
|
519 |
return formatResutl(result); |
|
520 |
} |
|
521 | 409 |
|
522 | 410 |
private String formatResutl(String query) { |
523 | 411 |
if ((query == null) || (query.equals(""))){ |
... | ... | |
735 | 623 |
return operatorNamesAndSymbols.contains(text); |
736 | 624 |
} |
737 | 625 |
|
738 |
///// END METHODS FOR THE FILTER QUERY ///// |
|
739 |
|
|
740 |
///// METHODS FOR TRANSLATE DATA IN FILTER SENTENCES ///// |
|
741 |
|
|
742 | 626 |
/** |
743 |
* Encodes an string to ISO 8859_1 with each ' symbol converted to '' |
|
744 |
* |
|
745 |
* @param text An string started and finished with simple apostrophes |
|
746 |
* |
|
747 |
* @return An string started and finished with simple apostrophes |
|
748 |
*/ |
|
749 |
private String translateString(String text) { |
|
750 |
// Encode to the string to ISO 8859_1 (the URL codification) |
|
751 |
|
|
752 |
// Ignore the first and last apostrophes |
|
753 |
if (text.length() > 2) { |
|
754 |
text = text.substring(1, text.length() -1); |
|
755 |
|
|
756 |
// Change ' (%27 code) to '' for the SQL parser (before send the query) |
|
757 |
text = text.replaceAll("\\%27", "\\'\\'"); |
|
758 |
} |
|
759 |
return "'" + text + "'"; |
|
760 |
} |
|
761 |
|
|
762 |
///// END METHODS FOR TRANSLATE DATA IN FILTER SENTENCES ///// |
|
763 |
|
|
764 |
///// METHODS FOR MANIPULATE 'fields' and 'values' ///// |
|
765 |
|
|
766 |
/** |
|
767 | 627 |
* Sets the model with the fields and values of the feature selected. |
768 | 628 |
* |
769 | 629 |
* @param eds data source with the model of the feature selected |
... | ... | |
807 | 667 |
} |
808 | 668 |
|
809 | 669 |
/** |
810 |
* If there is a field selected, show its new values |
|
811 |
*/ |
|
812 |
public void updateFieldValues() { |
|
813 |
// if (currentPath != null) { |
|
814 |
// DefaultExpression data = DataLoadingFromActiveView.getDefaultExpressionDataSource(); |
|
815 |
// |
|
816 |
// if (data != null) { |
|
817 |
// setModel(data); |
|
818 |
// fillValuesByPath(currentPath); |
|
819 |
// |
|
820 |
// // Updates all tables that their data is about the changed view |
|
821 |
// this.updateTablesThatHasNewData(); |
|
822 |
// |
|
823 |
// // Adjust JScrollPanes to the the beginning |
|
824 |
// getFieldsJScrollPane().getHorizontalScrollBar().setValue(-1); |
|
825 |
// getFieldsJScrollPane().getVerticalScrollBar().setValue(-1); |
|
826 |
// |
|
827 |
// // Adjust JScrollPanes to the the beginning |
|
828 |
// getValuesJScrollPane().getHorizontalScrollBar().setValue(-1); |
|
829 |
// getValuesJScrollPane().getVerticalScrollBar().setValue(-1); |
|
830 |
// |
|
831 |
// // Adjusts valuesJList to the default position |
|
832 |
// getValuesJList().setSelectedIndex(-1); // No item selected |
|
833 |
// } |
|
834 |
// } |
|
835 |
} |
|
836 |
|
|
837 |
/** |
|
838 | 670 |
* Adds the fields of the feature. |
839 | 671 |
* |
840 | 672 |
* @param feature A Layer node with fields information |
... | ... | |
892 | 724 |
} |
893 | 725 |
|
894 | 726 |
/** |
895 |
* This method load all values known of all fields known. |
|
896 |
* (It's used when a new layer is loaded). |
|
897 |
*/ |
|
898 |
private void setValuesKnownOfFields() { |
|
899 |
// Desde el modelo se deber?a acceder a los campos y sus valores cargados |
|
900 |
// try { |
|
901 |
// for (int i = 0; i < model.getFieldCount(); i++) { |
|
902 |
// String fieldName = model.getFieldName(i); |
|
903 |
// HashMap<String, String> fieldValues = (HashMap<String, String>) allFieldsAndValuesKnownOfCurrentLayer.get(fieldName); |
|
904 |
// |
|
905 |
// if (fieldValues != null) { |
|
906 |
// for (int j = 0; j < model.getRowCount(); j++) { |
|
907 |
// Value value = model.getFieldValue(j, i); |
|
908 |
// |
|
909 |
// if (value instanceof NullValue) |
|
910 |
// continue; |
|
911 |
// |
|
912 |
// Object obj = (Object)value; |
|
913 |
// |
|
914 |
// if (obj == null) |
|
915 |
// continue; |
|
916 |
// |
|
917 |
// fieldValues.put(obj.toString(), obj.toString()); |
|
918 |
// |
|
919 |
// } |
|
920 |
// } |
|
921 |
// } |
|
922 |
// } |
|
923 |
// catch (Exception e) { |
|
924 |
// NotificationManager.addError(e); |
|
925 |
// } |
|
926 |
} |
|
927 |
|
|
928 |
/** |
|
929 | 727 |
* Resets the data of fields and their values of the current layer feature, and removes the branches of <code>fieldsJTree</code>. |
930 | 728 |
*/ |
931 | 729 |
private void resetFieldsAndValuesData() { |
... | ... | |
960 | 758 |
return; |
961 | 759 |
} |
962 | 760 |
|
963 |
FeatureStore featureStore = (FeatureStore)selectedLayer.getDataStore();
|
|
761 |
FeatureStore featureStore = (FeatureStore)dataStore;
|
|
964 | 762 |
FeatureAttributeDescriptor featureAttributeDescriptor = featureStore.getDefaultFeatureType().getAttributeDescriptor(wfsFeatureField.getName()); |
965 | 763 |
|
966 | 764 |
if (featureAttributeDescriptor == null){ |
... | ... | |
984 | 782 |
} |
985 | 783 |
} |
986 | 784 |
|
987 |
this.getValuesJList().setEnabled(valuesListModel.getSize() > 0); |
|
785 |
this.getValuesJList().setEnabled(valuesListModel.getSize() > 0);
|
|
988 | 786 |
|
989 |
|
|
990 |
// // Find the selected field and try to obtein values related |
|
991 |
// for (int i = 0; i < model.getFieldCount(); i++) { |
|
992 |
// String name = model.getFieldName(i); |
|
993 |
// |
|
994 |
// // If we find the field (this means that are loaded its values and we can obtein them) |
|
995 |
// if (name.equals(element.getName())) { |
|
996 |
// for (int j = 0; j < model.getRowCount(); j++) { |
|
997 |
// Value value = model.getFieldValue(j, i); |
|
998 |
// |
|
999 |
// if (value instanceof NullValue) |
|
1000 |
// continue; |
|
1001 |
// |
|
1002 |
// if (!conjunto.contains(value)) { |
|
1003 |
// conjunto.add(value); |
|
1004 |
// } |
|
1005 |
// } |
|
1006 |
// |
|
1007 |
// break; |
|
1008 |
// } |
|
1009 |
// } |
|
1010 |
// } else { |
|
1011 |
// //create a vector with the parent names from the leaf until the root |
|
1012 |
// XMLElement parent = element.getParentElement(); |
|
1013 |
// Vector<String> parentNames = new Vector<String>(); |
|
1014 |
// parentNames.add(element.getName()); |
|
1015 |
// while (parent != null){ |
|
1016 |
// parentNames.add(parent.getName()); |
|
1017 |
// parent = parent.getParentElement(); |
|
1018 |
// } |
|
1019 |
// |
|
1020 |
// //The field name (in the gvSIG table) is the second field name |
|
1021 |
// String fieldName = parentNames.get(parentNames.size()-2); |
|
1022 |
// |
|
1023 |
// for (int i = 0; i < model.getFieldCount(); i++) { |
|
1024 |
// String name = model.getFieldName(i); |
|
1025 |
// |
|
1026 |
// // If we find the field (this means that are loaded its values and we can obtein them) |
|
1027 |
// if (name.equals(fieldName)) { |
|
1028 |
// for (int j = 0; j < model.getRowCount(); j++) { |
|
1029 |
// Value value = model.getFieldValue(j, i); |
|
1030 |
// |
|
1031 |
// if (value instanceof NullValue) |
|
1032 |
// continue; |
|
1033 |
// |
|
1034 |
// if (value instanceof ComplexValue){ |
|
1035 |
// for (int k=parentNames.size()-3 ; k >= 0 ; k--){ |
|
1036 |
// ComplexValue complex = (ComplexValue)value; |
|
1037 |
// Value childValue = (Value)complex.get(parentNames.get(k)); |
|
1038 |
// if (k == 0) { |
|
1039 |
// if (!conjunto.contains(childValue)) { |
|
1040 |
// conjunto.add(childValue); |
|
1041 |
// } |
|
1042 |
// } else { |
|
1043 |
// value = childValue; |
|
1044 |
// } |
|
1045 |
// } |
|
1046 |
// } |
|
1047 |
// } |
|
1048 |
// |
|
1049 |
// break; |
|
1050 |
// } |
|
1051 |
// } |
|
1052 |
// } |
|
1053 |
// break; |
|
1054 |
// case IXMLType.COMPLEX: |
|
1055 |
// break; |
|
1056 |
// default: |
|
1057 |
// // Do Nothing |
|
1058 |
// } |
|
1059 |
// |
|
1060 |
// // Add the values to the model of the graphic list |
|
1061 |
// Iterator<Object> it = conjunto.iterator(); |
|
1062 |
// Object[] objects = currentPath.getPath(); |
|
1063 |
// |
|
1064 |
// if (objects.length == 0) |
|
1065 |
// return; |
|
1066 |
// |
|
1067 |
// String selectedField = ((XMLElement)objects[objects.length-1]).getName(); // Gets the selected field |
|
1068 |
// |
|
1069 |
// if (selectedField != null) { // If there is a selected field |
|
1070 |
// Map<String, String> fieldValues = (HashMap<String, String>)allFieldsAndValuesKnownOfCurrentLayer.get(selectedField); // Gets values stored associated to this field |
|
1071 |
// JLabel currentValueLabel = null; |
|
1072 |
// |
|
1073 |
// // If the field doesn't exits -> create a new Map with its values |
|
1074 |
// if (fieldValues == null) { |
|
1075 |
// fieldValues = new HashMap<String, String>(); |
|
1076 |
// allFieldsAndValuesKnownOfCurrentLayer.put(selectedField, fieldValues); |
|
1077 |
// |
|
1078 |
// while (it.hasNext()) { |
|
1079 |
// // A label with text with yellow background color for values that are loaded in the layer |
|
1080 |
// currentValueLabel = new JLabelAsCellValueLoaded(); |
|
1081 |
// |
|
1082 |
// currentValueLabel.setText(it.next().toString()); |
|
1083 |
// |
|
1084 |
// if (currentValueLabel.getText().compareTo("") != 0) { |
|
1085 |
// fieldValues.put(currentValueLabel.getText(), currentValueLabel.getText()); |
|
1086 |
// |
|
1087 |
// // All values loaded in this loop must be at beginning of the list (and in a differenciated color) |
|
1088 |
// if ( ! valuesListModel.contains(currentValueLabel) ) |
|
1089 |
// valuesListModel.addElement(currentValueLabel); |
|
1090 |
// } |
|
1091 |
// } |
|
1092 |
// } |
|
1093 |
// else { // Else -> Adds the new ones, and changes element labels that have changed (before were loaded and now not, or before weren't loaded but now yes) |
|
1094 |
// |
|
1095 |
// // Changes element labels that have changed (before were loaded and now not, or before weren't loaded but now yes) |
|
1096 |
// ((DefaultListModelForJLabelAsCell)valuesListModel).setAllElementsToNotLoaded(); |
|
1097 |
// |
|
1098 |
// // For each current value associated to de current selected field -> if its loaded -> put it at beginning of the list and change to 'JLabelLoadedValue' |
|
1099 |
// while (it.hasNext()) { |
|
1100 |
// String text = it.next().toString(); |
|
1101 |
// int elementPosition = ((DefaultListModelForJLabelAsCell)valuesListModel).getIndexOfJLabelText(text); |
|
1102 |
// |
|
1103 |
// if (elementPosition == -1) // If it must be added |
|
1104 |
// valuesListModel.addElement(new JLabelAsCellValueLoaded(text)); |
|
1105 |
// else |
|
1106 |
// ((DefaultListModelForJLabelAsCell)valuesListModel).changeElementThatHasTextToJLabelLoadedValue(text); // Change to 'JLabelLoadedValue' |
|
1107 |
// } |
|
1108 |
// } |
|
1109 |
// |
|
1110 |
// // Load the rest of the values associated to the current selected field |
|
1111 |
// if (fieldValues != null) { |
|
1112 |
// // A label with text with yellow background color for values that are loaded in the layer |
|
1113 |
// currentValueLabel = new JLabelAsCellValueNotLoaded(); |
|
1114 |
// |
|
1115 |
// Set<String> values = fieldValues.keySet(); |
|
1116 |
// |
|
1117 |
// for (String name : values) { |
|
1118 |
// if ( ! ((DefaultListModelForJLabelAsCell)valuesListModel).containsJLabelText(name) ) |
|
1119 |
// valuesListModel.addElement(new JLabelAsCellValueNotLoaded(name)); |
|
1120 |
// } |
|
1121 |
// } |
|
1122 |
// } |
|
1123 |
|
|
1124 | 787 |
} catch (Exception e) { |
1125 | 788 |
NotificationManager.addError(e); |
1126 | 789 |
} |
1127 | 790 |
} |
1128 | 791 |
|
1129 |
///// END METHODS FOR MANIPULATE 'fields' and 'values' ///// |
|
1130 |
|
|
1131 |
///// METHOS FOR 'allFieldsAndValuesKnownOfCurrentLayer' ///// |
|
1132 |
|
|
1133 | 792 |
/** |
1134 | 793 |
* Sets all fields and values known about the current layer |
1135 | 794 |
* |
... | ... | |
1151 | 810 |
return allFieldsAndValuesKnownOfCurrentLayer; |
1152 | 811 |
} |
1153 | 812 |
|
1154 |
///// METHOS FOR 'allFieldsAndValuesKnownOfCurrentLayer' ///// |
|
1155 |
|
|
1156 |
///// UPDATE TABLES DATA ///// |
|
1157 |
|
|
1158 | 813 |
/** |
1159 |
* Updates all tables that their data is about the changed view |
|
1160 |
*/ |
|
1161 |
private void updateTablesThatHasNewData() { |
|
1162 |
// boolean oneTimeNewDataToTableAdded = false; |
|
1163 |
// |
|
1164 |
// IWindow[] activeNoModalWindows = PluginServices.getMDIManager().getAllWindows(); |
|
1165 |
// |
|
1166 |
// for (int i = 0; i < activeNoModalWindows.length; i++) { |
|
1167 |
// IWindow window = activeNoModalWindows[i]; |
|
1168 |
// if (window instanceof Table) { |
|
1169 |
// Table table = (Table) window; |
|
1170 |
// |
|
1171 |
// int pos1 = featureName.indexOf(':'); |
|
1172 |
// |
|
1173 |
// if ((pos1 >= 0) && (pos1 < featureName.length())) |
|
1174 |
// featureName = featureName.substring(pos1 +1, featureName.length()); |
|
1175 |
// |
|
1176 |
// String featureOfTable = table.getModel().getName(); |
|
1177 |
// int pos2 = featureOfTable.indexOf(':'); |
|
1178 |
// |
|
1179 |
// if ((pos2 >= 0) && (pos2 < featureName.length())) |
|
1180 |
// featureOfTable = featureOfTable.substring(pos2 +1, featureOfTable.length()); |
|
1181 |
// |
|
1182 |
// if (featureName.trim().compareTo(featureOfTable.trim()) == 0) { |
|
1183 |
// // Only add the new data associated to the table one time |
|
1184 |
// if (oneTimeNewDataToTableAdded == false) { |
|
1185 |
// setNewDataToTable(); |
|
1186 |
// oneTimeNewDataToTableAdded = true; |
|
1187 |
// } |
|
1188 |
// |
|
1189 |
// // Refresh the table with the new data |
|
1190 |
// table.invalidate(); |
|
1191 |
// table.refresh(); |
|
1192 |
// } |
|
1193 |
// } |
|
1194 |
// } |
|
1195 |
} |
|
1196 |
|
|
1197 |
/** |
|
1198 |
* This method is a modification of the "execute" method from the "ShowTable" class |
|
1199 |
* |
|
1200 |
* @see org.gvsig.app.extension.ShowTable#execute(String) |
|
1201 |
*/ |
|
1202 |
private void setNewDataToTable() { |
|
1203 |
// try { |
|
1204 |
// if (getPanelGroup().getReference() == null) |
|
1205 |
// return; |
|
1206 |
// |
|
1207 |
// FLayer activeLayer = (FLayer) getPanelGroup().getReference(); |
|
1208 |
// AlphanumericData co = (AlphanumericData) activeLayer; |
|
1209 |
// |
|
1210 |
// ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
|
1211 |
// ProjectTable projectTable = ext.getProject().getTable(co); |
|
1212 |
// |
|
1213 |
// EditableAdapter ea = null; |
|
1214 |
// ReadableVectorial rv = ((FLyrVect)activeLayer).getSource(); |
|
1215 |
// |
|
1216 |
// if (rv instanceof VectorialEditableAdapter) { |
|
1217 |
// ea = (EditableAdapter)((FLyrVect)activeLayer).getSource(); |
|
1218 |
// } else { |
|
1219 |
// ea = new EditableAdapter(); |
|
1220 |
// SelectableDataSource sds = ((FLyrVect)activeLayer).getRecordset(); |
|
1221 |
// ea.setOriginalDataSource(sds); |
|
1222 |
// } |
|
1223 |
// |
|
1224 |
// if (projectTable == null) { |
|
1225 |
// projectTable = ProjectFactory.createTable(PluginServices.getText(this, "Tabla_de_Atributos") + ": " + activeLayer.getName(), ea); |
|
1226 |
// projectTable.setProjectDocumentFactory(new ProjectTableFactory()); |
|
1227 |
// projectTable.setAssociatedTable(co); |
|
1228 |
// ext.getProject().addDocument(projectTable); |
|
1229 |
// } |
|
1230 |
// |
|
1231 |
// projectTable.setModel(ea); |
|
1232 |
// } catch (ReadDriverException e) { |
|
1233 |
// NotificationManager.addError(PluginServices.getText(this,"No_se_pudo_obtener_la_tabla_de_la_capa"), e); |
|
1234 |
// } |
|
1235 |
} |
|
1236 |
|
|
1237 |
/** |
|
1238 | 814 |
* @param layer |
1239 | 815 |
*/ |
1240 |
public void setSelectedLayer(FLyrVect layer) {
|
|
1241 |
this.selectedLayer = layer;
|
|
816 |
public void setDataStore(DataStore dataStore) {
|
|
817 |
this.dataStore = dataStore;
|
|
1242 | 818 |
|
1243 |
} |
|
1244 |
|
|
1245 |
// /** OLD VERSION |
|
1246 |
// * This method is a modification of the "execute" method from the "ShowTable" class |
|
1247 |
// * |
|
1248 |
// * @see com.iver.cit.gvsig.ShowTable#execute(String) |
|
1249 |
// */ |
|
1250 |
// private void setNewDataToTable() { |
|
1251 |
// BaseView vista = (BaseView) PluginServices.getMDIManager().getActiveWindow(); |
|
1252 |
// FLayer[] actives = vista.getModel().getMapContext().getLayers().getActives(); |
|
1253 |
// |
|
1254 |
// try { |
|
1255 |
// for (int i = 0; i < actives.length; i++) { |
|
1256 |
// if (actives[i] instanceof AlphanumericData) { |
|
1257 |
// AlphanumericData co = (AlphanumericData) actives[i]; |
|
1258 |
// |
|
1259 |
// ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
|
1260 |
// |
|
1261 |
// ProjectTable projectTable = ext.getProject().getTable(co); |
|
1262 |
// EditableAdapter ea=null; |
|
1263 |
// ReadableVectorial rv=((FLyrVect)actives[i]).getSource(); |
|
1264 |
// if (rv instanceof VectorialEditableAdapter){ |
|
1265 |
// ea = (EditableAdapter)((FLyrVect)actives[i]).getSource(); |
|
1266 |
// } else { |
|
1267 |
// ea = new EditableAdapter(); |
|
1268 |
// SelectableDataSource sds=((FLyrVect)actives[i]).getRecordset(); |
|
1269 |
// ea.setOriginalDataSource(sds); |
|
1270 |
// } |
|
1271 |
// |
|
1272 |
// if (projectTable == null) { |
|
1273 |
// projectTable = ProjectFactory.createTable(PluginServices.getText(this, "Tabla_de_Atributos") + ": " + actives[i].getName(), ea); |
|
1274 |
// projectTable.setProjectDocumentFactory(new ProjectTableFactory()); |
|
1275 |
// projectTable.setAssociatedTable(co); |
|
1276 |
// ext.getProject().addDocument(projectTable); |
|
1277 |
// } |
|
1278 |
// |
|
1279 |
// projectTable.setModel(ea); |
|
1280 |
// } |
|
1281 |
// } |
|
1282 |
// } catch (ReadDriverException e) { |
|
1283 |
// NotificationManager.addError(PluginServices.getText(this,"No_se_pudo_obtener_la_tabla_de_la_capa"), e); |
|
1284 |
// } |
|
1285 |
// } |
|
1286 |
|
|
1287 |
///// END UPDATE TABLES DATA ///// |
|
819 |
} |
|
1288 | 820 |
} |
Also available in: Unified diff