IDEMPIERE-4084 Improve button access logic (#592)
This commit is contained in:
parent
b1d3f9c8fd
commit
3c220b6681
|
@ -153,6 +153,9 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
||||||
|
|
||||||
private List<ToolbarCustomButton> toolbarCustomButtons = new ArrayList<ToolbarCustomButton>();
|
private List<ToolbarCustomButton> toolbarCustomButtons = new ArrayList<ToolbarCustomButton>();
|
||||||
|
|
||||||
|
private List<String> restrictionList;
|
||||||
|
private List<String> advancedList;
|
||||||
|
|
||||||
// Elaine 2008/12/04
|
// Elaine 2008/12/04
|
||||||
/** Show Personal Lock */
|
/** Show Personal Lock */
|
||||||
public boolean isPersonalLock = MRole.getDefault().isPersonalLock();
|
public boolean isPersonalLock = MRole.getDefault().isPersonalLock();
|
||||||
|
@ -289,7 +292,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
||||||
overflows = new ArrayList<ToolBarButton>();
|
overflows = new ArrayList<ToolBarButton>();
|
||||||
MToolBarButton[] officialButtons = MToolBarButton.getToolbarButtons("W", null);
|
MToolBarButton[] officialButtons = MToolBarButton.getToolbarButtons("W", null);
|
||||||
for (MToolBarButton button : officialButtons) {
|
for (MToolBarButton button : officialButtons) {
|
||||||
if (! button.isActive()) {
|
if (!button.isActive() || !hasAccess(BTNPREFIX+button.getComponentName())) {
|
||||||
buttons.remove(button.getComponentName());
|
buttons.remove(button.getComponentName());
|
||||||
} else {
|
} else {
|
||||||
if (button.isCustomization()) {
|
if (button.isCustomization()) {
|
||||||
|
@ -476,6 +479,8 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
||||||
{
|
{
|
||||||
if(event.getTarget() instanceof ToolBarButton)
|
if(event.getTarget() instanceof ToolBarButton)
|
||||||
{
|
{
|
||||||
|
if (!event.getTarget().isVisible())
|
||||||
|
return;
|
||||||
if (!event.getTarget().getId().contentEquals(BTNPREFIX+"ShowMore"))
|
if (!event.getTarget().getId().contentEquals(BTNPREFIX+"ShowMore"))
|
||||||
doOnClick(event);
|
doOnClick(event);
|
||||||
else
|
else
|
||||||
|
@ -847,67 +852,30 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
||||||
|
|
||||||
private boolean ToolBarMenuRestictionLoaded = false;
|
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) {
|
public void updateToolbarAccess(int xAD_Window_ID) {
|
||||||
if (ToolBarMenuRestictionLoaded)
|
if (ToolBarMenuRestictionLoaded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ADWindow adwindow = ADWindow.findADWindow(this);
|
ADWindow adwindow = ADWindow.findADWindow(this);
|
||||||
List<String> 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<String> 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();
|
dynamicDisplay();
|
||||||
// If no workflow set for the table => disable btnWorkflow
|
// If no workflow set for the table => disable btnWorkflow
|
||||||
|
@ -1196,6 +1164,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPressed(String buttonName, boolean pressed) {
|
public void setPressed(String buttonName, boolean pressed) {
|
||||||
|
if (getButton(buttonName) != null)
|
||||||
getButton(buttonName).setPressed(pressed);
|
getButton(buttonName).setPressed(pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue