Revision 45222 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/searchpanel/DefaultSearchPanel.java
DefaultSearchPanel.java | ||
---|---|---|
477 | 477 |
|
478 | 478 |
this.conditionPanels.add( |
479 | 479 |
new SearchConditionPanelSimplified( |
480 |
parameters, |
|
480 | 481 |
store, |
481 | 482 |
btnAddAccumulatedFilter, |
482 | 483 |
btnRemoveAccumulatedFilter, |
... | ... | |
683 | 684 |
lblMsg.setText(ToolsLocator.getI18nManager().getTranslation("_Searching")+"..."); |
684 | 685 |
setEnabled(false); |
685 | 686 |
Thread th = new Thread(() -> { |
687 |
try { |
|
686 | 688 |
FeatureQuery myQuery; |
687 | 689 |
SearchParameters searchParams; |
690 |
List<String> resultColumnNames; |
|
688 | 691 |
try { |
689 | 692 |
searchParams = this.fetch(this.parameters.getCopy()); // esto lo actualiza a la ultima // decidir si se devuelve clonado |
693 |
resultColumnNames = searchParams.getResultColumnNames(); |
|
690 | 694 |
Date date = Calendar.getInstance().getTime(); |
691 | 695 |
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); |
692 | 696 |
String strDate = dateFormat.format(date); |
693 | 697 |
searchParams.setName("Params: " + strDate); |
694 | 698 |
} catch (Exception ex) { |
695 | 699 |
LOGGER.warn("Not able to create search parameters.", ex); |
700 |
resetTable(); |
|
696 | 701 |
return; |
697 | 702 |
} |
698 | 703 |
|
... | ... | |
707 | 712 |
// al modelo le pasamos el ftype de esas features |
708 | 713 |
SimpleFeaturesTableModel tableModel = new SimpleFeaturesTableModel( |
709 | 714 |
ftype, |
710 |
searchParams.getResultColumnNames(),
|
|
715 |
resultColumnNames,
|
|
711 | 716 |
features |
712 | 717 |
); |
713 | 718 |
model.setValue(tableModel); |
714 | 719 |
rowCount.setValue(tableModel.getRowCount()); |
715 | 720 |
} catch (Exception ex) { |
716 | 721 |
LOGGER.warn("Search not able to be executed. Can't get features or create table model", ex); |
722 |
resetTable(); |
|
717 | 723 |
} finally { |
718 | 724 |
SwingUtilities.invokeLater(() -> { |
719 | 725 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
... | ... | |
725 | 731 |
((SimpleFeaturesTableModel)oldmodel).dispose(); |
726 | 732 |
} |
727 | 733 |
if( m.hasErrors() ) { |
728 |
lblMsg.setText("_Errors_occurred_during_search");
|
|
734 |
lblMsg.setText(i18n.getTranslation("_Errors_occurred_during_search"));
|
|
729 | 735 |
} else { |
730 | 736 |
lblMsg.setText(String.format("%d " + i18n.getTranslation("_elements"), rowCount.getValue())); |
731 | 737 |
} |
... | ... | |
735 | 741 |
this.history.add(searchParams); |
736 | 742 |
} |
737 | 743 |
} |
744 |
} catch (Exception ex) { |
|
745 |
LOGGER.warn("Search panel has errors during the search", ex); |
|
746 |
resetTable(); |
|
747 |
} finally { |
|
748 |
SwingUtilities.invokeLater(() -> { |
|
749 |
setEnabled(true); |
|
750 |
}); |
|
751 |
} |
|
738 | 752 |
}); |
739 | 753 |
th.start(); |
740 | 754 |
} |
755 |
|
|
756 |
private void resetTable() { |
|
757 |
if(!SwingUtilities.isEventDispatchThread()) { |
|
758 |
SwingUtilities.invokeLater(this::resetTable); |
|
759 |
return; |
|
760 |
} |
|
761 |
List<String> resultColumnNames = null; |
|
762 |
try { |
|
763 |
resultColumnNames = this.parameters.getResultColumnNames(); |
|
764 |
} catch(Exception ex) { |
|
765 |
|
|
766 |
} |
|
767 |
FeatureType ftype = this.store.getDefaultFeatureTypeQuietly(); |
|
768 |
SimpleFeaturesTableModel emptyTableModel = new SimpleFeaturesTableModel( |
|
769 |
ftype, |
|
770 |
resultColumnNames, |
|
771 |
null |
|
772 |
); |
|
773 |
this.tblResults.setModel(emptyTableModel); |
|
774 |
|
|
775 |
} |
|
741 | 776 |
|
742 | 777 |
public void setResultColumnNames(List<String> names) { |
743 | 778 |
this.parameters.getResultColumnNames().clear(); |
... | ... | |
910 | 945 |
if (tags.has(DAL_USE_LABELS)) { |
911 | 946 |
theUseLabels = tags.getInt(DAL_USE_LABELS, USE_LABELS_NO); |
912 | 947 |
} else { |
913 |
tags = attrdesc.getFeatureType().getTags(); |
|
914 |
theUseLabels = tags.getInt(DAL_USE_LABELS, USE_LABELS_NO); |
|
948 |
if (attrdesc.getFeatureType()!=null) { |
|
949 |
tags = attrdesc.getFeatureType().getTags(); |
|
950 |
theUseLabels = tags.getInt(DAL_USE_LABELS, USE_LABELS_NO); |
|
951 |
} else { |
|
952 |
theUseLabels = USE_LABELS_NO; |
|
953 |
} |
|
915 | 954 |
} |
916 | 955 |
} else { |
917 | 956 |
theUseLabels = useLabels; |
Also available in: Unified diff