IDEMPIERE-522 Zk: Random Freeze of screen update. Modify process and form to only block the parent window instead of the whole browser. This allow user to continue using the application if the process busy dialog doesn't get close at the end for whatever reason.

This commit is contained in:
Heng Sin Low 2012-11-30 18:03:49 +08:00
parent e852eefa2e
commit a4fc8c40be
8 changed files with 74 additions and 25 deletions

View File

@ -33,6 +33,8 @@ import org.zkoss.zul.Window;
*/
public final class LayoutUtils {
public static final String ON_REDRAW_EVENT = "onRedraw";
/**
* @param layout
*/

View File

@ -91,6 +91,7 @@ import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.WebDoc;
import org.zkoss.zk.ui.AbstractComponent;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.HtmlBasedComponent;
@ -98,6 +99,7 @@ import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.sys.ExecutionCtrl;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Button;
import org.zkoss.zul.Column;
@ -208,7 +210,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
adTabbox.setSelectionEventListener(this);
adTabbox.setADWindowPanel(this);
return super.createPart(parent);
Component comp = super.createPart(parent);
comp.addEventListener(LayoutUtils.ON_REDRAW_EVENT, this);
return comp;
}
public BreadCrumb getBreadCrumb()
@ -973,6 +977,16 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
toolbar.dynamicDisplay();
}
}
else if (event.getTarget() == getComponent() && event.getName().equals(LayoutUtils.ON_REDRAW_EVENT)) {
ExecutionCtrl ctrl = (ExecutionCtrl) Executions.getCurrent();
Event evt = ctrl.getNextEvent();
if (evt != null) {
Events.sendEvent(evt);
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent()));
return;
}
LayoutUtils.redraw((AbstractComponent) getComponent());
}
}
private void setActiveTab(final int newTabIndex, final Callback<Boolean> callback) {
@ -2313,11 +2327,13 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
else
{
final int recordIdParam = record_ID;
win.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
win.setPosition("center");
getComponent().getParent().appendChild(win);
win.setStyle("position: absolute;");
win.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
public void onEvent(Event event) throws Exception {
Clients.clearBusy(getComponent());
if (!win.isStartProcess()) {
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent()));
return;
}
boolean startWOasking = true;
@ -2325,7 +2341,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
executeButtonProcess(wButton, startWOasking, table_ID, recordIdParam, isProcessMandatory);
}
});
AEnv.showWindow(win);
Clients.showBusy(getComponent(), " ");
LayoutUtils.openOverlappedWindow(getComponent(), win, "middle_center");
return;
}
} // DocAction
@ -2490,11 +2507,19 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
form.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
Clients.clearBusy(getComponent());
onRefresh(true, false);
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent()));
}
});
form.setStyle("position: absolute;");
getComponent().getParent().appendChild(form);
Clients.showBusy(getComponent(), " ");
LayoutUtils.openOverlappedWindow(getComponent(), form, "middle_center");
}
else {
SessionManager.getAppDesktop().showWindow(form);
}
SessionManager.getAppDesktop().showWindow(form);
}
else
{
@ -2502,11 +2527,12 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (dialog.isValid())
{
dialog.setStyle("position: absolute;");
dialog.setWidth("500px");
dialog.setVisible(true);
dialog.setPosition("center");
dialog.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
AEnv.showWindow(dialog);
dialog.setBorder("normal");
Clients.showBusy(getComponent(), " ");
getComponent().getParent().appendChild(dialog);
LayoutUtils.openOverlappedWindow(getComponent(), dialog, "middle_center");
}
else
{
@ -2605,10 +2631,12 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (Executions.getCurrent() != null)
{
Clients.clearBusy(getComponent());
if (notPrint) // refresh if not print
{
updateUI(pi);
}
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent()));
}
else
{
@ -2616,10 +2644,12 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
//acquire desktop, 2 second timeout
Executions.activate(getComponent().getDesktop(), 2000);
try {
Clients.clearBusy(getComponent());
if (notPrint) // refresh if not print
{
updateUI(pi);
}
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent()));
} catch(Error ex){
throw ex;
} finally{

View File

@ -55,8 +55,6 @@ import org.zkoss.zul.Vlayout;
*/
public class CompositeADTabbox extends AbstractADTabbox
{
public static final String ON_POST_INIT_EVENT = "onPostInit";
public static final String ON_SELECTION_CHANGED_EVENT = "onSelectionChanged";
/** Logger */
@ -554,7 +552,7 @@ public class CompositeADTabbox extends AbstractADTabbox
detailTab.setDetailPaneMode(true, isUseVflexForDetailPane());
detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane()));
if (!ADTabpanel.isUseSplitViewForForm() && !headerTab.isGridView()) {
Events.postEvent(new Event(DetailPane.ON_REDRAW_EVENT, detailPane));
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, detailPane));
}
}
}

View File

@ -47,8 +47,6 @@ public class DetailPane extends Panel implements EventListener<Event> {
public static final String ON_POST_SELECT_TAB_EVENT = "onPostSelectTab";
public static final String ON_REDRAW_EVENT = "onRedraw";
private static final String STATUS_TEXT_ATTRIBUTE = "status.text";
private static final String STATUS_ERROR_ATTRIBUTE = "status.error";
@ -111,7 +109,7 @@ public class DetailPane extends Panel implements EventListener<Event> {
LayoutUtils.addSclass("adwindow-detailpane-xsplit", this);
}
addEventListener(ON_REDRAW_EVENT, this);
addEventListener(LayoutUtils.ON_REDRAW_EVENT, this);
}
public int getSelectedIndex() {
@ -396,12 +394,12 @@ public class DetailPane extends Panel implements EventListener<Event> {
showPopup(error, messageContainer);
} else if (event.getName().equals(ADTabpanel.ON_DYNAMIC_DISPLAY_EVENT)) {
updateProcessToolbar();
} else if (event.getName().equals(ON_REDRAW_EVENT)) {
} else if (event.getName().equals(LayoutUtils.ON_REDRAW_EVENT)) {
ExecutionCtrl ctrl = (ExecutionCtrl) Executions.getCurrent();
Event evt = ctrl.getNextEvent();
if (evt != null) {
Events.sendEvent(evt);
Events.postEvent(new Event(ON_REDRAW_EVENT, this));
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, this));
return;
}
LayoutUtils.redraw(this);

View File

@ -21,6 +21,7 @@ import org.adempiere.util.ContextRunnable;
import org.adempiere.util.IProcessUI;
import org.adempiere.util.ServerContext;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.Window;
@ -422,9 +423,10 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
}
private void showBusyDialog() {
Clients.showBusy(this, " ");
progressWindow = new BusyDialog();
progressWindow.setPage(this.getPage());
progressWindow.doHighlighted();
progressWindow.setStyle("position: absolute;");
LayoutUtils.openOverlappedWindow(this, progressWindow, "middle_center");
}
public void unlockUI(ProcessInfo pi) {
@ -436,6 +438,7 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
}
private void hideBusyDialog() {
Clients.clearBusy(this);
if (progressWindow != null) {
progressWindow.dispose();
progressWindow = null;

View File

@ -365,6 +365,8 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
progressWindow = new BusyDialog();
this.appendChild(progressWindow);
if (this.getParent() != null)
LayoutUtils.openOverlappedWindow(this.getParent(), progressWindow, "middle_center");
}
/**

View File

@ -24,16 +24,17 @@ import java.util.Set;
import org.adempiere.base.IGridTabExporter;
import org.adempiere.base.Service;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.adwindow.AbstractADWindowContent;
import org.adempiere.webui.adwindow.IADTabbox;
import org.adempiere.webui.adwindow.IADTabpanel;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Checkbox;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.GridTab;
import org.compiere.util.Env;
@ -41,6 +42,8 @@ import org.compiere.util.Msg;
import org.zkoss.util.media.AMedia;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Div;
import org.zkoss.zul.Filedownload;
import org.zkoss.zul.Hbox;
@ -131,8 +134,10 @@ public class ExportAction implements EventListener<Event>
confirmPanel.addActionListener(this);
}
winExportFile.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
AEnv.showWindow(winExportFile);
Clients.showBusy(panel.getComponent(), " ");
panel.getComponent().getParent().appendChild(winExportFile);
LayoutUtils.openOverlappedWindow(panel.getComponent(), winExportFile, "middle_center");
winExportFile.addEventListener(DialogEvents.ON_WINDOW_CLOSE, this);
}
@Override
@ -141,6 +146,10 @@ public class ExportAction implements EventListener<Event>
winExportFile.onClose();
else if(event.getTarget().getId().equals(ConfirmPanel.A_OK))
exportFile();
else if (event.getName().equals(DialogEvents.ON_WINDOW_CLOSE)) {
Clients.clearBusy(panel.getComponent());
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, panel.getComponent()));
}
}
private void exportFile() {

View File

@ -27,16 +27,17 @@ import java.util.Set;
import org.adempiere.base.IGridTabImporter;
import org.adempiere.base.Service;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.adwindow.AbstractADWindowContent;
import org.adempiere.webui.adwindow.IADTabbox;
import org.adempiere.webui.adwindow.IADTabpanel;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.util.ReaderInputStream;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.GridTab;
@ -50,6 +51,7 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Div;
import org.zkoss.zul.Filedownload;
import org.zkoss.zul.Hbox;
@ -170,8 +172,10 @@ public class FileImportAction implements EventListener<Event>
confirmPanel.addActionListener(this);
}
winImportFile.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
AEnv.showWindow(winImportFile);
Clients.showBusy(panel.getComponent(), " ");
panel.getComponent().getParent().appendChild(winImportFile);
LayoutUtils.openOverlappedWindow(panel.getComponent(), winImportFile, "middle_center");
winImportFile.addEventListener(DialogEvents.ON_WINDOW_CLOSE, this);
}
@Override
@ -197,6 +201,9 @@ public class FileImportAction implements EventListener<Event>
if (m_file_istream == null || fCharset.getSelectedItem() == null)
return;
importFile();
} else if (event.getName().equals(DialogEvents.ON_WINDOW_CLOSE)) {
Clients.clearBusy(panel.getComponent());
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, panel.getComponent()));
}
}