IDEMPIERE-4790 : Deactivating ToolbarDetail Customize button throws NPE when using Toggle button (#689)
This commit is contained in:
parent
da96ecdc19
commit
3b4d371fb6
|
@ -89,7 +89,7 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
||||||
/**
|
/**
|
||||||
* generated serial id
|
* generated serial id
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -6994505162094868814L;
|
private static final long serialVersionUID = -6839563468328913930L;
|
||||||
|
|
||||||
private static final String BTN_PROCESS_ID = "BtnProcess";
|
private static final String BTN_PROCESS_ID = "BtnProcess";
|
||||||
|
|
||||||
|
@ -536,7 +536,10 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
||||||
var adTabPanel = getSelectedADTabpanel();
|
var adTabPanel = getSelectedADTabpanel();
|
||||||
if(!(adTabPanel instanceof ADSortTab)) {
|
if(!(adTabPanel instanceof ADSortTab)) {
|
||||||
adTabPanel.switchRowPresentation();
|
adTabPanel.switchRowPresentation();
|
||||||
getSelectedPanel().getToolbarButton(BTN_CUSTOMIZE_ID).setDisabled(!adTabPanel.isGridView());
|
|
||||||
|
ToolBarButton btnCustomize = getSelectedPanel().getToolbarButton(BTN_CUSTOMIZE_ID);
|
||||||
|
if (btnCustomize != null)
|
||||||
|
btnCustomize.setDisabled(!adTabPanel.isGridView());
|
||||||
|
|
||||||
Tabpanel tabPanel = (Tabpanel) tabbox.getSelectedTabpanel();
|
Tabpanel tabPanel = (Tabpanel) tabbox.getSelectedTabpanel();
|
||||||
tabPanel.setToggleToFormView(!adTabPanel.isGridView());
|
tabPanel.setToggleToFormView(!adTabPanel.isGridView());
|
||||||
|
@ -1111,8 +1114,8 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
||||||
getRecordToolbar().dynamicDisplay();
|
getRecordToolbar().dynamicDisplay();
|
||||||
}
|
}
|
||||||
boolean enableCustomize = !adTabPanel.getGridTab().isSortTab() && adTabPanel.isGridView();
|
boolean enableCustomize = !adTabPanel.getGridTab().isSortTab() && adTabPanel.isGridView();
|
||||||
List<ToolBarButton> btns = getToolbar().getChildren();
|
|
||||||
Optional<ToolBarButton> optional = btns.stream().filter(e -> BTN_CUSTOMIZE_ID.equals(e.getId())).findFirst();
|
Optional<ToolBarButton> optional = getToolbarButtons().stream().filter(e -> BTN_CUSTOMIZE_ID.equals(e.getId())).findFirst();
|
||||||
if (optional.isPresent())
|
if (optional.isPresent())
|
||||||
optional.get().setDisabled(!enableCustomize);
|
optional.get().setDisabled(!enableCustomize);
|
||||||
}
|
}
|
||||||
|
@ -1207,11 +1210,26 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
||||||
* @return {@link ToolBarButton}
|
* @return {@link ToolBarButton}
|
||||||
*/
|
*/
|
||||||
public ToolBarButton getToolbarButton(String id) {
|
public ToolBarButton getToolbarButton(String id) {
|
||||||
List<ToolBarButton> list = toolbar.getChildren();
|
Optional<ToolBarButton> optional = getToolbarButtons().stream().filter(e -> e.getId().equals(id)).findFirst();
|
||||||
Optional<ToolBarButton> optional = list.stream().filter(e -> e.getId().equals(id)).findFirst();
|
|
||||||
return optional.isPresent() ? optional.get() : null;
|
return optional.isPresent() ? optional.get() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return buttons from the detail toolbar
|
||||||
|
*/
|
||||||
|
private List<ToolBarButton> getToolbarButtons() {
|
||||||
|
|
||||||
|
List<ToolBarButton> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Component c : toolbar.getChildren()) {
|
||||||
|
if (c instanceof ToolBarButton)
|
||||||
|
list.add((ToolBarButton) c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
private void createOverflowButton() {
|
private void createOverflowButton() {
|
||||||
overflowButton = new A();
|
overflowButton = new A();
|
||||||
overflowButton.setTooltiptext(Msg.getMsg(Env.getCtx(), "ShowMore"));
|
overflowButton.setTooltiptext(Msg.getMsg(Env.getCtx(), "ShowMore"));
|
||||||
|
|
Loading…
Reference in New Issue