From 0f6e3abacf877ac5d17fd161896f9f7e0bb6b8f4 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 19 Aug 2015 07:37:26 -0500 Subject: [PATCH] IDEMPIERE-1328 Change tab name dynamically / fix issue reported by Claudemir about deleted records and empty tabs --- .../src/org/compiere/model/GridTable.java | 6 +++-- .../adwindow/AbstractADWindowContent.java | 26 ++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridTable.java b/org.adempiere.base/src/org/compiere/model/GridTable.java index a78f1256ee..efa0eb2967 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTable.java +++ b/org.adempiere.base/src/org/compiere/model/GridTable.java @@ -102,9 +102,11 @@ public class GridTable extends AbstractTableModel /** * */ - private static final long serialVersionUID = -4440415447489133947L; + private static final long serialVersionUID = -3993077765244392901L; public static final String DATA_REFRESH_MESSAGE = "Refreshed"; + public static final String DATA_UPDATE_COPIED_MESSAGE = "UpdateCopied"; + public static final String DATA_INSERTED_MESSAGE = "Inserted"; /** * JDBC Based Buffered Table @@ -2621,7 +2623,7 @@ public class GridTable extends AbstractTableModel // inform if (log.isLoggable(Level.FINE)) log.fine("Current=" + currentRow + ", New=" + m_newRow); fireTableRowsInserted(m_newRow, m_newRow); - fireDataStatusIEvent(copyCurrent ? "UpdateCopied" : "Inserted", ""); + fireDataStatusIEvent(copyCurrent ? DATA_UPDATE_COPIED_MESSAGE : DATA_INSERTED_MESSAGE, ""); if (log.isLoggable(Level.FINE)) log.fine("Current=" + currentRow + ", New=" + m_newRow + " - complete"); return true; } // dataNew diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index 69864ec096..57c7488536 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -1337,7 +1337,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements if (!detailTab) { String dbInfo = e.getMessage(); - if (! prevdbInfo.equals(dbInfo)) { + String adInfo = e.getAD_Message(); + if ( ! prevdbInfo.equals(dbInfo) + && ( GridTab.DEFAULT_STATUS_MESSAGE.equals(adInfo) + || GridTable.DATA_REFRESH_MESSAGE.equals(adInfo) + || GridTable.DATA_INSERTED_MESSAGE.equals(adInfo) + || GridTable.DATA_UPDATE_COPIED_MESSAGE.equals(adInfo) + ) + ) { prevdbInfo = dbInfo; if (logger.isLoggable(Level.INFO)) logger.info(dbInfo); if (adTabbox.getSelectedGridTab() != null && adTabbox.getSelectedGridTab().isQueryActive()) @@ -1361,13 +1368,20 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements sb.append(Env.getContext(ctx, curWindowNo, "_WinInfo_WindowName", false)).append(": "); if (titleLogic.contains("<")) { // IDEMPIERE-1328 - enable using format or subcolumns on title - if ( getADTab() != null - && getADTab().getADTabpanel(0) != null - && getADTab().getADTabpanel(0).getGridTab() != null + if ( getADTab() != null + && getADTab().getADTabpanel(0) != null + && getADTab().getADTabpanel(0).getGridTab() != null && getADTab().getADTabpanel(0).getGridTab().getTableModel() != null) { GridTab tab = getADTab().getADTabpanel(0).getGridTab(); - PO po = tab.getTableModel().getPO(tab.getCurrentRow()); - titleLogic = Env.parseVariable(titleLogic, po, null, false); + int row = tab.getCurrentRow(); + int cnt = tab.getRowCount(); + boolean inserting = tab.getTableModel().isInserting(); + if (row >= 0 && cnt > 0 && !inserting) { + PO po = tab.getTableModel().getPO(row); + titleLogic = Env.parseVariable(titleLogic, po, null, false); + } else { + titleLogic = Env.parseContext(Env.getCtx(), curWindowNo, titleLogic, false, true); + } } } else { titleLogic = Env.parseContext(Env.getCtx(), curWindowNo, titleLogic, false, true);