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,9 +338,9 @@ public class ReportEngine implements PrintServiceAttributeListener
|
||||||
*/
|
*/
|
||||||
public Properties getCtx()
|
public Properties getCtx()
|
||||||
{
|
{
|
||||||
return getLayout().getCtx();
|
return m_ctx;
|
||||||
} // getCtx
|
} // getCtx
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Row Count
|
* Get Row Count
|
||||||
* @return row count
|
* @return row count
|
||||||
|
|
|
@ -229,9 +229,6 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
||||||
m_ctx = m_reportEngine.getCtx();
|
m_ctx = m_reportEngine.getCtx();
|
||||||
init();
|
init();
|
||||||
dynInit();
|
dynInit();
|
||||||
|
|
||||||
if (!ArchiveEngine.isValid(m_reportEngine.getLayout()))
|
|
||||||
log.warning("Cannot archive Document");
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
@ -467,7 +464,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
||||||
future = Adempiere.getThreadPoolExecutor().submit(new DesktopRunnable(new XLSRendererRunnable(this),getDesktop()));
|
future = Adempiere.getThreadPoolExecutor().submit(new DesktopRunnable(new XLSRendererRunnable(this),getDesktop()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPreviewReport() {
|
private void onPreviewReport() {
|
||||||
try {
|
try {
|
||||||
if (future != null) {
|
if (future != null) {
|
||||||
|
@ -1306,6 +1303,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
||||||
@Override
|
@Override
|
||||||
protected void doRun() {
|
protected void doRun() {
|
||||||
try {
|
try {
|
||||||
|
if (!ArchiveEngine.isValid(viewer.m_reportEngine.getLayout()))
|
||||||
|
log.warning("Cannot archive Document");
|
||||||
String path = System.getProperty("java.io.tmpdir");
|
String path = System.getProperty("java.io.tmpdir");
|
||||||
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
||||||
if (log.isLoggable(Level.FINE))
|
if (log.isLoggable(Level.FINE))
|
||||||
|
@ -1351,6 +1350,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
||||||
@Override
|
@Override
|
||||||
protected void doRun() {
|
protected void doRun() {
|
||||||
try {
|
try {
|
||||||
|
if (!ArchiveEngine.isValid(viewer.m_reportEngine.getLayout()))
|
||||||
|
log.warning("Cannot archive Document");
|
||||||
String path = System.getProperty("java.io.tmpdir");
|
String path = System.getProperty("java.io.tmpdir");
|
||||||
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
||||||
if (log.isLoggable(Level.FINE))
|
if (log.isLoggable(Level.FINE))
|
||||||
|
@ -1395,6 +1396,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
||||||
@Override
|
@Override
|
||||||
protected void doRun() {
|
protected void doRun() {
|
||||||
try {
|
try {
|
||||||
|
if (!ArchiveEngine.isValid(viewer.m_reportEngine.getLayout()))
|
||||||
|
log.warning("Cannot archive Document");
|
||||||
String path = System.getProperty("java.io.tmpdir");
|
String path = System.getProperty("java.io.tmpdir");
|
||||||
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
||||||
if (log.isLoggable(Level.FINE))
|
if (log.isLoggable(Level.FINE))
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
package org.adempiere.webui.window;
|
package org.adempiere.webui.window;
|
||||||
|
|
||||||
import org.adempiere.util.ContextRunnable;
|
import org.adempiere.util.ContextRunnable;
|
||||||
|
import org.adempiere.webui.LayoutUtils;
|
||||||
import org.adempiere.webui.apps.AEnv;
|
import org.adempiere.webui.apps.AEnv;
|
||||||
|
import org.adempiere.webui.apps.DesktopRunnable;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
import org.adempiere.webui.part.WindowContainer;
|
import org.adempiere.webui.part.WindowContainer;
|
||||||
import org.adempiere.webui.session.SessionManager;
|
import org.adempiere.webui.session.SessionManager;
|
||||||
|
@ -34,32 +36,26 @@ import org.zkoss.zk.ui.Executions;
|
||||||
public class ZkReportViewerProvider implements ReportViewerProvider {
|
public class ZkReportViewerProvider implements ReportViewerProvider {
|
||||||
|
|
||||||
public void openViewer(final ReportEngine report) {
|
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
|
// IDEMPIERE-2499
|
||||||
// detect ui thread by value of Executions.getCurrent(), not office method but work
|
// detect ui thread by value of Executions.getCurrent(), not office method but work
|
||||||
if (Executions.getCurrent() != null){
|
if (Executions.getCurrent() != null){
|
||||||
Adempiere.getThreadPoolExecutor().submit(new ContextRunnable(){
|
openReportViewWindow (report);
|
||||||
protected void doRun(){
|
}else {
|
||||||
// load layout, with big report it's heavy job, do in non ui thread to don't lock gui
|
AEnv.executeAsyncDesktopTask(new Runnable() {
|
||||||
report.getLayout();
|
@Override
|
||||||
AEnv.executeAsyncDesktopTask(runnable);
|
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