IDEMPIERE-2499:long task (ZkReportViewerProvider.openViewer) in process make GUI lock
fix:NPE, and improve long process
This commit is contained in:
parent
9d62771e3a
commit
19d7e7b855
|
@ -338,7 +338,7 @@ public class ReportEngine implements PrintServiceAttributeListener
|
|||
*/
|
||||
public Properties getCtx()
|
||||
{
|
||||
return getLayout().getCtx();
|
||||
return m_ctx;
|
||||
} // getCtx
|
||||
|
||||
/**
|
||||
|
|
|
@ -229,9 +229,6 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
m_ctx = m_reportEngine.getCtx();
|
||||
init();
|
||||
dynInit();
|
||||
|
||||
if (!ArchiveEngine.isValid(m_reportEngine.getLayout()))
|
||||
log.warning("Cannot archive Document");
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
@ -1306,6 +1303,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
if (!ArchiveEngine.isValid(viewer.m_reportEngine.getLayout()))
|
||||
log.warning("Cannot archive Document");
|
||||
String path = System.getProperty("java.io.tmpdir");
|
||||
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
||||
if (log.isLoggable(Level.FINE))
|
||||
|
@ -1351,6 +1350,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
if (!ArchiveEngine.isValid(viewer.m_reportEngine.getLayout()))
|
||||
log.warning("Cannot archive Document");
|
||||
String path = System.getProperty("java.io.tmpdir");
|
||||
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
||||
if (log.isLoggable(Level.FINE))
|
||||
|
@ -1395,6 +1396,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
if (!ArchiveEngine.isValid(viewer.m_reportEngine.getLayout()))
|
||||
log.warning("Cannot archive Document");
|
||||
String path = System.getProperty("java.io.tmpdir");
|
||||
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
||||
if (log.isLoggable(Level.FINE))
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
package org.adempiere.webui.window;
|
||||
|
||||
import org.adempiere.util.ContextRunnable;
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.apps.DesktopRunnable;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.part.WindowContainer;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
|
@ -34,32 +36,26 @@ import org.zkoss.zk.ui.Executions;
|
|||
public class ZkReportViewerProvider implements ReportViewerProvider {
|
||||
|
||||
public void openViewer(final ReportEngine report) {
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Window viewer = new ZkReportViewer(report, report.getName());
|
||||
|
||||
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
|
||||
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
|
||||
viewer.setAttribute(WindowContainer.DEFER_SET_SELECTED_TAB, Boolean.TRUE);
|
||||
SessionManager.getAppDesktop().showWindow(viewer);
|
||||
}
|
||||
};
|
||||
|
||||
// IDEMPIERE-2499
|
||||
// detect ui thread by value of Executions.getCurrent(), not office method but work
|
||||
if (Executions.getCurrent() != null){
|
||||
Adempiere.getThreadPoolExecutor().submit(new ContextRunnable(){
|
||||
protected void doRun(){
|
||||
// load layout, with big report it's heavy job, do in non ui thread to don't lock gui
|
||||
report.getLayout();
|
||||
AEnv.executeAsyncDesktopTask(runnable);
|
||||
openReportViewWindow (report);
|
||||
}else {
|
||||
AEnv.executeAsyncDesktopTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
openReportViewWindow (report);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
// load layout in non ui thread before run into ui thread
|
||||
report.getLayout();
|
||||
AEnv.executeAsyncDesktopTask(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
protected void openReportViewWindow (ReportEngine report) {
|
||||
Window viewer = new ZkReportViewer(report, report.getName());
|
||||
|
||||
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
|
||||
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
|
||||
viewer.setAttribute(WindowContainer.DEFER_SET_SELECTED_TAB, Boolean.TRUE);
|
||||
SessionManager.getAppDesktop().showWindow(viewer);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue