IDEMPIERE-144 Performance: Reduce use of modal dialog
This commit is contained in:
parent
336fd52791
commit
44fecb0ca9
|
@ -58,8 +58,16 @@ import org.zkoss.zul.Html;
|
|||
* @author arboleda - globalqss
|
||||
* - Implement ShowHelp option on processes and reports
|
||||
*/
|
||||
public class ProcessModalDialog extends Window implements EventListener, IProcessMonitor
|
||||
public class ProcessModalDialog extends Window implements EventListener<Event>, IProcessMonitor
|
||||
{
|
||||
private static final String ON_STATUS_UPDATE = "onStatusUpdate";
|
||||
private static final String ON_COMPLETE = "onComplete";
|
||||
|
||||
/**
|
||||
* on modal close event, use this for highlight mode modal dialog to perform action after the modal dialog closed.
|
||||
*/
|
||||
public final static String ON_MODAL_CLOSE = "onModalClose";
|
||||
|
||||
/**
|
||||
* generated serial version ID
|
||||
*/
|
||||
|
@ -140,7 +148,7 @@ public class ProcessModalDialog extends Window implements EventListener, IProces
|
|||
centerPanel = new Panel();
|
||||
dialogBody.appendChild(centerPanel);
|
||||
div = new Div();
|
||||
div.setAlign("right");
|
||||
div.setStyle("text-align: right");
|
||||
Hbox hbox = new Hbox();
|
||||
Button btn = new Button("Ok");
|
||||
LayoutUtils.addSclass("action-text-button", btn);
|
||||
|
@ -167,6 +175,7 @@ public class ProcessModalDialog extends Window implements EventListener, IProces
|
|||
private StringBuffer m_messageText = new StringBuffer();
|
||||
private String m_ShowHelp = null; // Determine if a Help Process Window is shown
|
||||
private boolean m_valid = true;
|
||||
private boolean m_cancel = false;
|
||||
|
||||
private Panel centerPanel = null;
|
||||
private Html message = null;
|
||||
|
@ -181,7 +190,6 @@ public class ProcessModalDialog extends Window implements EventListener, IProces
|
|||
private boolean isLocked = false;
|
||||
private org.adempiere.webui.apps.ProcessModalDialog.ProcessDialogRunnable processDialogRunnable;
|
||||
private Thread thread;
|
||||
private String statusUpdate;
|
||||
|
||||
/**
|
||||
* Set Visible
|
||||
|
@ -212,6 +220,14 @@ public class ProcessModalDialog extends Window implements EventListener, IProces
|
|||
return m_valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if user have press the cancel button to close the dialog
|
||||
*/
|
||||
public boolean isCancel()
|
||||
{
|
||||
return m_cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic Init
|
||||
* @return true, if there is something to process (start from menu)
|
||||
|
@ -351,35 +367,6 @@ public class ProcessModalDialog extends Window implements EventListener, IProces
|
|||
processDialogRunnable = new ProcessDialogRunnable(p);
|
||||
thread = new Thread(processDialogRunnable);
|
||||
thread.start();
|
||||
|
||||
Clients.response(new AuEcho(this, "checkProgress", null));
|
||||
}
|
||||
|
||||
public void checkProgress() {
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.interrupted();
|
||||
}
|
||||
if (thread.isAlive()) {
|
||||
synchronized(this) {
|
||||
if (statusUpdate != null) {
|
||||
if (progressWindow != null)
|
||||
progressWindow.statusUpdate(statusUpdate);
|
||||
statusUpdate = null;
|
||||
}
|
||||
}
|
||||
Clients.response(new AuEcho(this, "checkProgress", null));
|
||||
} else {
|
||||
Env.getCtx().putAll(processDialogRunnable.getProperties());
|
||||
thread = null;
|
||||
processDialogRunnable = null;
|
||||
dispose();
|
||||
if (m_processMonitor != null) {
|
||||
m_processMonitor.unlockUI(m_pi);
|
||||
}
|
||||
unlockUI(m_pi);
|
||||
}
|
||||
}
|
||||
|
||||
private void hideBusyDialog() {
|
||||
|
@ -397,13 +384,45 @@ public class ProcessModalDialog extends Window implements EventListener, IProces
|
|||
if (component instanceof Button) {
|
||||
Button element = (Button)component;
|
||||
if ("Ok".equalsIgnoreCase(element.getId())) {
|
||||
this.startProcess();
|
||||
onOK();
|
||||
} else if ("Cancel".equalsIgnoreCase(element.getId())) {
|
||||
this.dispose();
|
||||
onCancel();
|
||||
}
|
||||
} else if (event.getName().equals(ON_STATUS_UPDATE)) {
|
||||
onStatusUpdate(event);
|
||||
} else if (event.getName().equals(ON_COMPLETE)) {
|
||||
onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
this.startProcess();
|
||||
}
|
||||
|
||||
private void onCancel() {
|
||||
m_cancel = true;
|
||||
this.dispose();
|
||||
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
|
||||
}
|
||||
|
||||
private void onStatusUpdate(Event event) {
|
||||
String message = (String) event.getData();
|
||||
if (progressWindow != null)
|
||||
progressWindow.statusUpdate(message);
|
||||
}
|
||||
|
||||
private void onComplete() {
|
||||
Env.getCtx().putAll(processDialogRunnable.getProperties());
|
||||
thread = null;
|
||||
processDialogRunnable = null;
|
||||
dispose();
|
||||
if (m_processMonitor != null) {
|
||||
m_processMonitor.unlockUI(m_pi);
|
||||
}
|
||||
unlockUI(m_pi);
|
||||
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lockUI(ProcessInfo pi) {
|
||||
if (isLocked || Executions.getCurrent() == null)
|
||||
|
@ -429,7 +448,15 @@ public class ProcessModalDialog extends Window implements EventListener, IProces
|
|||
|
||||
@Override
|
||||
public void statusUpdate(String message) {
|
||||
statusUpdate = message;
|
||||
Executions.schedule(getDesktop(), this, new Event(ON_STATUS_UPDATE, this, message));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return ProcessInfo
|
||||
*/
|
||||
public ProcessInfo getProcessInfo() {
|
||||
return m_pi;
|
||||
}
|
||||
|
||||
class ProcessDialogRunnable implements Runnable {
|
||||
|
@ -446,6 +473,7 @@ public class ProcessModalDialog extends Window implements EventListener, IProces
|
|||
WProcessCtl.process(ProcessModalDialog.this, m_WindowNo, parameterPanel, m_pi, null);
|
||||
} finally {
|
||||
ServerContext.dispose();
|
||||
Executions.schedule(getDesktop(), ProcessModalDialog.this, new Event(ON_COMPLETE, ProcessModalDialog.this, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ import org.zkoss.zul.Menupopup;
|
|||
* https://sourceforge.net/tracker/?func=detail&aid=2985892&group_id=176962&atid=955896
|
||||
*/
|
||||
public abstract class AbstractADWindowPanel extends AbstractUIPart implements ToolbarListener,
|
||||
EventListener, DataStatusListener, ActionListener, IProcessMonitor
|
||||
EventListener<Event>, DataStatusListener, ActionListener, IProcessMonitor
|
||||
{
|
||||
private static final CLogger logger;
|
||||
|
||||
|
@ -777,7 +777,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
|
||||
m_lock = new Menuitem(Msg.translate(Env.getCtx(), "Lock"));
|
||||
m_popup.appendChild(m_lock);
|
||||
m_lock.addEventListener(Events.ON_CLICK, new EventListener()
|
||||
m_lock.addEventListener(Events.ON_CLICK, new EventListener<Event>()
|
||||
{
|
||||
public void onEvent(Event event) throws Exception
|
||||
{
|
||||
|
@ -790,7 +790,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
|
||||
m_access = new Menuitem(Msg.translate(Env.getCtx(), "RecordAccessDialog"));
|
||||
m_popup.appendChild(m_access);
|
||||
m_access.addEventListener(Events.ON_CLICK, new EventListener()
|
||||
m_access.addEventListener(Events.ON_CLICK, new EventListener<Event>()
|
||||
{
|
||||
public void onEvent(Event event) throws Exception
|
||||
{
|
||||
|
@ -1760,7 +1760,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
messagePanel.appendChild(listbox);
|
||||
|
||||
Div div = new Div();
|
||||
div.setAlign("center");
|
||||
div.setStyle("text-align: center");
|
||||
messagePanel.appendChild(div);
|
||||
|
||||
Hbox hbox = new Hbox();
|
||||
|
@ -1769,9 +1769,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
Button btnOk = new Button();
|
||||
btnOk.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "OK")));
|
||||
btnOk.setImage("/images/Ok16.png");
|
||||
btnOk.addEventListener(Events.ON_CLICK, new EventListener()
|
||||
btnOk.addEventListener(Events.ON_CLICK, new EventListener<Event>()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
public void onEvent(Event event) throws Exception
|
||||
{
|
||||
if (FDialog.ask(curWindowNo, messagePanel, "DeleteSelection"))
|
||||
|
@ -1812,7 +1811,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
Button btnCancel = new Button();
|
||||
btnCancel.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Cancel")));
|
||||
btnCancel.setImage("/images/Cancel16.png");
|
||||
btnCancel.addEventListener(Events.ON_CLICK, new EventListener()
|
||||
btnCancel.addEventListener(Events.ON_CLICK, new EventListener<Event>()
|
||||
{
|
||||
public void onEvent(Event event) throws Exception
|
||||
{
|
||||
|
@ -2247,9 +2246,19 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
dialog.setWidth("500px");
|
||||
dialog.setVisible(true);
|
||||
dialog.setPosition("center");
|
||||
dialog.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
||||
dialog.addEventListener(ProcessModalDialog.ON_MODAL_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
onRefresh(false);
|
||||
}
|
||||
});
|
||||
AEnv.showWindow(dialog);
|
||||
}
|
||||
onRefresh(false);
|
||||
else
|
||||
{
|
||||
onRefresh(false);
|
||||
}
|
||||
}
|
||||
} // actionButton
|
||||
|
||||
|
|
Loading…
Reference in New Issue