From ffc5bec7ad54d1e6b65745ccecbd294e5f0f982c Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 5 Nov 2014 08:59:55 -0500 Subject: [PATCH] IDEMPIERE-2089 Print format window ID is hardcoded in ZKReportViewer --- org.adempiere.base/src/org/compiere/model/SystemIDs.java | 1 - .../src/org/compiere/print/MPrintFormat.java | 8 +++++++- .../src/org/compiere/print/Viewer.java | 7 +++---- .../org/adempiere/webui/panel/action/ReportAction.java | 8 ++++---- .../src/org/adempiere/webui/window/ZkReportViewer.java | 9 ++++----- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/SystemIDs.java b/org.adempiere.base/src/org/compiere/model/SystemIDs.java index 2ab44b9358..4629ad1e30 100644 --- a/org.adempiere.base/src/org/compiere/model/SystemIDs.java +++ b/org.adempiere.base/src/org/compiere/model/SystemIDs.java @@ -145,7 +145,6 @@ public class SystemIDs public final static int WINDOW_MATERIALTRANSACTIONS_INDIRECTUSER = 223; public final static int WINDOW_MY_REQUESTS = 237; public final static int WINDOW_PHYSICALINVENTORY = 168; - public final static int WINDOW_PRINTFORMAT = 240; public final static int WINDOW_PRODUCTION = 191; public final static int WINDOW_REQUESTS_ALL = 232; public final static int WINDOW_RETURNTOVENDOR = 53098; diff --git a/org.adempiere.base/src/org/compiere/print/MPrintFormat.java b/org.adempiere.base/src/org/compiere/print/MPrintFormat.java index ec0ea10a1a..3a03d8dedf 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintFormat.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintFormat.java @@ -29,6 +29,7 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.logging.Level; + import org.adempiere.model.MTabCustomization; import org.compiere.model.GridField; import org.compiere.model.GridTab; @@ -58,7 +59,7 @@ public class MPrintFormat extends X_AD_PrintFormat /** * */ - private static final long serialVersionUID = 2826550741107576964L; + private static final long serialVersionUID = 5563074831750686572L; /** * Public Constructor. @@ -1239,6 +1240,11 @@ public class MPrintFormat extends X_AD_PrintFormat return clone; } + public static int getZoomWindowID(int AD_PrintFormat_ID) { + int pfAD_Window_ID = Env.getZoomWindowID(Table_ID, AD_PrintFormat_ID); + return pfAD_Window_ID; + } + /************************************************************************** * Test * @param args arga diff --git a/org.adempiere.ui.swing/src/org/compiere/print/Viewer.java b/org.adempiere.ui.swing/src/org/compiere/print/Viewer.java index e9f265b7a4..750054de67 100644 --- a/org.adempiere.ui.swing/src/org/compiere/print/Viewer.java +++ b/org.adempiere.ui.swing/src/org/compiere/print/Viewer.java @@ -18,8 +18,6 @@ *****************************************************************************/ package org.compiere.print; -import static org.compiere.model.SystemIDs.WINDOW_PRINTFORMAT; - import java.awt.BorderLayout; import java.awt.Component; import java.awt.Cursor; @@ -473,8 +471,9 @@ public class Viewer extends CFrame pstmt = null; } // IDEMPIERE-297 - Check for Table Access and Window Access for New Report + int pfAD_Window_ID = MPrintFormat.getZoomWindowID(AD_PrintFormat_ID); if ( MRole.getDefault().isTableAccess(MPrintFormat.Table_ID, false) - && (Boolean.TRUE.equals(MRole.getDefault().getWindowAccess(WINDOW_PRINTFORMAT)))) + && (Boolean.TRUE.equals(MRole.getDefault().getWindowAccess(pfAD_Window_ID)))) { StringBuffer sb = new StringBuffer("** ").append(Msg.getMsg(m_ctx, "NewReport")).append(" **"); KeyNamePair pp = new KeyNamePair(-1, sb.toString()); @@ -1221,8 +1220,8 @@ public class Viewer extends CFrame { AWindow win = new AWindow (getGraphicsConfiguration()); new AWindowListener (win, this); // forwards Window Events - int AD_Window_ID = WINDOW_PRINTFORMAT; // hardcoded int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID(); + int AD_Window_ID = MPrintFormat.getZoomWindowID(AD_PrintFormat_ID); boolean loadedOK = win.initWindow(AD_Window_ID, MQuery.getEqualQuery("AD_PrintFormat_ID", AD_PrintFormat_ID)); if (loadedOK) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ReportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ReportAction.java index 831b480b8b..e9027dfcae 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ReportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ReportAction.java @@ -15,14 +15,13 @@ package org.adempiere.webui.panel.action; -import static org.compiere.model.SystemIDs.WINDOW_PRINTFORMAT; - import java.io.ByteArrayOutputStream; import java.io.File; import java.io.StringWriter; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; + import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.adwindow.AbstractADWindowContent; import org.adempiere.webui.apps.WProcessCtl; @@ -449,8 +448,9 @@ public class ReportAction implements EventListener printFormatList.clear(); printFormatList = MPrintFormat.getAccessiblePrintFormats(AD_Table_ID, AD_Window_ID, null, false); - - if (MRole.getDefault().isTableAccess(MPrintFormat.Table_ID, false) && Boolean.TRUE.equals(MRole.getDefault().getWindowAccess(WINDOW_PRINTFORMAT))) + + int pfAD_Window_ID = MPrintFormat.getZoomWindowID(-1); + if (MRole.getDefault().isTableAccess(MPrintFormat.Table_ID, false) && Boolean.TRUE.equals(MRole.getDefault().getWindowAccess(pfAD_Window_ID))) { StringBuffer sb = new StringBuffer("** ").append(Msg.getMsg(Env.getCtx(), "NewReport")).append(" **"); KeyNamePair pp = new KeyNamePair(-1, sb.toString()); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index 7604a1f989..b2cbd67eb7 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -16,8 +16,6 @@ *****************************************************************************/ package org.adempiere.webui.window; -import static org.compiere.model.SystemIDs.WINDOW_PRINTFORMAT; - import java.io.ByteArrayOutputStream; import java.io.File; import java.io.StringWriter; @@ -648,8 +646,9 @@ public class ZkReportViewer extends Window implements EventListener, ITab pstmt = null; } // IDEMPIERE-297 - Check for Table Access and Window Access for New Report + int pfAD_Window_ID = MPrintFormat.getZoomWindowID(AD_PrintFormat_ID); if ( MRole.getDefault().isTableAccess(MPrintFormat.Table_ID, false) - && Boolean.TRUE.equals(MRole.getDefault().getWindowAccess(WINDOW_PRINTFORMAT))) + && Boolean.TRUE.equals(MRole.getDefault().getWindowAccess(pfAD_Window_ID))) { StringBuffer sb = new StringBuffer("** ").append(Msg.getMsg(Env.getCtx(), "NewReport")).append(" **"); KeyNamePair pp = new KeyNamePair(-1, sb.toString()); @@ -1162,9 +1161,9 @@ public class ZkReportViewer extends Window implements EventListener, ITab */ private void cmd_customize() { - int AD_Window_ID = WINDOW_PRINTFORMAT; // hardcoded int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID(); - AEnv.zoom(AD_Window_ID, MQuery.getEqualQuery("AD_PrintFormat_ID", AD_PrintFormat_ID)); + int pfAD_Window_ID = MPrintFormat.getZoomWindowID(AD_PrintFormat_ID); + AEnv.zoom(pfAD_Window_ID, MQuery.getEqualQuery("AD_PrintFormat_ID", AD_PrintFormat_ID)); } // cmd_customize /*IDEMPIERE -379*/