Revision 46505 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 | ||
---|---|---|
137 | 137 |
private final PropertiesSupportHelper propertiesHelper; |
138 | 138 |
private TaskStatusController taskStatusController; |
139 | 139 |
private boolean automaticallySearch; |
140 |
private boolean initialized; |
|
140 | 141 |
|
141 | 142 |
public static class UseLabelsYesAction extends AbstractAction { |
142 | 143 |
|
... | ... | |
523 | 524 |
} |
524 | 525 |
this.bookmarks = ToolsLocator.getBookmarksAndHistoryManager().getBookmarksGroup(BOOKMARKSANDHISTORY_NAME); |
525 | 526 |
this.history = ToolsLocator.getBookmarksAndHistoryManager().getHistoryGroup(BOOKMARKSANDHISTORY_NAME); |
527 |
this.initComponents0(); |
|
528 |
this.initialized = false; |
|
526 | 529 |
} |
527 | 530 |
|
528 | 531 |
@Override |
... | ... | |
538 | 541 |
|
539 | 542 |
@Override |
540 | 543 |
public JComponent asJComponent() { |
541 |
if (this.conditionPanels == null) { |
|
542 |
this.initComponents(); |
|
544 |
if (!this.initialized) { //this.conditionPanels == null) {
|
|
545 |
this.initComponents1();
|
|
543 | 546 |
} |
544 | 547 |
return this; |
545 | 548 |
} |
... | ... | |
600 | 603 |
return this.acctionListeners.hasActionListeners(); |
601 | 604 |
} |
602 | 605 |
|
603 |
private void initComponents() { |
|
606 |
private void initComponents0() {
|
|
604 | 607 |
this.conditionPanels = new ArrayList<>(); |
608 |
this.taskStatusController = ToolsSwingLocator.getTaskStatusSwingManager().createTaskStatusController( |
|
609 |
this.lblStatusTitle, |
|
610 |
this.lblMsg, |
|
611 |
this.pgbStatus); |
|
612 |
} |
|
605 | 613 |
|
614 |
private void initComponents1() { |
|
615 |
|
|
606 | 616 |
ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager(); |
607 | 617 |
swingManager.translate(this.tabSearchMode); |
608 | 618 |
swingManager.translate(this.tabResults); |
... | ... | |
619 | 629 |
this.pnlCfgActions.setLayout(new BorderLayout(0, 0)); |
620 | 630 |
this.pnlCfgActions.add(configurableActions, BorderLayout.CENTER); |
621 | 631 |
|
622 |
this.taskStatusController = ToolsSwingLocator.getTaskStatusSwingManager().createTaskStatusController( |
|
623 |
this.lblStatusTitle, |
|
624 |
this.lblMsg, |
|
625 |
this.pgbStatus); |
|
626 | 632 |
this.pgbStatus.setVisible(false); |
627 | 633 |
|
628 | 634 |
this.conditionPanels.add( |
... | ... | |
790 | 796 |
this.btnSearchPostProcess.setVisible(false); |
791 | 797 |
} |
792 | 798 |
|
799 |
this.initialized = true; |
|
800 |
|
|
793 | 801 |
//this.tblResults.add |
794 | 802 |
if (this.automaticallySearch){ |
795 | 803 |
if (this.bookmarks.hasBookmark(this.store.getName())) { |
... | ... | |
810 | 818 |
DefaultSearchParameters params; |
811 | 819 |
try { |
812 | 820 |
params = searchParams.getCopy(); |
813 |
params.fix(this.getFeatureType()); |
|
814 |
// TODO: habria que comprobar y preguntar al usuario de forma |
|
815 |
// similar a lo que se hace en DefaultFeatureQueryCalculatedColumnsPanel.doRemove |
|
821 |
FeatureType featType = this.getFeatureType(); |
|
822 |
StringBuilder errMessage = new StringBuilder(); |
|
823 |
boolean onlyEssentials = false; |
|
824 |
boolean isValid = params.isValid(featType, errMessage); |
|
825 |
if(!isValid){ |
|
826 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
827 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
828 |
int n = dialogs.confirmDialog( |
|
829 |
i18n.getTranslation("_The_validation_of_the_search_parameters_has_returned_the_following_errors")+":\n\n"+errMessage.toString()+"\n"+i18n.getTranslation("_You_want_the_application_to_try_to_resolve_them_before_launching_the_query"), |
|
830 |
i18n.getTranslation("_Validation_of_search_parameters"), |
|
831 |
JOptionPane.YES_NO_OPTION, |
|
832 |
JOptionPane.WARNING_MESSAGE, |
|
833 |
"_Fix_search_parameters" |
|
834 |
); |
|
835 |
if( n != JOptionPane.YES_OPTION ) { |
|
836 |
onlyEssentials = true; |
|
837 |
} |
|
838 |
|
|
839 |
} |
|
840 |
params.fix(featType, onlyEssentials); |
|
816 | 841 |
} catch (Exception ex) { |
817 | 842 |
LOGGER.warn("Not been able to clone export parameters", ex); |
818 | 843 |
return; |
... | ... | |
865 | 890 |
return; |
866 | 891 |
} |
867 | 892 |
|
868 |
if (this.conditionPanels == null) { |
|
869 |
this.initComponents(); |
|
893 |
if (!this.initialized) { //this.conditionPanels == null) {
|
|
894 |
this.initComponents1();
|
|
870 | 895 |
} |
871 | 896 |
for (SearchConditionPanel conditionPanel : conditionPanels) { |
872 | 897 |
conditionPanel.setEnabled(enabled); |
... | ... | |
884 | 909 |
@Override |
885 | 910 |
public void clear() { |
886 | 911 |
this.taskStatusController.setTitle(""); |
887 |
if (this.conditionPanels == null) { |
|
912 |
if (!this.initialized) { //this.conditionPanels == null) {
|
|
888 | 913 |
return; |
889 | 914 |
} |
890 | 915 |
for (SearchConditionPanel conditionPanel : conditionPanels) { |
... | ... | |
985 | 1010 |
try { |
986 | 1011 |
status.setTitle(ToolsLocator.getI18nManager().getTranslation("_Processing_search")); |
987 | 1012 |
SwingUtilities.invokeLater(() -> { |
1013 |
if(this.initialized){ |
|
988 | 1014 |
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
1015 |
} |
|
989 | 1016 |
}); |
990 | 1017 |
final List<Feature> features; |
991 | 1018 |
FeatureQuery myQuery; |
992 | 1019 |
// myQuery = this.getQuery().getCopy(); |
993 |
this.tabResults.setSelectedIndex(0); |
|
994 | 1020 |
List<String> resultColumnNames = searchParams.getResultColumnNames(); |
995 | 1021 |
myQuery = searchParams.getQuery().getCopy(); |
996 | 1022 |
features = store.getFeatures(myQuery, 50); |
... | ... | |
1013 | 1039 |
return STATUS_ERROR1; |
1014 | 1040 |
} finally { |
1015 | 1041 |
SwingUtilities.invokeLater(() -> { |
1042 |
if(this.initialized){ |
|
1016 | 1043 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
1017 | 1044 |
try { |
1045 |
this.tabResults.setSelectedIndex(0); |
|
1018 | 1046 |
TableModel oldmodel = tblResults.getModel(); |
1019 | 1047 |
tblResults.setModel(resultModel); |
1020 | 1048 |
resultModel.setCellRenderers(tblResults, getCustomRenderers(searchParams)); |
... | ... | |
1037 | 1065 |
status.terminate(); |
1038 | 1066 |
this.setCursor(savedCursor); |
1039 | 1067 |
} |
1068 |
} |
|
1040 | 1069 |
}); |
1041 | 1070 |
} |
1042 | 1071 |
return STATUS_OK; |
... | ... | |
1060 | 1089 |
|
1061 | 1090 |
private void resetTable() { |
1062 | 1091 |
if (!SwingUtilities.isEventDispatchThread()) { |
1063 |
SwingUtilities.invokeLater(this::resetTable); |
|
1092 |
SwingUtilities.invokeLater(() -> { |
|
1093 |
if(this.initialized){ |
|
1094 |
resetTable(); |
|
1095 |
} |
|
1096 |
}); |
|
1064 | 1097 |
return; |
1065 | 1098 |
} |
1066 | 1099 |
List<String> resultColumnNames = null; |
... | ... | |
1101 | 1134 |
@Override |
1102 | 1135 |
public boolean setFilter(Expression filter) { |
1103 | 1136 |
try { |
1104 |
if (this.conditionPanels == null) {
|
|
1105 |
this.initComponents(); |
|
1137 |
if (!this.initialized) { //this.conditionPanels == null) {
|
|
1138 |
this.initComponents1();
|
|
1106 | 1139 |
} |
1107 | 1140 |
if (ExpressionUtils.isPhraseEmpty(filter)) { |
1108 | 1141 |
this.clear(); |
... | ... | |
1148 | 1181 |
|
1149 | 1182 |
@Override |
1150 | 1183 |
public Expression getFilterForSelectedFeature() { |
1151 |
if (this.conditionPanels == null) { |
|
1184 |
if (!this.initialized) { //this.conditionPanels == null) {
|
|
1152 | 1185 |
return null; |
1153 | 1186 |
} |
1154 | 1187 |
if (this.tabResults.getSelectedIndex() == 0) { |
... | ... | |
1380 | 1413 |
|
1381 | 1414 |
@Override |
1382 | 1415 |
public int getSelectedFeatureCount() { |
1383 |
if (this.conditionPanels == null) { |
|
1416 |
if (!this.initialized) { //this.conditionPanels == null) {
|
|
1384 | 1417 |
return 0; |
1385 | 1418 |
} |
1386 | 1419 |
if (this.currentPostProcess == null || this.tabResults.getSelectedIndex() == 0) { |
Also available in: Unified diff