Revision 45280 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 | ||
---|---|---|
578 | 578 |
} |
579 | 579 |
clear(); |
580 | 580 |
put(searchParams); |
581 |
Thread th = new Thread(() -> { |
|
582 |
doSearch(searchParams); |
|
583 |
}); |
|
584 |
th.start(); |
|
581 | 585 |
break; |
582 | 586 |
} |
583 | 587 |
|
... | ... | |
603 | 607 |
if (this.bookmarks.hasBookmark(this.store.getName())) { |
604 | 608 |
Bookmark<DefaultSearchParameters> initBookmark = this.bookmarks.get(this.store.getName()); |
605 | 609 |
DefaultSearchParameters initSearchParams = initBookmark.getValue().getCopy(); |
606 |
clear(); |
|
607 | 610 |
put(initSearchParams); |
611 |
Thread th = new Thread(() -> { |
|
612 |
doSearch(initSearchParams); |
|
613 |
}); |
|
614 |
th.start(); |
|
615 |
return; |
|
608 | 616 |
} |
609 | 617 |
search(); |
610 | 618 |
} |
... | ... | |
696 | 704 |
boolean valid = panel.isValid(message); |
697 | 705 |
return valid; |
698 | 706 |
} |
699 |
|
|
707 |
|
|
708 |
public void search(SearchParameters params) { |
|
709 |
|
|
710 |
} |
|
711 |
|
|
700 | 712 |
@Override |
701 | 713 |
public void search() { |
702 |
final MutableObject model = new MutableObject(null); |
|
703 |
|
|
704 | 714 |
StringBuilder message = new StringBuilder(); |
705 | 715 |
if (!this.isValid(message)) { |
706 | 716 |
ThreadSafeDialogsManager dialogManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
... | ... | |
712 | 722 |
return; |
713 | 723 |
} |
714 | 724 |
lblMsg.setText(ToolsLocator.getI18nManager().getTranslation("_Searching")+"..."); |
715 |
SwingUtilities.invokeLater(() -> { |
|
716 |
setEnabled(false); |
|
717 |
}); |
|
725 |
setEnabled(false); |
|
718 | 726 |
Thread th = new Thread(() -> { |
719 | 727 |
try { |
720 |
FeatureQuery myQuery; |
|
728 |
|
|
721 | 729 |
SearchParameters searchParams; |
722 |
List<String> resultColumnNames; |
|
723 | 730 |
try { |
724 | 731 |
searchParams = this.fetch(this.parameters.getCopy()); // esto lo actualiza a la ultima // decidir si se devuelve clonado |
725 |
resultColumnNames = searchParams.getResultColumnNames(); |
|
732 |
|
|
726 | 733 |
Date date = Calendar.getInstance().getTime(); |
727 | 734 |
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); |
728 | 735 |
String strDate = dateFormat.format(date); |
... | ... | |
733 | 740 |
resetTable(); |
734 | 741 |
return; |
735 | 742 |
} |
743 |
doSearch(searchParams); |
|
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 |
} |
|
736 | 752 |
|
753 |
}); |
|
754 |
th.start(); |
|
755 |
} |
|
756 |
|
|
757 |
private void doSearch(SearchParameters searchParams) { |
|
758 |
final MutableObject model = new MutableObject(null); |
|
737 | 759 |
final MutableLong rowCount=new MutableLong(); |
738 | 760 |
try { |
739 | 761 |
final List<Feature> features; |
740 |
|
|
741 |
myQuery = this.getQuery().getCopy(); |
|
742 |
features = store.getFeatures(myQuery, 20); |
|
762 |
FeatureQuery myQuery; |
|
763 |
// myQuery = this.getQuery().getCopy(); |
|
764 |
List<String> resultColumnNames = searchParams.getResultColumnNames(); |
|
765 |
myQuery = searchParams.getQuery(); |
|
766 |
features = store.getFeatures(myQuery, 50); |
|
743 | 767 |
FacadeOfAFeaturePagingHelper facade = (FacadeOfAFeaturePagingHelper) features; |
744 | 768 |
FeatureType ftype = facade.getFeaturePagingHelper().getFeatureSet().getDefaultFeatureType(); |
745 |
// al modelo le pasamos el ftype de esas features
|
|
746 |
SimpleFeaturesTableModel tableModel = new SimpleFeaturesTableModel(
|
|
747 |
ftype,
|
|
748 |
resultColumnNames,
|
|
749 |
features
|
|
750 |
);
|
|
769 |
// al modelo le pasamos el ftype de esas features |
|
770 |
SimpleFeaturesTableModel tableModel = new SimpleFeaturesTableModel( |
|
771 |
ftype, |
|
772 |
resultColumnNames, |
|
773 |
features |
|
774 |
); |
|
751 | 775 |
model.setValue(tableModel); |
752 | 776 |
rowCount.setValue(tableModel.getRowCount()); |
753 | 777 |
} catch (Exception ex) { |
754 | 778 |
LOGGER.warn("Search not able to be executed. Can't get features or create table model", ex); |
755 |
lblMsg.setText(ToolsLocator.getI18nManager().getTranslation("_Errors_getting_new_feature_set")+"...");
|
|
779 |
lblMsg.setText(ToolsLocator.getI18nManager().getTranslation("_Errors_getting_new_feature_set") + "...");
|
|
756 | 780 |
resetTable(); |
757 | 781 |
} finally { |
758 | 782 |
SwingUtilities.invokeLater(() -> { |
... | ... | |
774 | 798 |
this.history.add(searchParams); |
775 | 799 |
} |
776 | 800 |
} catch (Exception ex) { |
801 |
LOGGER.warn(" Errors occurred during search getting old model", ex); |
|
777 | 802 |
lblMsg.setText(i18n.getTranslation("_Errors_occurred_during_search")); |
778 | 803 |
} finally { |
779 | 804 |
setEnabled(true); |
780 | 805 |
} |
781 | 806 |
}); |
782 | 807 |
} |
783 |
} catch (Exception ex) { |
|
784 |
LOGGER.warn("Search panel has errors during the search", ex); |
|
785 |
resetTable(); |
|
786 |
} finally { |
|
787 |
SwingUtilities.invokeLater(() -> { |
|
788 |
setEnabled(true); |
|
789 |
}); |
|
790 |
} |
|
791 |
}); |
|
792 |
th.start(); |
|
793 |
} |
|
808 |
} |
|
809 |
|
|
810 |
|
|
794 | 811 |
|
795 | 812 |
private void resetTable() { |
796 | 813 |
if(!SwingUtilities.isEventDispatchThread()) { |
... | ... | |
1109 | 1126 |
|
1110 | 1127 |
@Override |
1111 | 1128 |
public void put(SearchParameters inParams) { |
1129 |
this.parameters = (DefaultSearchParameters) inParams; |
|
1112 | 1130 |
for (SearchConditionPanel conditionPanel : this.conditionPanels) { |
1113 | 1131 |
try { |
1114 | 1132 |
conditionPanel.put(inParams); |
... | ... | |
1117 | 1135 |
} |
1118 | 1136 |
} |
1119 | 1137 |
this.tabSearchMode.setSelectedIndex(inParams.getSearchMode()); |
1120 |
this.parameters = (DefaultSearchParameters) inParams;
|
|
1138 |
// this.resetTable();
|
|
1121 | 1139 |
|
1122 | 1140 |
} |
1123 | 1141 |
|
Also available in: Unified diff