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 2b7f8d95a6..a69ba8ffa0 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 @@ -152,6 +152,9 @@ public class ADWindowToolbar extends FToolbar implements EventListener private Map ctrlKeyMap = new HashMap(); private List toolbarCustomButtons = new ArrayList(); + + private List restrictionList; + private List advancedList; // Elaine 2008/12/04 /** Show Personal Lock */ @@ -289,7 +292,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener overflows = new ArrayList(); MToolBarButton[] officialButtons = MToolBarButton.getToolbarButtons("W", null); for (MToolBarButton button : officialButtons) { - if (! button.isActive()) { + if (!button.isActive() || !hasAccess(BTNPREFIX+button.getComponentName())) { buttons.remove(button.getComponentName()); } else { if (button.isCustomization()) { @@ -476,6 +479,8 @@ public class ADWindowToolbar extends FToolbar implements EventListener { if(event.getTarget() instanceof ToolBarButton) { + if (!event.getTarget().isVisible()) + return; if (!event.getTarget().getId().contentEquals(BTNPREFIX+"ShowMore")) doOnClick(event); else @@ -846,68 +851,31 @@ public class ADWindowToolbar extends FToolbar implements EventListener } private boolean ToolBarMenuRestictionLoaded = false; + + private boolean hasAccess(String buttonName) { + ADWindow adwindow = ADWindow.get(windowNo); + if (restrictionList == null) + restrictionList = adwindow.getWindowToolbarRestrictList(); + + if (restrictionList.contains(buttonName)) + return false; + + if (!MRole.getDefault().isAccessAdvanced()) { + if (advancedList == null) + advancedList = adwindow.getWindowAdvancedButtonList(); + + if (advancedList.contains(buttonName)) + return false; + }// All advanced btn + + return true; + } public void updateToolbarAccess(int xAD_Window_ID) { if (ToolBarMenuRestictionLoaded) return; ADWindow adwindow = ADWindow.findADWindow(this); - List restrictionList = adwindow.getWindowToolbarRestrictList(); - - for (String restrictName : restrictionList) - { - for (Component p = this.getFirstChild(); p != null; p = p.getNextSibling()) { - if (p instanceof ToolBarButton) { - if ( restrictName.equals(((ToolBarButton)p).getName()) ) { - this.removeChild(p); - 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) { - if (restrictName.equals(((Combobox) p).getId())) { - this.removeChild(p); - break; - } - } - } - - } // All restrictions - - if (!MRole.getDefault().isAccessAdvanced()) - { - List advancedList = adwindow.getWindowAdvancedButtonList(); - for (String advancedName : advancedList) - { - for (Component p = this.getFirstChild(); p != null; p = p.getNextSibling()) { - if (p instanceof ToolBarButton) { - if ( advancedName.equals(((ToolBarButton)p).getName()) ) { - this.removeChild(p); - break; - } - } else if (p instanceof Menupopup) { - for (Component p1 = p.getFirstChild(); p1 != null; p1 = p1.getNextSibling()) { - if ( p1 instanceof Menuitem && advancedName.equals((((Menuitem)p1).getValue())) ) { - p.removeChild(p1); - break; - } - } - } else if (p instanceof Combobox) { - if (advancedName.equals(((Combobox) p).getId())) { - this.removeChild(p); - break; - } - } - } - - } // All advanced btn - } dynamicDisplay(); // If no workflow set for the table => disable btnWorkflow @@ -1196,7 +1164,8 @@ public class ADWindowToolbar extends FToolbar implements EventListener } public void setPressed(String buttonName, boolean pressed) { - getButton(buttonName).setPressed(pressed); + if (getButton(buttonName) != null) + getButton(buttonName).setPressed(pressed); } /**