From 60bcc24bb4a29032ca5a423fba07fb219d5e96a9 Mon Sep 17 00:00:00 2001 From: Diego Ruiz <12065321+d-ruiz@users.noreply.github.com> Date: Mon, 22 Feb 2021 03:54:30 +0100 Subject: [PATCH] Idempiere 4084 (#599) * IDEMPIERE-4084 Fixed DynamicDisplay on overflow buttons * IDEMPIERE-4084 Clean unused code --- .../webui/adwindow/ADWindowToolbar.java | 31 ++++++++++++------- .../adwindow/AbstractADWindowContent.java | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java index a69ba8ffa0..562e6f6a35 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java @@ -32,7 +32,6 @@ import org.adempiere.webui.action.Actions; import org.adempiere.webui.action.IAction; import org.adempiere.webui.component.Combobox; import org.adempiere.webui.component.FToolbar; -import org.adempiere.webui.component.Menupopup; import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.event.ToolbarListener; @@ -68,7 +67,6 @@ import org.zkoss.zul.A; import org.zkoss.zul.Cell; import org.zkoss.zul.Comboitem; import org.zkoss.zul.Grid; -import org.zkoss.zul.Menuitem; import org.zkoss.zul.Popup; import org.zkoss.zul.Row; import org.zkoss.zul.Rows; @@ -871,7 +869,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener return true; } - public void updateToolbarAccess(int xAD_Window_ID) { + public void updateToolbarAccess() { if (ToolBarMenuRestictionLoaded) return; @@ -914,7 +912,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener if (gridTab != null) { int AD_Tab_ID = gridTab.getAD_Tab_ID(); List restrictionList = adwindow.getTabToolbarRestrictList(AD_Tab_ID); - + for (Component p = this.getFirstChild(); p != null; p = p.getNextSibling()) { if (p instanceof ToolBarButton) { if (!customButtons.contains(p) && !p.isVisible()) @@ -932,14 +930,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener p.setVisible(false); break; } - } else if (p instanceof Menupopup) { - for (Component p1 = p.getFirstChild(); p1 != null; p1 = p1.getNextSibling()) { - if ( p1 instanceof Menuitem && restrictName.equals((((Menuitem)p1).getValue())) ) { - p.removeChild(p1); - break; - } - } - } else if (p instanceof Combobox) { + } else if (p instanceof Combobox) { if (restrictName.equals(((Combobox) p).getId())) { p.setVisible(false); break; @@ -948,6 +939,22 @@ public class ADWindowToolbar extends FToolbar implements EventListener } } + + if (overflows != null) { + //Set visible all overflow buttons with the same condition as above + overflows.stream() + .filter(button -> !customButtons.contains(button) && !button.isVisible()) + .forEach(button -> button.setVisible(true)); + + for (String restrictName : restrictionList) { + for (ToolBarButton p : overflows) { + if (restrictName.equals(p.getName())) { + p.setVisible(false); + break; + } + } + } + } } } 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 b96357c347..646e526f8b 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 @@ -386,7 +386,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements toolbar.enableFind(true); adTabbox.evaluate(null); - toolbar.updateToolbarAccess(adWindowId); + toolbar.updateToolbarAccess(); updateToolbar(); if (query == null && toolbar.initDefaultQuery()) { doOnQueryChange();