Idempiere 4084 (#599)

* IDEMPIERE-4084 Fixed DynamicDisplay on overflow buttons

* IDEMPIERE-4084 Clean unused code
This commit is contained in:
Diego Ruiz 2021-02-22 03:54:30 +01:00 committed by GitHub
parent d188e563fc
commit 60bcc24bb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 13 deletions

View File

@ -32,7 +32,6 @@ import org.adempiere.webui.action.Actions;
import org.adempiere.webui.action.IAction; import org.adempiere.webui.action.IAction;
import org.adempiere.webui.component.Combobox; import org.adempiere.webui.component.Combobox;
import org.adempiere.webui.component.FToolbar; import org.adempiere.webui.component.FToolbar;
import org.adempiere.webui.component.Menupopup;
import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.event.ToolbarListener; import org.adempiere.webui.event.ToolbarListener;
@ -68,7 +67,6 @@ import org.zkoss.zul.A;
import org.zkoss.zul.Cell; import org.zkoss.zul.Cell;
import org.zkoss.zul.Comboitem; import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Grid; import org.zkoss.zul.Grid;
import org.zkoss.zul.Menuitem;
import org.zkoss.zul.Popup; import org.zkoss.zul.Popup;
import org.zkoss.zul.Row; import org.zkoss.zul.Row;
import org.zkoss.zul.Rows; import org.zkoss.zul.Rows;
@ -871,7 +869,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
return true; return true;
} }
public void updateToolbarAccess(int xAD_Window_ID) { public void updateToolbarAccess() {
if (ToolBarMenuRestictionLoaded) if (ToolBarMenuRestictionLoaded)
return; return;
@ -914,7 +912,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
if (gridTab != null) { if (gridTab != null) {
int AD_Tab_ID = gridTab.getAD_Tab_ID(); int AD_Tab_ID = gridTab.getAD_Tab_ID();
List<String> restrictionList = adwindow.getTabToolbarRestrictList(AD_Tab_ID); List<String> restrictionList = adwindow.getTabToolbarRestrictList(AD_Tab_ID);
for (Component p = this.getFirstChild(); p != null; p = p.getNextSibling()) { for (Component p = this.getFirstChild(); p != null; p = p.getNextSibling()) {
if (p instanceof ToolBarButton) { if (p instanceof ToolBarButton) {
if (!customButtons.contains(p) && !p.isVisible()) if (!customButtons.contains(p) && !p.isVisible())
@ -932,14 +930,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
p.setVisible(false); p.setVisible(false);
break; break;
} }
} else if (p instanceof Menupopup) { } else if (p instanceof Combobox) {
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) {
if (restrictName.equals(((Combobox) p).getId())) { if (restrictName.equals(((Combobox) p).getId())) {
p.setVisible(false); p.setVisible(false);
break; break;
@ -948,6 +939,22 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
} }
} }
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;
}
}
}
}
} }
} }

View File

@ -386,7 +386,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
toolbar.enableFind(true); toolbar.enableFind(true);
adTabbox.evaluate(null); adTabbox.evaluate(null);
toolbar.updateToolbarAccess(adWindowId); toolbar.updateToolbarAccess();
updateToolbar(); updateToolbar();
if (query == null && toolbar.initDefaultQuery()) { if (query == null && toolbar.initDefaultQuery()) {
doOnQueryChange(); doOnQueryChange();