From c5038a33ca440efe6355bda41251aa1c2da009ae Mon Sep 17 00:00:00 2001 From: Nicolas Micoud <58596990+nmicoud@users.noreply.github.com> Date: Tue, 19 May 2020 13:56:52 +0200 Subject: [PATCH] IDEMPIERE-4150 : Right click / New/Update not visible with duplicated windows (#50) Also use ZoomConditions for Table/TableDirect editors --- .../org/compiere/model/MLookupFactory.java | 9 +++++ .../webui/editor/WEditorPopupMenu.java | 34 ++++++++++++------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java index fc62fa2ca3..ef6e1039cc 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java +++ b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java @@ -581,6 +581,11 @@ public class MLookupFactory realSQL.append(" ORDER BY 3"); if (s_log.isLoggable(Level.FINEST)) s_log.finest("AD_Reference_Value_ID=" + AD_Reference_Value_ID + " - " + realSQL); + + int zoomWinID = Env.getZoomWindowID(MTable.get(ctx, TableName).getAD_Table_ID(), 0, WindowNo); + if (zoomWinID > 0) + ZoomWindow = zoomWinID; + if (overrideZoomWindow > 0) { ZoomWindow = overrideZoomWindow; @@ -786,6 +791,10 @@ public class MLookupFactory ZoomWindow = table.getAD_Window_ID(); ZoomWindowPO = table.getPO_Window_ID(); + int zoomWinID = Env.getZoomWindowID(table.getAD_Table_ID(), 0, WindowNo); + if (zoomWinID > 0) + ZoomWindow = zoomWinID; + StringBuilder realSQL = new StringBuilder("SELECT "); realSQL.append(TableName).append(".").append(KeyColumn).append(",NULL,"); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java index dc20d4356b..9a8916a1e0 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java @@ -141,23 +141,16 @@ public class WEditorPopupMenu extends Menupopup implements EventListener Boolean canAccessZoom = MRole.getDefault().getWindowAccess(zoomCondition.getAD_Window_ID()); if (canAccessZoom != null && canAccessZoom) { this.zoomEnabled = true; + if (hasQuickEntryField(zoomCondition.getAD_Window_ID(), 0, tableName)) { + this.newEnabled = true; + this.updateEnabled = true; + } + break; } } } else { - int cnt = DB.getSQLValueEx(null, - "SELECT COUNT(*) " - + "FROM AD_Field f " - + " JOIN AD_Tab t " - + " ON ( t.AD_Tab_ID = f.AD_Tab_ID ) " - + "WHERE t.AD_Window_ID IN (?,?) " - + " AND f.IsActive = 'Y' " - + " AND t.IsActive = 'Y' " - + " AND f.IsQuickEntry = 'Y' " - + " AND (t.TabLevel = 0 " - + " AND t.AD_Table_ID IN (SELECT AD_Table_ID FROM AD_Table WHERE TableName = ? )) ", - winID,winIDPO,tableName); - if (cnt > 0) { + if (hasQuickEntryField(winID,winIDPO,tableName)) { this.newEnabled = true; this.updateEnabled = true; } else { @@ -169,6 +162,21 @@ public class WEditorPopupMenu extends Menupopup implements EventListener init(); } + boolean hasQuickEntryField(int winID, int winIDPO, String tableName) { + return DB.getSQLValueEx(null, + "SELECT COUNT(*) " + + "FROM AD_Field f " + + " JOIN AD_Tab t " + + " ON ( t.AD_Tab_ID = f.AD_Tab_ID ) " + + "WHERE t.AD_Window_ID IN (?,?) " + + " AND f.IsActive = 'Y' " + + " AND t.IsActive = 'Y' " + + " AND f.IsQuickEntry = 'Y' " + + " AND (t.TabLevel = 0 " + + " AND t.AD_Table_ID IN (SELECT AD_Table_ID FROM AD_Table WHERE TableName = ? )) ", + winID,winIDPO,tableName) > 0; + } + public boolean isZoomEnabled() { return zoomEnabled; }