From 4901016de87e3da4b48a272bd177713a62795ae1 Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Mon, 14 Jun 2010 15:49:59 +0000 Subject: [PATCH] Errors for processes run from included tab should be shown. Thanks to Low. Sponsored by Metas GmbH. Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=3015917 --- base/src/org/compiere/model/GridTab.java | 48 +++++++++++++++---- base/src/org/compiere/model/GridTable.java | 28 +++++++++-- .../webui/panel/AbstractADWindowPanel.java | 36 +++++++++----- .../adempiere/webui/panel/StatusBarPanel.java | 15 +++--- 4 files changed, 96 insertions(+), 31 deletions(-) diff --git a/base/src/org/compiere/model/GridTab.java b/base/src/org/compiere/model/GridTab.java index b52287ff29..cf60b4f7c8 100644 --- a/base/src/org/compiere/model/GridTab.java +++ b/base/src/org/compiere/model/GridTab.java @@ -875,11 +875,20 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable * Refresh all data */ public void dataRefreshAll () + { + dataRefreshAll(true); + } + + /************************************************************************** + * Refresh all data + * @param fireEvent + */ + public void dataRefreshAll (boolean fireEvent) { log.fine("#" + m_vo.TabNo); /** @todo does not work with alpha key */ int keyNo = m_mTable.getKeyID(m_currentRow); - m_mTable.dataRefreshAll(); + m_mTable.dataRefreshAll(fireEvent); // Should use RowID - not working for tables with multiple keys if (keyNo != -1) { @@ -896,8 +905,9 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable } } } - setCurrentRow(m_currentRow, true); - fireStateChangeEvent(new StateChangeEvent(this, StateChangeEvent.DATA_REFRESH_ALL)); + setCurrentRow(m_currentRow, fireEvent); + if (fireEvent) + fireStateChangeEvent(new StateChangeEvent(this, StateChangeEvent.DATA_REFRESH_ALL)); } // dataRefreshAll /** @@ -905,7 +915,16 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable */ public void dataRefresh () { - dataRefresh (m_currentRow); + dataRefresh(true); + } + + /** + * Refresh current row data + * @param fireEvent + */ + public void dataRefresh (boolean fireEvent) + { + dataRefresh (m_currentRow, fireEvent); } // dataRefresh /** @@ -913,11 +932,22 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable * @param row index */ public void dataRefresh (int row) + { + dataRefresh(row, true); + } + + /** + * Refresh row data + * @param row index + * @param fireEvent + */ + public void dataRefresh (int row, boolean fireEvent) { log.fine("#" + m_vo.TabNo + " - row=" + row); - m_mTable.dataRefresh(row); - setCurrentRow(row, true); - fireStateChangeEvent(new StateChangeEvent(this, StateChangeEvent.DATA_REFRESH)); + m_mTable.dataRefresh(row, fireEvent); + setCurrentRow(row, fireEvent); + if (fireEvent) + fireStateChangeEvent(new StateChangeEvent(this, StateChangeEvent.DATA_REFRESH)); } // dataRefresh @@ -1008,7 +1038,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable for (int i = m_window.getTabIndex(this) - 1; i >= 0; i--) { GridTab parentTab = m_window.getTab(i); if (parentTab.m_vo.TabLevel == level-1) { - parentTab.dataRefresh(); + parentTab.dataRefresh(false); // search for the next parent if (parentTab.isDetail()) { level = parentTab.m_vo.TabLevel; @@ -1018,7 +1048,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable } } // refresh this tab - dataRefresh(); + dataRefresh(false); } } diff --git a/base/src/org/compiere/model/GridTable.java b/base/src/org/compiere/model/GridTable.java index 6bce4f1097..dde1ec3be9 100644 --- a/base/src/org/compiere/model/GridTable.java +++ b/base/src/org/compiere/model/GridTable.java @@ -87,6 +87,7 @@ import org.compiere.util.ValueNamePair; public class GridTable extends AbstractTableModel implements Serializable { + public static final String DATA_REFRESH_MESSAGE = "Refreshed"; /** * generated */ @@ -2738,6 +2739,16 @@ public class GridTable extends AbstractTableModel * @param row row */ public void dataRefresh (int row) + { + dataRefresh(row, true); + } + + /** + * Refresh Row - ignore changes + * @param row row + * @param fireStatusEvent + */ + public void dataRefresh (int row, boolean fireStatusEvent) { log.info("Row=" + row); @@ -2789,7 +2800,8 @@ public class GridTable extends AbstractTableModel m_rowChanged = -1; m_inserting = false; fireTableRowsUpdated(row, row); - fireDataStatusIEvent("Refreshed", ""); + if (fireStatusEvent) + fireDataStatusIEvent(DATA_REFRESH_MESSAGE, ""); } // dataRefresh @@ -2797,6 +2809,15 @@ public class GridTable extends AbstractTableModel * Refresh all Rows - ignore changes */ public void dataRefreshAll() + { + dataRefreshAll(true); + } + + /** + * Refresh all Rows - ignore changes + * @param fireStatusEvent + */ + public void dataRefreshAll(boolean fireStatusEvent) { log.info(""); m_inserting = false; // should not happen @@ -2809,7 +2830,8 @@ public class GridTable extends AbstractTableModel m_rowChanged = -1; m_inserting = false; fireTableDataChanged(); - fireDataStatusIEvent("Refreshed", ""); + if (fireStatusEvent) + fireDataStatusIEvent(DATA_REFRESH_MESSAGE, ""); } // dataRefreshAll @@ -2833,7 +2855,7 @@ public class GridTable extends AbstractTableModel m_rowChanged = -1; m_inserting = false; fireTableDataChanged(); - fireDataStatusIEvent("Refreshed", ""); + fireDataStatusIEvent(DATA_REFRESH_MESSAGE, ""); return true; } // dataRequery diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java index 52eee21671..9b7569ac9c 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java @@ -1009,7 +1009,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To newTabpanel.activate(true); back = (newTabIndex < oldTabIndex); - if (back) + if (back && newTabpanel.getTabLevel() > 0) { if (newTabpanel.getTabLevel() >= oldTabpanel.getTabLevel()) back = false; @@ -1129,7 +1129,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To { sb.replace(pos, pos+1, " - "); } - boolean showPopup = e.isError() || (!GridTab.DEFAULT_STATUS_MESSAGE.equals(e.getAD_Message())); + boolean showPopup = e.isError() + || (!GridTab.DEFAULT_STATUS_MESSAGE.equals(e.getAD_Message()) && !GridTable.DATA_REFRESH_MESSAGE.equals(e.getAD_Message())); statusBar.setStatusLine (sb.toString (), e.isError (), showPopup); } } @@ -1256,15 +1257,24 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To return (selTabIndex == 0); } + /** + * refresh all row + * @param fireEvent + */ + public void onRefresh(boolean fireEvent) + { + onSave(false); + curTab.dataRefreshAll(fireEvent); + curTabpanel.dynamicDisplay(0); + focusToActivePanel(); + } + /** * @see ToolbarListener#onRefresh() */ public void onRefresh() { - onSave(false); - curTab.dataRefreshAll(); - curTabpanel.dynamicDisplay(0); - focusToActivePanel(); + onRefresh(true); } /** @@ -1390,7 +1400,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords()); // autoSize } - curTab.dataRefresh(); // Elaine 2008/07/25 + curTab.dataRefresh(false); // Elaine 2008/07/25 } focusToActivePanel(); } @@ -1408,7 +1418,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To else { curTab.dataIgnore(); - curTab.dataRefresh(); + curTab.dataRefresh(false); curTabpanel.dynamicDisplay(0); toolbar.enableIgnore(false); } @@ -1898,7 +1908,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To if (vp.needSave()) { onSave(false); - onRefresh(); + onRefresh(false); } } // PaymentRule @@ -1998,7 +2008,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To if (error != null) FDialog.error(curWindowNo, null, "PostingError-N", error); - onRefresh(); + onRefresh(false); } } return; @@ -2043,7 +2053,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To form.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED); form.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT); SessionManager.getAppDesktop().showWindow(form); - onRefresh(); + onRefresh(false); } else { @@ -2056,8 +2066,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To dialog.setVisible(true); dialog.setPosition("center"); AEnv.showWindow(dialog); - onRefresh(); } + onRefresh(false); } } // actionButton @@ -2194,7 +2204,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To private void updateUI(ProcessInfo pi) { // Refresh data - curTab.dataRefresh(); + curTab.dataRefresh(false); // Timeout if (pi.isTimeout()) // set temporarily to R/O Env.setContext(ctx, curWindowNo, "Processed", "Y"); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/StatusBarPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/StatusBarPanel.java index 8f8ecae14a..87fc72ac08 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/StatusBarPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/StatusBarPanel.java @@ -18,6 +18,7 @@ package org.adempiere.webui.panel; import org.adempiere.webui.LayoutUtils; +import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Panel; import org.adempiere.webui.session.SessionManager; @@ -202,7 +203,7 @@ public class StatusBarPanel extends Panel implements EventListener, IStatusBar statusLine.setStyle("color: black"); statusLine.setTooltiptext(text); - if (!embedded && showPopup) + if (showPopup && AEnv.isBrowserSupported()) { Text t = new Text(text); popupContent.getChildren().clear(); @@ -252,11 +253,13 @@ public class StatusBarPanel extends Panel implements EventListener, IStatusBar String script = "var d = $e('" + popup.getUuid() + "');"; script += "d.style.display='block';d.style.visibility='hidden';"; - script += "var hs = document.defaultView.getComputedStyle(d, null).getPropertyValue('height');"; - script += "var h = parseInt(hs, 10);"; - script += "h = h - 18;if (h < 0) h = 0;"; - script += "var p = Position.cumulativeOffset($e('" + this.getUuid() + "'));"; - script += "d.style.top=(p[1]-h)+'px';"; + script += "var dhs = document.defaultView.getComputedStyle(d, null).getPropertyValue('height');"; + script += "var dh = parseInt(dhs, 10);"; + script += "var r = $e('" + getRoot().getUuid() + "');"; + script += "var rhs = document.defaultView.getComputedStyle(r, null).getPropertyValue('height');"; + script += "var rh = parseInt(rhs, 10);"; + script += "var p = Position.cumulativeOffset(r);"; + script += "d.style.top=(rh-dh-5)+'px';"; script += "d.style.left=(p[0]+1)+'px';"; script += "d.style.visibility='visible';";