IDEMPIERE-522 Zk: Random Freeze of screen update. Modify process and form to only block the parent window instead of the whole browser.

This commit is contained in:
Heng Sin Low 2012-12-04 16:50:17 +08:00
parent b6fd81b23c
commit e1115bd294
8 changed files with 49 additions and 105 deletions

View File

@ -23,13 +23,10 @@
package org.adempiere.webui.adwindow;
import java.util.List;
import java.util.Properties;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Tabbox;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.panel.ITabOnCloseHandler;
import org.adempiere.webui.session.SessionManager;
import org.compiere.util.CLogger;
@ -162,24 +159,9 @@ public class ADWindowContent extends AbstractADWindowContent
class TabOnCloseHanlder implements ITabOnCloseHandler {
public void onClose(Tabpanel tabPanel) {
if (ADWindowContent.this.onExit()) {
if (ADWindowContent.this.onExit()) {
Tab tab = tabPanel.getLinkedTab();
Tabbox tabbox = (Tabbox) tab.getTabbox();
if (tabbox.getSelectedTab() == tab) {
Tabs tabs = (Tabs) tabbox.getTabs();
List<?> childs = tabs.getChildren();
for(int i = 0; i < childs.size(); i++) {
if (childs.get(i) == tab) {
if (i > 0)
tabbox.setSelectedIndex((i-1));
break;
}
}
} else {
tabbox.getSelectedPanel().invalidate();
}
tabPanel.detach();
tab.detach();
tab.close();
if (getWindowNo() > 0)
SessionManager.getAppDesktop().unregisterWindow(getWindowNo());
}

View File

@ -850,15 +850,24 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
EventListener<Event> listener = new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
public void onEvent(Event event) throws Exception {
adTabbox.getSelectedGridTab().loadAttachments(); // reload
toolbar.getButton("Attachment").setPressed(adTabbox.getSelectedGridTab().hasAttachment());
focusToActivePanel();
focusToActivePanel();
}
};
// Attachment va =
new WAttachment ( curWindowNo, adTabbox.getSelectedGridTab().getAD_AttachmentID(),
adTabbox.getSelectedGridTab().getAD_Table_ID(), record_ID, null, listener);
WAttachment win = new WAttachment ( curWindowNo, adTabbox.getSelectedGridTab().getAD_AttachmentID(),
adTabbox.getSelectedGridTab().getAD_Table_ID(), record_ID, null, listener);
win.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
Clients.clearBusy(getComponent());
}
});
getComponent().getParent().appendChild(win);
Clients.showBusy(getComponent(), " ");
LayoutUtils.openOverlappedWindow(getComponent(), win, "middle_center");
}
public void onChat()
@ -890,12 +899,16 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
WChat chat = new WChat(curWindowNo, adTabbox.getSelectedGridTab().getCM_ChatID(), adTabbox.getSelectedGridTab().getAD_Table_ID(), recordId, description, null);
chat.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
public void onEvent(Event event) throws Exception {
adTabbox.getSelectedGridTab().loadChats();
toolbar.getButton("Chat").setPressed(adTabbox.getSelectedGridTab().hasChat());
focusToActivePanel();
Clients.clearBusy(getComponent());
}
});
getComponent().getParent().appendChild(chat);
Clients.showBusy(getComponent(), " ");
LayoutUtils.openOverlappedWindow(getComponent(), chat, "middle_center");
chat.showWindow();
}
@ -969,6 +982,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
boolean b = breadCrumb.getStatusError();
onRefresh(true, false);
breadCrumb.setStatusLine(s, b);
Clients.clearBusy(getComponent());
}
else if (ADTabpanel.ON_DYNAMIC_DISPLAY_EVENT.equals(event.getName()))
{
@ -2023,14 +2037,16 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
hbox.setPack("end");
hbox.setHflex("1");
messagePanel.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
messagePanel.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
public void onEvent(Event event) throws Exception {
focusToActivePanel();
Clients.clearBusy(getComponent());
}
});
AEnv.showWindow(messagePanel);
getComponent().getParent().appendChild(messagePanel);
Clients.showBusy(getComponent(), " ");
LayoutUtils.openOverlappedWindow(getComponent(), messagePanel, "middle_center");
}
//
@ -2059,9 +2075,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
ProcessModalDialog dialog = new ProcessModalDialog(AbstractADWindowContent.this, getWindowNo(), AD_Process_ID,table_ID, record_ID, true);
if (dialog.isValid()) {
dialog.setPosition("center");
dialog.setPage(AbstractADWindowContent.this.getComponent().getPage());
dialog.doHighlighted();
dialog.setWidth("500px");
dialog.setBorder("normal");
Clients.showBusy(getComponent(), " ");
getComponent().getParent().appendChild(dialog);
LayoutUtils.openOverlappedWindow(getComponent(), dialog, "middle_center");
}
}
}
@ -2329,12 +2347,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
{
final int recordIdParam = record_ID;
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;
@ -2360,15 +2376,13 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
{
Clients.showBusy(getComponent(), " ");
final WCreateFromWindow window = (WCreateFromWindow) cf.getWindow();
window.setStyle("position: absolute");
window.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
Clients.clearBusy(getComponent());
public void onEvent(Event event) throws Exception {
if (!window.isCancel()) {
onRefresh(true, false);
}
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent()));
Clients.clearBusy(getComponent());
}
});
getComponent().getParent().appendChild(window);
@ -2512,13 +2526,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (mode == Mode.HIGHLIGHTED || mode == Mode.MODAL) {
form.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
Clients.clearBusy(getComponent());
public void onEvent(Event event) throws Exception {
onRefresh(true, false);
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent()));
Clients.clearBusy(getComponent());
}
});
form.setStyle("position: absolute;");
getComponent().getParent().appendChild(form);
Clients.showBusy(getComponent(), " ");
LayoutUtils.openOverlappedWindow(getComponent(), form, "middle_center");
@ -2533,7 +2545,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (dialog.isValid())
{
dialog.setStyle("position: absolute;");
dialog.setWidth("500px");
dialog.setBorder("normal");
Clients.showBusy(getComponent(), " ");
@ -2637,12 +2648,10 @@ 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
{
@ -2650,12 +2659,10 @@ 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

@ -17,8 +17,6 @@
package org.adempiere.webui.component;
import java.util.List;
import org.adempiere.webui.panel.ITabOnCloseHandler;
import org.zkoss.zul.Tab;
@ -66,20 +64,7 @@ public class Tabpanel extends org.zkoss.zul.Tabpanel
onCloseHandler.onClose(this);
else {
Tab tab = this.getLinkedTab();
Tabbox tabbox = (Tabbox) tab.getTabbox();
if (tabbox.getSelectedTab() == tab) {
Tabs tabs = (Tabs) tabbox.getTabs();
List childs = tabs.getChildren();
for(int i = 0; i < childs.size(); i++) {
if (childs.get(i) == tab) {
if (i > 0)
tabbox.setSelectedIndex((i-1));
break;
}
}
}
this.detach();
tab.detach();
tab.close();
}
}

View File

@ -186,8 +186,6 @@ public class WAttachment extends Window implements EventListener<Event>
Clients.response(new AuScript(null, script));
}
//enter modal
doHighlighted();
}
catch (Exception e)
{

View File

@ -53,6 +53,7 @@ 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;
@ -93,6 +94,7 @@ public class ReportAction implements EventListener<Event>
winReport.setClosable(true);
winReport.setBorder("normal");
winReport.setStyle("position:absolute");
winReport.addEventListener("onValidate", this);
cboPrintFormat.setMold("select");
cboPrintFormat.getItems().clear();
@ -162,7 +164,6 @@ public class ReportAction implements EventListener<Event>
confirmPanel.addActionListener(this);
}
winReport.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
LayoutUtils.openPopupWindow(panel.getToolbar().getButton("Report"), winReport, "after_start");
}
@ -170,8 +171,11 @@ public class ReportAction implements EventListener<Event>
public void onEvent(Event event) throws Exception {
if(event.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
winReport.onClose();
else if(event.getTarget().getId().equals(ConfirmPanel.A_OK))
validate();
else if(event.getTarget().getId().equals(ConfirmPanel.A_OK)) {
winReport.setVisible(false);
Clients.showBusy(panel.getComponent(), null);
Events.echoEvent("onValidate", winReport, null);
}
else if(event.getTarget() == cboPrintFormat)
{
ListItem li = cboPrintFormat.getSelectedItem();
@ -183,6 +187,10 @@ public class ReportAction implements EventListener<Event>
}
else if(event.getTarget() == chkExport)
cboExportType.setVisible(chkExport.isChecked());
else if (event.getName().equals("onValidate")) {
validate();
Clients.clearBusy(panel.getComponent());
}
}
private void validate()

View File

@ -22,7 +22,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label;
@ -40,7 +39,6 @@ import org.compiere.util.Util;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.Div;
@ -109,8 +107,6 @@ public class WChat extends Window implements EventListener<Event>, DialogEvents
public void showWindow()
{
this.setAttribute(MODE_KEY, MODE_HIGHLIGHTED);
AEnv.showWindow(this);
newText.focus();
}

View File

@ -2,7 +2,6 @@ package org.adempiere.webui.window;
import java.io.File;
import java.io.FileOutputStream;
import java.util.List;
import java.util.logging.Level;
import javax.servlet.http.HttpServletRequest;
@ -18,9 +17,7 @@ import net.sf.jasperreports.engine.export.JRXlsExporterParameter;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Tabbox;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.panel.ITabOnCloseHandler;
import org.adempiere.webui.session.SessionManager;
@ -222,20 +219,7 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
@Override
public void onClose(Tabpanel tabPanel) {
Tab tab = tabPanel.getLinkedTab();
Tabbox tabbox = (Tabbox) tab.getTabbox();
if (tabbox.getSelectedTab() == tab) {
Tabs tabs = (Tabs) tabbox.getTabs();
List<?> childs = tabs.getChildren();
for(int i = 0; i < childs.size(); i++) {
if (childs.get(i) == tab) {
if (i > 0)
tabbox.setSelectedIndex((i-1));
break;
}
}
}
tabPanel.detach();
tab.detach();
tab.close();
cleanUp();
}

View File

@ -24,7 +24,6 @@ import java.io.StringWriter;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@ -41,9 +40,7 @@ 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.Tabbox;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
@ -615,20 +612,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
@Override
public void onClose(Tabpanel tabPanel) {
Tab tab = tabPanel.getLinkedTab();
Tabbox tabbox = (Tabbox) tab.getTabbox();
if (tabbox.getSelectedTab() == tab) {
Tabs tabs = (Tabs) tabbox.getTabs();
List<?> childs = tabs.getChildren();
for(int i = 0; i < childs.size(); i++) {
if (childs.get(i) == tab) {
if (i > 0)
tabbox.setSelectedIndex((i-1));
break;
}
}
}
tabPanel.detach();
tab.detach();
tab.close();
cleanUp();
}