From c9b563f40823d4278835193691fcd180b9679473 Mon Sep 17 00:00:00 2001 From: hengsin Date: Thu, 2 Dec 2021 21:00:14 +0800 Subject: [PATCH] IDEMPIERE-5068 Improvement to report viewer find dialog (#1023) * IDEMPIERE-5068 Improvement to report viewer find dialog * IDEMPIERE-5068 Improvement to report viewer find dialog Fix javascript error --- .../src/org/adempiere/webui/LayoutUtils.java | 37 +++++++++++++- .../webui/window/ZkReportViewer.java | 50 +++++++++++++------ 2 files changed, 70 insertions(+), 17 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java index a65f0c388c..8538fdc3a1 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java @@ -191,7 +191,7 @@ public final class LayoutUtils { } /** - * open popup window relative to the ref component + * open embedded window relative to the ref component * @param ref * @param window * @param position @@ -207,7 +207,26 @@ public final class LayoutUtils { .append("');"); window.setVisible(true); window.setMode(Mode.EMBEDDED); - Clients.response("_openPopupWindow_", new AuScript(window, script.toString())); + Clients.response("_openEmbeddedWindow_", new AuScript(window, script.toString())); + } + + /** + * open highlighted window relative to the ref component + * @param ref + * @param window + * @param position + */ + public static void openHighlightedWindow(Component ref, Window window, String position) { + StringBuilder script = new StringBuilder(); + script.append("idempiere.show_popup_window('#") + .append(ref.getUuid()) + .append("','#") + .append(window.getUuid()) + .append("','") + .append(position) + .append("');"); + window.setMode(Mode.HIGHLIGHTED); + Clients.response("_openHighlightedWindow_", new AuScript(window, script.toString())); } /** @@ -509,4 +528,18 @@ public final class LayoutUtils { } }); } + + /** + * set target same width as ref using client side script + * @param target + * @param ref + */ + public static void sameWidth(HtmlBasedComponent target, HtmlBasedComponent ref) { + StringBuilder script = new StringBuilder() + .append("var t=zk.Widget.$('#").append(target.getUuid()).append("');") + .append("var r=zk.Widget.$('#").append(ref.getUuid()).append("');") + .append("jq(t).css({'width':").append("jq(r).width()+'px'});") + .append("t.setWidth(\"").append("jq(r).width()+'px'\");"); + Clients.response("_sameWidth_", new AuScript(target, script.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 6551e2efa1..18b53113f5 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 @@ -227,6 +227,8 @@ public class ZkReportViewer extends Window implements EventListener, ITab private final Map> mediaSuppliers = new HashMap>(); private Center center; + + private FindWindow find; /** * Static Layout * @throws Exception @@ -1513,22 +1515,30 @@ public class ZkReportViewer extends Window implements EventListener, ITab bFind.setVisible(false); else { - final FindWindow find = new FindWindow(m_WindowNo, 0, title, AD_Table_ID, tableName,m_reportEngine.getWhereExtended(), findFields, 1, AD_Tab_ID); - if (!find.initialize()) - return; + if (find == null) + { + find = new FindWindow(m_WindowNo, 0, title, AD_Table_ID, tableName,m_reportEngine.getWhereExtended(), findFields, 1, AD_Tab_ID); + if (!find.initialize()) + { + find = null; + return; + } - find.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { - @Override - public void onEvent(Event event) throws Exception { - if (!find.isCancel()) - { - m_reportEngine.setQuery(find.getQuery()); - postRenderReportEvent(); - } - } - }); - find.setTitle(null); - LayoutUtils.openPopupWindow(toolBar, find, "after_start"); + find.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + if (!find.isCancel()) + { + m_reportEngine.setQuery(find.getQuery()); + postRenderReportEvent(); + } + } + }); + setupFindwindow(find); + } + getParent().appendChild(find); + LayoutUtils.openHighlightedWindow(toolBar, find, "after_start"); + LayoutUtils.sameWidth(find, this); } } // cmd_find @@ -1893,4 +1903,14 @@ public class ZkReportViewer extends Window implements EventListener, ITab return m_reportEngine.getName(); } + private void setupFindwindow(FindWindow findWindow) { + findWindow.setTitle(null); + findWindow.setBorder("none"); + if (ClientInfo.maxHeight(ClientInfo.MEDIUM_HEIGHT-1)) + ZKUpdateUtil.setHeight(findWindow, "100%"); + else + ZKUpdateUtil.setHeight(findWindow, "60%"); + findWindow.setSizable(false); + findWindow.setContentStyle("background-color: #fff; width: 99%; margin: auto;"); + } }