Revision 46062 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 | ||
---|---|---|
29 | 29 |
import javax.swing.ImageIcon; |
30 | 30 |
import javax.swing.JButton; |
31 | 31 |
import javax.swing.JComponent; |
32 |
import javax.swing.JLabel; |
|
33 | 32 |
import javax.swing.JMenuItem; |
34 | 33 |
import javax.swing.JOptionPane; |
35 | 34 |
import javax.swing.JPopupMenu; |
36 |
import javax.swing.JProgressBar; |
|
37 | 35 |
import javax.swing.JTable; |
38 | 36 |
import javax.swing.ListSelectionModel; |
39 | 37 |
import javax.swing.SwingUtilities; |
... | ... | |
618 | 616 |
this.pnlCfgActions.add(configurableActions, BorderLayout.CENTER); |
619 | 617 |
|
620 | 618 |
this.taskStatusController = ToolsSwingLocator.getTaskStatusSwingManager().createTaskStatusController( |
621 |
new JLabel(), |
|
622 |
new JLabel(), |
|
623 |
new JProgressBar()); |
|
619 |
this.lblStatusTitle, |
|
620 |
this.lblMsg, |
|
621 |
this.pgbStatus); |
|
622 |
this.pgbStatus.setVisible(false); |
|
624 | 623 |
|
625 | 624 |
this.conditionPanels.add( |
626 | 625 |
new SearchConditionPanelSimplified( |
... | ... | |
855 | 854 |
|
856 | 855 |
@Override |
857 | 856 |
public void clear() { |
858 |
this.lblMsg.setText("");
|
|
857 |
this.taskStatusController.setTitle("");
|
|
859 | 858 |
if (this.conditionPanels == null) { |
860 | 859 |
return; |
861 | 860 |
} |
... | ... | |
911 | 910 |
lblMsg.setText(ToolsLocator.getI18nManager().getTranslation("_Searching")+"..."); |
912 | 911 |
setEnabled(false); |
913 | 912 |
Thread th = new Thread(() -> { |
914 |
try {
|
|
915 |
SearchParameters searchParams;
|
|
916 |
try {
|
|
917 |
searchParams = this.fetch(this.parameters.getCopy()); // esto lo actualiza a la ultima // decidir si se devuelve clonado
|
|
913 |
try { |
|
914 |
SearchParameters searchParams;
|
|
915 |
try {
|
|
916 |
searchParams = this.fetch(this.parameters.getCopy()); // esto lo actualiza a la ultima // decidir si se devuelve clonado
|
|
918 | 917 |
|
919 |
Date date = Calendar.getInstance().getTime();
|
|
920 |
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
921 |
String strDate = dateFormat.format(date);
|
|
922 |
searchParams.setName("Params: " + strDate);
|
|
923 |
} catch (Exception ex) {
|
|
924 |
LOGGER.warn("Not able to create search parameters.", ex);
|
|
925 |
lblMsg.setText(ToolsLocator.getI18nManager().getTranslation("_Errors_fetching_new_query")+"...");
|
|
926 |
resetTable();
|
|
927 |
return;
|
|
928 |
}
|
|
929 |
doSearch(searchParams);
|
|
930 |
} catch (Exception ex) {
|
|
931 |
LOGGER.warn("Search panel has errors during the search", ex);
|
|
932 |
resetTable();
|
|
933 |
} finally {
|
|
934 |
SwingUtilities.invokeLater(() -> {
|
|
935 |
setEnabled(true);
|
|
936 |
});
|
|
937 |
}
|
|
918 |
Date date = Calendar.getInstance().getTime();
|
|
919 |
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
920 |
String strDate = dateFormat.format(date);
|
|
921 |
searchParams.setName("Params: " + strDate);
|
|
922 |
} catch (Exception ex) {
|
|
923 |
LOGGER.warn("Not able to create search parameters.", ex);
|
|
924 |
this.taskStatusController.setTitle(ToolsLocator.getI18nManager().getTranslation("_Errors_fetching_new_query") + "...");
|
|
925 |
resetTable();
|
|
926 |
return;
|
|
927 |
}
|
|
928 |
doSearch(searchParams);
|
|
929 |
} catch (Exception ex) {
|
|
930 |
LOGGER.warn("Search panel has errors during the search", ex);
|
|
931 |
resetTable();
|
|
932 |
} finally {
|
|
933 |
SwingUtilities.invokeLater(() -> {
|
|
934 |
setEnabled(true);
|
|
935 |
});
|
|
936 |
}
|
|
938 | 937 |
}); |
939 | 938 |
th.start(); |
940 | 939 |
} |
... | ... | |
942 | 941 |
private void doSearch(SearchParameters searchParams) { |
943 | 942 |
final MutableObject model = new MutableObject(null); |
944 | 943 |
final MutableLong rowCount=new MutableLong(); |
944 |
Cursor savedCursor = this.getCursor(); |
|
945 |
SimpleTaskStatus status = ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus(""); |
|
946 |
status.setAutoremove(true); |
|
947 |
status.add(); |
|
948 |
this.taskStatusController.bind(status); |
|
945 | 949 |
try { |
950 |
status.setTitle(ToolsLocator.getI18nManager().getTranslation("_Processing_search")); |
|
951 |
SwingUtilities.invokeLater(() -> {this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));}); |
|
946 | 952 |
final List<Feature> features; |
947 | 953 |
FeatureQuery myQuery; |
948 | 954 |
// myQuery = this.getQuery().getCopy(); |
... | ... | |
962 | 968 |
rowCount.setValue(tableModel.getRowCount()); |
963 | 969 |
} catch (Exception ex) { |
964 | 970 |
LOGGER.warn("Search not able to be executed. Can't get features or create table model", ex); |
965 |
lblMsg.setText(ToolsLocator.getI18nManager().getTranslation("_Errors_getting_new_feature_set") + "..."); |
|
971 |
status.setTitle(ToolsLocator.getI18nManager().getTranslation("_Errors_getting_new_feature_set") + "..."); |
|
972 |
status.abort(); |
|
966 | 973 |
resetTable(); |
967 | 974 |
} finally { |
968 | 975 |
SwingUtilities.invokeLater(() -> { |
... | ... | |
976 | 983 |
((SimpleFeaturesTableModelImpl) oldmodel).dispose(); |
977 | 984 |
} |
978 | 985 |
if (resultModel.hasErrors()) { |
979 |
lblMsg.setText(i18n.getTranslation("_Errors_occurred_during_search"));
|
|
986 |
status.setTitle(i18n.getTranslation("_Errors_occurred_during_search"));
|
|
980 | 987 |
} else { |
981 |
lblMsg.setText(String.format("%d " + i18n.getTranslation("_elements"), rowCount.getValue()));
|
|
988 |
status.setTitle(String.format("%d " + i18n.getTranslation("_elements"), rowCount.getValue()));
|
|
982 | 989 |
} |
983 | 990 |
if (this.parameters != null && this.parameters.getQuery() != null) { |
984 | 991 |
this.history.add(searchParams); |
985 | 992 |
} |
986 | 993 |
} catch (Exception ex) { |
987 | 994 |
LOGGER.warn(" Errors occurred during search getting old model", ex); |
988 |
lblMsg.setText(i18n.getTranslation("_Errors_occurred_during_search"));
|
|
995 |
status.setTitle(i18n.getTranslation("_Errors_occurred_during_search"));
|
|
989 | 996 |
} finally { |
990 | 997 |
setEnabled(true); |
998 |
status.terminate(); |
|
999 |
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
|
991 | 1000 |
} |
992 | 1001 |
}); |
993 | 1002 |
} |
... | ... | |
1191 | 1200 |
try { |
1192 | 1201 |
this.processing = true; |
1193 | 1202 |
this.setEnabled(false); |
1203 |
status.setTitle(ToolsLocator.getI18nManager().getTranslation("_Copying_rows_to_clipboard")); |
|
1194 | 1204 |
SwingUtilities.invokeLater(() -> {this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));}); |
1195 | 1205 |
|
1196 | 1206 |
SimpleFeaturesTableModel model = null; |
... | ... | |
1224 | 1234 |
} |
1225 | 1235 |
|
1226 | 1236 |
//from( 0, selection.length) |
1227 |
|
|
1237 |
|
|
1228 | 1238 |
status.setRangeOfValues(0, selection.length); |
1229 | 1239 |
excelStr.append(LINE_BREAK); |
1230 | 1240 |
for (int i : selection) { |
... | ... | |
1279 | 1289 |
} finally { |
1280 | 1290 |
this.processing = false; |
1281 | 1291 |
SwingUtilities.invokeLater(() -> {this.setCursor(savedCursor);}); |
1282 |
this.setEnabled(true); |
|
1292 |
status.setTitle(ToolsLocator.getI18nManager().getTranslation("_Copy_ended")); |
|
1293 |
this.updateComponentState(); |
|
1283 | 1294 |
} |
1284 | 1295 |
}, "SearchPanelCopyRows"); |
1285 | 1296 |
task.start(); |
... | ... | |
1607 | 1618 |
SearchPostProcessFactory factory, |
1608 | 1619 |
DynObject parameters |
1609 | 1620 |
) { |
1621 |
Cursor savedCursor = this.getCursor(); |
|
1622 |
SimpleTaskStatus status = ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus(""); |
|
1623 |
status.setAutoremove(true); |
|
1624 |
status.add(); |
|
1625 |
this.taskStatusController.bind(status); |
|
1610 | 1626 |
Thread task = new Thread(() -> { |
1611 | 1627 |
try { |
1628 |
SwingUtilities.invokeLater(() -> {this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));}); |
|
1612 | 1629 |
this.processing = true; |
1613 |
this.updateComponentState(); |
|
1630 |
this.updateComponentState();
|
|
1614 | 1631 |
SearchPostProcess process = factory.createProcess(factory, input, query, parameters); |
1615 | 1632 |
|
1616 | 1633 |
if (parameters != null) { |
1617 | 1634 |
process.setParameters(parameters); |
1618 | 1635 |
} |
1619 | 1636 |
//Ejecutar el execute en thread para no bloquear el software |
1620 |
SearchPostProcess.SearchPostProcessResult output = process.execute(input, query, parameters); |
|
1621 |
this.postProcessStore = output.getStore(); |
|
1622 |
this.postProcessQuery = output.getQuery(); |
|
1637 |
SearchPostProcess.SearchPostProcessResult output = process.execute(input, query, parameters, status); |
|
1638 |
if (output != null) { |
|
1639 |
this.postProcessStore = output.getStore(); |
|
1640 |
this.postProcessQuery = output.getQuery(); |
|
1641 |
|
|
1642 |
doLoadSearchPostProccessResults(this.postProcessStore); |
|
1643 |
|
|
1644 |
} |
|
1623 | 1645 |
this.currentPostProcess = factory.getName(); |
1624 |
SwingUtilities.invokeLater(() -> { // Añade a la cola de eventos un evento a ejecutar de código |
|
1625 |
doLoadSearchPostProccessResults(this.postProcessStore); |
|
1626 |
}); |
|
1646 |
status.terminate(); |
|
1647 |
|
|
1627 | 1648 |
}catch (Exception ex){ |
1628 | 1649 |
LOGGER.warn("SearchPostProcess not able to be executed.", ex); |
1629 | 1650 |
resetPostProcessTable(); |
1630 |
|
|
1651 |
status.setTitle(ToolsLocator.getI18nManager().getTranslation("_Error_in_post_process_operation")); |
|
1652 |
status.message(""); |
|
1653 |
status.abort(); |
|
1631 | 1654 |
} finally { |
1655 |
SwingUtilities.invokeLater(() -> {this.setCursor(savedCursor);}); |
|
1632 | 1656 |
this.processing = false; |
1633 | 1657 |
this.updateComponentState(); |
1634 | 1658 |
} |
... | ... | |
1639 | 1663 |
} |
1640 | 1664 |
|
1641 | 1665 |
private void doLoadSearchPostProccessResults(FeatureStore input) { |
1666 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
1667 |
SwingUtilities.invokeLater(() -> { |
|
1668 |
doLoadSearchPostProccessResults(input); |
|
1669 |
}); |
|
1670 |
return; |
|
1671 |
} |
|
1642 | 1672 |
|
1643 | 1673 |
final List<Feature> featuresSearchPostProccessResults; |
1644 | 1674 |
final FeatureQuery finalQuery; |
... | ... | |
1680 | 1710 |
SwingUtilities.invokeLater(this::updateComponentState); |
1681 | 1711 |
return; |
1682 | 1712 |
} |
1713 |
this.pgbStatus.setVisible(processing); |
|
1683 | 1714 |
this.setEnabled(!processing); |
1684 | 1715 |
} |
1685 | 1716 |
|
... | ... | |
1733 | 1764 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
1734 | 1765 |
|
1735 | 1766 |
if (model.hasErrors()) { |
1736 |
lblMsg.setText(i18n.getTranslation("_Errors_occurred_load_search_post_process"));
|
|
1767 |
this.taskStatusController.setTitle(i18n.getTranslation("_Errors_occurred_load_search_post_process"));
|
|
1737 | 1768 |
} else { |
1738 |
lblMsg.setText(String.format("%d " + i18n.getTranslation("_elements"), model.getRowCount()));
|
|
1769 |
this.taskStatusController.setTitle(String.format("%d " + i18n.getTranslation("_elements"), model.getRowCount()));
|
|
1739 | 1770 |
} |
1740 | 1771 |
} |
1741 | 1772 |
|
Also available in: Unified diff