IDEMPIERE-5664 - Report Renderer can Overwrite any Current Tab (#1777)

* IDEMPIERE-5664 - Report Renderer can Overwrite any Current Tab

* IDEMPIERE-5664 - fix issue on close

- do not render the report if the tab is not found (e.g. closed already)

* IDEMPIERE-5664 -  pr1777 patch
This commit is contained in:
Peter Takács 2023-04-13 16:45:44 +02:00 committed by GitHub
parent a811b62b56
commit fdf2f0299c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 18 deletions

View File

@ -274,12 +274,21 @@ public abstract class TabbedDesktop extends AbstractDesktop {
String title = window.getTitle();
window.setTitle(null);
preOpenNewTab();
if (Window.INSERT_NEXT.equals(window.getAttribute(Window.INSERT_POSITION_KEY)))
if (Window.INSERT_NEXT.equals(window.getAttribute(Window.INSERT_POSITION_KEY))) {
windowContainer.insertAfter(windowContainer.getSelectedTab(), tabPanel, title, true, true, null);
else if(Window.REPLACE.equals(window.getAttribute(Window.INSERT_POSITION_KEY)))
windowContainer.replace(windowContainer.getSelectedTab(), window, title);
else
}
else if(Window.REPLACE.equals(window.getAttribute(Window.INSERT_POSITION_KEY))) {
Tab refTab = windowContainer.getSelectedTab();
Object windowNoAttribute = window.getAttribute(WindowContainer.REPLACE_WINDOW_NO);
if (windowNoAttribute != null && windowNoAttribute instanceof Integer) {
int windowNo = (Integer)windowNoAttribute;
refTab = windowContainer.getTab(windowNo);
}
windowContainer.replace(refTab, window, title);
}
else {
windowContainer.addWindow(tabPanel, title, true, null);
}
if (window instanceof IHelpContext)
Events.sendEvent(new Event(WindowContainer.ON_WINDOW_CONTAINER_SELECTION_CHANGED_EVENT, window));
}

View File

@ -74,6 +74,8 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
public static final String DEFER_SET_SELECTED_TAB = "deferSetSelectedTab";
private static final int DEFAULT_MAX_TITLE_LENGTH = 30;
public static final String REPLACE_WINDOW_NO = "replaceWindowNo";
private Tabbox tabbox;
private ToolBar toolbar;
@ -584,7 +586,7 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
* @param windowNo
* @return org.zkoss.zul.Tab
*/
private org.zkoss.zul.Tab getTab(int windowNo) {
public org.zkoss.zul.Tab getTab(int windowNo) {
org.zkoss.zul.Tabpanels panels = tabbox.getTabpanels();
List<?> childrens = panels.getChildren();
for (Object child : childrens)
@ -647,7 +649,7 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
* @param title
* @return
*/
public Tab replace(Tab refTab, Window comp, String title) {
public org.zkoss.zul.Tab replace(org.zkoss.zul.Tab refTab, Window comp, String title) {
if (refTab == null)
{

View File

@ -2033,7 +2033,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
ZKUpdateUtil.setHeight(findWindow, "100%");
else
ZKUpdateUtil.setHeight(findWindow, "60%");
findWindow.setSizable(false);
findWindow.setContentStyle("background-color: #fff; width: 99%; margin: auto;");
}
}
findWindow.setSizable(false);
findWindow.setContentStyle("background-color: #fff; width: 99%; margin: auto;");
}
}

View File

@ -48,14 +48,15 @@ public class ZkReportViewerProvider implements ReportViewerProvider {
}
protected void openReportViewWindow (ReportEngine report) {
Window viewer = new ZkReportViewer(report, report.getName());
ZkReportViewer viewer = new ZkReportViewer(report, report.getName());
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
if(report.isReplaceTabContent())
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.REPLACE);
viewer.setAttribute(WindowContainer.DEFER_SET_SELECTED_TAB, Boolean.TRUE);
SessionManager.getAppDesktop().showWindow(viewer);
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
if(report.isReplaceTabContent()) {
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.REPLACE);
viewer.setAttribute(WindowContainer.REPLACE_WINDOW_NO, report.getWindowNo());
}
viewer.setAttribute(WindowContainer.DEFER_SET_SELECTED_TAB, Boolean.TRUE);
SessionManager.getAppDesktop().showWindow(viewer);
}
}