IDEMPIERE-174 Performance: Use Executions.schedule instead of the Executions.activate and Executions.deactivate pair
This commit is contained in:
parent
ba7a432b62
commit
336fd52791
|
@ -14,7 +14,6 @@ import java.util.logging.Level;
|
||||||
import org.adempiere.util.IProcessMonitor;
|
import org.adempiere.util.IProcessMonitor;
|
||||||
import org.adempiere.util.ServerContext;
|
import org.adempiere.util.ServerContext;
|
||||||
import org.adempiere.webui.AdempiereWebUI;
|
import org.adempiere.webui.AdempiereWebUI;
|
||||||
import org.adempiere.webui.apps.ProcessDialog.ProcessDialogRunnable;
|
|
||||||
import org.adempiere.webui.component.Button;
|
import org.adempiere.webui.component.Button;
|
||||||
import org.adempiere.webui.component.Panel;
|
import org.adempiere.webui.component.Panel;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
|
@ -33,7 +32,6 @@ import org.compiere.util.Msg;
|
||||||
import org.zkoss.zk.au.out.AuEcho;
|
import org.zkoss.zk.au.out.AuEcho;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.Desktop;
|
import org.zkoss.zk.ui.Desktop;
|
||||||
import org.zkoss.zk.ui.Execution;
|
|
||||||
import org.zkoss.zk.ui.Executions;
|
import org.zkoss.zk.ui.Executions;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
@ -80,7 +78,7 @@ import com.lowagie.text.pdf.PdfWriter;
|
||||||
* @author arboleda - globalqss
|
* @author arboleda - globalqss
|
||||||
* - Implement ShowHelp option on processes and reports
|
* - Implement ShowHelp option on processes and reports
|
||||||
*/
|
*/
|
||||||
public class ProcessDialog extends Window implements EventListener, IProcessMonitor
|
public class ProcessDialog extends Window implements EventListener<Event>, IProcessMonitor
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* generate serial version ID
|
* generate serial version ID
|
||||||
|
@ -148,7 +146,7 @@ public class ProcessDialog extends Window implements EventListener, IProcessMoni
|
||||||
center.setStyle("border: none");
|
center.setStyle("border: none");
|
||||||
|
|
||||||
Div div = new Div();
|
Div div = new Div();
|
||||||
div.setAlign("center");
|
div.setStyle("text-align: center");
|
||||||
Hbox hbox = new Hbox();
|
Hbox hbox = new Hbox();
|
||||||
String label = Msg.getMsg(Env.getCtx(), "Start");
|
String label = Msg.getMsg(Env.getCtx(), "Start");
|
||||||
bOK = new Button(label.replaceAll("&", ""));
|
bOK = new Button(label.replaceAll("&", ""));
|
||||||
|
@ -200,9 +198,10 @@ public class ProcessDialog extends Window implements EventListener, IProcessMoni
|
||||||
private String initialMessage;
|
private String initialMessage;
|
||||||
private BusyDialog progressWindow;
|
private BusyDialog progressWindow;
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
private String statusUpdate;
|
|
||||||
private ProcessDialogRunnable processDialogRunnable;
|
private ProcessDialogRunnable processDialogRunnable;
|
||||||
|
|
||||||
|
private static final String ON_STATUS_UPDATE = "onStatusUpdate";
|
||||||
|
private static final String ON_COMPLETE = "onComplete";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Visible
|
* Set Visible
|
||||||
|
@ -336,31 +335,19 @@ public class ProcessDialog extends Window implements EventListener, IProcessMoni
|
||||||
processDialogRunnable = new ProcessDialogRunnable(p);
|
processDialogRunnable = new ProcessDialogRunnable(p);
|
||||||
thread = new Thread(processDialogRunnable);
|
thread = new Thread(processDialogRunnable);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
Clients.response(new AuEcho(this, "checkProgress", null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkProgress() {
|
private void onComplete() {
|
||||||
try {
|
Env.getCtx().putAll(processDialogRunnable.getProperties());
|
||||||
Thread.sleep(500);
|
thread = null;
|
||||||
} catch (InterruptedException e) {
|
processDialogRunnable = null;
|
||||||
Thread.interrupted();
|
unlockUI(m_pi);
|
||||||
}
|
}
|
||||||
if (thread.isAlive()) {
|
|
||||||
synchronized(this) {
|
private void onStatusUpdate(Event event) {
|
||||||
if (statusUpdate != null) {
|
String message = (String) event.getData();
|
||||||
if (progressWindow != null)
|
if (progressWindow != null)
|
||||||
progressWindow.statusUpdate(statusUpdate);
|
progressWindow.statusUpdate(message);
|
||||||
statusUpdate = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Clients.response(new AuEcho(this, "checkProgress", null));
|
|
||||||
} else {
|
|
||||||
Env.getCtx().putAll(processDialogRunnable.getProperties());
|
|
||||||
thread = null;
|
|
||||||
processDialogRunnable = null;
|
|
||||||
unlockUI(m_pi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEvent(Event event) {
|
public void onEvent(Event event) {
|
||||||
|
@ -378,6 +365,10 @@ public class ProcessDialog extends Window implements EventListener, IProcessMoni
|
||||||
} else if ("Cancel".equalsIgnoreCase(element.getId())) {
|
} else if ("Cancel".equalsIgnoreCase(element.getId())) {
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
} else if (event.getName().equals(ON_STATUS_UPDATE)) {
|
||||||
|
onStatusUpdate(event);
|
||||||
|
} else if (event.getName().equals(ON_COMPLETE)) {
|
||||||
|
onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -658,6 +649,7 @@ public class ProcessDialog extends Window implements EventListener, IProcessMoni
|
||||||
WProcessCtl.process(ProcessDialog.this, m_WindowNo, parameterPanel, m_pi, null);
|
WProcessCtl.process(ProcessDialog.this, m_WindowNo, parameterPanel, m_pi, null);
|
||||||
} finally {
|
} finally {
|
||||||
ServerContext.dispose();
|
ServerContext.dispose();
|
||||||
|
Executions.schedule(getDesktop(), ProcessDialog.this, new Event(ON_COMPLETE, ProcessDialog.this, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,6 +660,6 @@ public class ProcessDialog extends Window implements EventListener, IProcessMoni
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void statusUpdate(String message) {
|
public void statusUpdate(String message) {
|
||||||
statusUpdate = message;
|
Executions.schedule(getDesktop(), this, new Event(ON_STATUS_UPDATE, this, message));
|
||||||
}
|
}
|
||||||
} // ProcessDialog
|
} // ProcessDialog
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class ZkJRViewerProvider implements JRViewerProvider {
|
||||||
SessionManager.getAppDesktop().showWindow(viewer);
|
SessionManager.getAppDesktop().showWindow(viewer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
AEnv.executeDesktopTask(runnable);
|
AEnv.executeAsyncDesktopTask(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,6 @@ public class ZkReportViewerProvider implements ReportViewerProvider {
|
||||||
SessionManager.getAppDesktop().showWindow(viewer);
|
SessionManager.getAppDesktop().showWindow(viewer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
AEnv.executeDesktopTask(runnable);
|
AEnv.executeAsyncDesktopTask(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue