IDEMPIERE-6094 AD Window: error notification popup for detail tab is being shown at the wrong position (#2299)

This commit is contained in:
hengsin 2024-04-09 01:11:23 +08:00 committed by Carlos Ruiz
parent 35995e07df
commit da8ce352a7
1 changed files with 21 additions and 4 deletions

View File

@ -73,6 +73,7 @@ import org.zkoss.zul.A;
import org.zkoss.zul.Div; import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox; import org.zkoss.zul.Hbox;
import org.zkoss.zul.Hlayout; import org.zkoss.zul.Hlayout;
import org.zkoss.zul.LayoutRegion;
import org.zkoss.zul.Popup; import org.zkoss.zul.Popup;
import org.zkoss.zul.Separator; import org.zkoss.zul.Separator;
import org.zkoss.zul.Space; import org.zkoss.zul.Space;
@ -708,7 +709,8 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
String labelText = buildLabelText(status); String labelText = buildLabelText(status);
if (error) { if (error) {
Clients.showNotification(buildNotificationText(status), "error", findTabpanel(this), "top_left", 3500, true); Component ref = isCollapsed(this) ? findTabpanel(this) : findTabpanel(messageContainer);
Clients.showNotification(buildNotificationText(status), "error", ref, "top_left", 3500, true);
} }
Label label = new Label(labelText); Label label = new Label(labelText);
messageContainer.appendChild(label); messageContainer.appendChild(label);
@ -735,6 +737,21 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
} }
} }
/**
* Is parent of detailPane in collapsed state
* @param detailPane
* @return true if parent of detailPane is in collapsed state
*/
private boolean isCollapsed(DetailPane detailPane) {
Component parent = detailPane.getParent();
while (parent != null) {
if (parent instanceof LayoutRegion lr)
return !lr.isOpen();
parent = parent.getParent();
}
return false;
}
/** /**
* Shorten status text to a more presentable length. * Shorten status text to a more presentable length.
* @param statusText * @param statusText
@ -811,8 +828,8 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
* @param error * @param error
* @param msg * @param msg
*/ */
private void showPopup(boolean error, String msg) { private void showPopup(boolean error, String msg) {
Clients.showNotification(buildNotificationText(msg), "error", findTabpanel(this), "at_pointer", 3500, true); Clients.showNotification(buildNotificationText(msg), "error", null, "at_pointer", 3500, true);
} }
/** /**
@ -1065,7 +1082,7 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
private Component findTabpanel(Component comp) { private Component findTabpanel(Component comp) {
Component parent = comp.getParent(); Component parent = comp.getParent();
while (parent != null) { while (parent != null) {
if (parent instanceof Tabpanel) if (parent instanceof org.adempiere.webui.component.Tabpanel)
return parent; return parent;
parent = parent.getParent(); parent = parent.getParent();