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; package org.adempiere.webui.adwindow;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Tabbox;
import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.panel.ITabOnCloseHandler; import org.adempiere.webui.panel.ITabOnCloseHandler;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -162,24 +159,9 @@ public class ADWindowContent extends AbstractADWindowContent
class TabOnCloseHanlder implements ITabOnCloseHandler { class TabOnCloseHanlder implements ITabOnCloseHandler {
public void onClose(Tabpanel tabPanel) { public void onClose(Tabpanel tabPanel) {
if (ADWindowContent.this.onExit()) { if (ADWindowContent.this.onExit()) {
Tab tab = tabPanel.getLinkedTab(); Tab tab = tabPanel.getLinkedTab();
Tabbox tabbox = (Tabbox) tab.getTabbox(); tab.close();
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();
if (getWindowNo() > 0) if (getWindowNo() > 0)
SessionManager.getAppDesktop().unregisterWindow(getWindowNo()); SessionManager.getAppDesktop().unregisterWindow(getWindowNo());
} }

View File

@ -850,15 +850,24 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
EventListener<Event> listener = new EventListener<Event>() { EventListener<Event> listener = new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
adTabbox.getSelectedGridTab().loadAttachments(); // reload adTabbox.getSelectedGridTab().loadAttachments(); // reload
toolbar.getButton("Attachment").setPressed(adTabbox.getSelectedGridTab().hasAttachment()); toolbar.getButton("Attachment").setPressed(adTabbox.getSelectedGridTab().hasAttachment());
focusToActivePanel(); focusToActivePanel();
} }
}; };
// Attachment va = // Attachment va =
new WAttachment ( curWindowNo, adTabbox.getSelectedGridTab().getAD_AttachmentID(), WAttachment win = new WAttachment ( curWindowNo, adTabbox.getSelectedGridTab().getAD_AttachmentID(),
adTabbox.getSelectedGridTab().getAD_Table_ID(), record_ID, null, listener); 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() 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); 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>() { chat.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
adTabbox.getSelectedGridTab().loadChats(); adTabbox.getSelectedGridTab().loadChats();
toolbar.getButton("Chat").setPressed(adTabbox.getSelectedGridTab().hasChat()); toolbar.getButton("Chat").setPressed(adTabbox.getSelectedGridTab().hasChat());
focusToActivePanel(); focusToActivePanel();
Clients.clearBusy(getComponent());
} }
}); });
getComponent().getParent().appendChild(chat);
Clients.showBusy(getComponent(), " ");
LayoutUtils.openOverlappedWindow(getComponent(), chat, "middle_center");
chat.showWindow(); chat.showWindow();
} }
@ -969,6 +982,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
boolean b = breadCrumb.getStatusError(); boolean b = breadCrumb.getStatusError();
onRefresh(true, false); onRefresh(true, false);
breadCrumb.setStatusLine(s, b); breadCrumb.setStatusLine(s, b);
Clients.clearBusy(getComponent());
} }
else if (ADTabpanel.ON_DYNAMIC_DISPLAY_EVENT.equals(event.getName())) 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.setPack("end");
hbox.setHflex("1"); hbox.setHflex("1");
messagePanel.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
messagePanel.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() { messagePanel.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
focusToActivePanel(); 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); ProcessModalDialog dialog = new ProcessModalDialog(AbstractADWindowContent.this, getWindowNo(), AD_Process_ID,table_ID, record_ID, true);
if (dialog.isValid()) { if (dialog.isValid()) {
dialog.setPosition("center"); dialog.setWidth("500px");
dialog.setPage(AbstractADWindowContent.this.getComponent().getPage()); dialog.setBorder("normal");
dialog.doHighlighted(); 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; final int recordIdParam = record_ID;
getComponent().getParent().appendChild(win); getComponent().getParent().appendChild(win);
win.setStyle("position: absolute;");
win.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() { win.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
Clients.clearBusy(getComponent()); Clients.clearBusy(getComponent());
if (!win.isStartProcess()) { if (!win.isStartProcess()) {
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent()));
return; return;
} }
boolean startWOasking = true; boolean startWOasking = true;
@ -2360,15 +2376,13 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
{ {
Clients.showBusy(getComponent(), " "); Clients.showBusy(getComponent(), " ");
final WCreateFromWindow window = (WCreateFromWindow) cf.getWindow(); final WCreateFromWindow window = (WCreateFromWindow) cf.getWindow();
window.setStyle("position: absolute");
window.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() { window.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
Clients.clearBusy(getComponent());
if (!window.isCancel()) { if (!window.isCancel()) {
onRefresh(true, false); onRefresh(true, false);
} }
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent())); Clients.clearBusy(getComponent());
} }
}); });
getComponent().getParent().appendChild(window); getComponent().getParent().appendChild(window);
@ -2512,13 +2526,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (mode == Mode.HIGHLIGHTED || mode == Mode.MODAL) { if (mode == Mode.HIGHLIGHTED || mode == Mode.MODAL) {
form.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() { form.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
Clients.clearBusy(getComponent());
onRefresh(true, false); onRefresh(true, false);
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent())); Clients.clearBusy(getComponent());
} }
}); });
form.setStyle("position: absolute;");
getComponent().getParent().appendChild(form); getComponent().getParent().appendChild(form);
Clients.showBusy(getComponent(), " "); Clients.showBusy(getComponent(), " ");
LayoutUtils.openOverlappedWindow(getComponent(), form, "middle_center"); LayoutUtils.openOverlappedWindow(getComponent(), form, "middle_center");
@ -2533,7 +2545,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (dialog.isValid()) if (dialog.isValid())
{ {
dialog.setStyle("position: absolute;");
dialog.setWidth("500px"); dialog.setWidth("500px");
dialog.setBorder("normal"); dialog.setBorder("normal");
Clients.showBusy(getComponent(), " "); Clients.showBusy(getComponent(), " ");
@ -2637,12 +2648,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (Executions.getCurrent() != null) if (Executions.getCurrent() != null)
{ {
Clients.clearBusy(getComponent());
if (notPrint) // refresh if not print if (notPrint) // refresh if not print
{ {
updateUI(pi); updateUI(pi);
} }
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent()));
} }
else else
{ {
@ -2650,12 +2659,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
//acquire desktop, 2 second timeout //acquire desktop, 2 second timeout
Executions.activate(getComponent().getDesktop(), 2000); Executions.activate(getComponent().getDesktop(), 2000);
try { try {
Clients.clearBusy(getComponent());
if (notPrint) // refresh if not print if (notPrint) // refresh if not print
{ {
updateUI(pi); updateUI(pi);
} }
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent()));
} catch(Error ex){ } catch(Error ex){
throw ex; throw ex;
} finally{ } finally{

View File

@ -17,8 +17,6 @@
package org.adempiere.webui.component; package org.adempiere.webui.component;
import java.util.List;
import org.adempiere.webui.panel.ITabOnCloseHandler; import org.adempiere.webui.panel.ITabOnCloseHandler;
import org.zkoss.zul.Tab; import org.zkoss.zul.Tab;
@ -66,20 +64,7 @@ public class Tabpanel extends org.zkoss.zul.Tabpanel
onCloseHandler.onClose(this); onCloseHandler.onClose(this);
else { else {
Tab tab = this.getLinkedTab(); Tab tab = this.getLinkedTab();
Tabbox tabbox = (Tabbox) tab.getTabbox(); tab.close();
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();
} }
} }

View File

@ -186,8 +186,6 @@ public class WAttachment extends Window implements EventListener<Event>
Clients.response(new AuScript(null, script)); Clients.response(new AuScript(null, script));
} }
//enter modal
doHighlighted();
} }
catch (Exception e) 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.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Div; import org.zkoss.zul.Div;
import org.zkoss.zul.Filedownload; import org.zkoss.zul.Filedownload;
import org.zkoss.zul.Hbox; import org.zkoss.zul.Hbox;
@ -93,6 +94,7 @@ public class ReportAction implements EventListener<Event>
winReport.setClosable(true); winReport.setClosable(true);
winReport.setBorder("normal"); winReport.setBorder("normal");
winReport.setStyle("position:absolute"); winReport.setStyle("position:absolute");
winReport.addEventListener("onValidate", this);
cboPrintFormat.setMold("select"); cboPrintFormat.setMold("select");
cboPrintFormat.getItems().clear(); cboPrintFormat.getItems().clear();
@ -162,7 +164,6 @@ public class ReportAction implements EventListener<Event>
confirmPanel.addActionListener(this); confirmPanel.addActionListener(this);
} }
winReport.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
LayoutUtils.openPopupWindow(panel.getToolbar().getButton("Report"), winReport, "after_start"); 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 { public void onEvent(Event event) throws Exception {
if(event.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) if(event.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
winReport.onClose(); winReport.onClose();
else if(event.getTarget().getId().equals(ConfirmPanel.A_OK)) else if(event.getTarget().getId().equals(ConfirmPanel.A_OK)) {
validate(); winReport.setVisible(false);
Clients.showBusy(panel.getComponent(), null);
Events.echoEvent("onValidate", winReport, null);
}
else if(event.getTarget() == cboPrintFormat) else if(event.getTarget() == cboPrintFormat)
{ {
ListItem li = cboPrintFormat.getSelectedItem(); ListItem li = cboPrintFormat.getSelectedItem();
@ -183,6 +187,10 @@ public class ReportAction implements EventListener<Event>
} }
else if(event.getTarget() == chkExport) else if(event.getTarget() == chkExport)
cboExportType.setVisible(chkExport.isChecked()); cboExportType.setVisible(chkExport.isChecked());
else if (event.getName().equals("onValidate")) {
validate();
Clients.clearBusy(panel.getComponent());
}
} }
private void validate() private void validate()

View File

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

View File

@ -2,7 +2,6 @@ package org.adempiere.webui.window;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -18,9 +17,7 @@ import net.sf.jasperreports.engine.export.JRXlsExporterParameter;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Tabbox;
import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.panel.ITabOnCloseHandler; import org.adempiere.webui.panel.ITabOnCloseHandler;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
@ -222,20 +219,7 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
@Override @Override
public void onClose(Tabpanel tabPanel) { public void onClose(Tabpanel tabPanel) {
Tab tab = tabPanel.getLinkedTab(); Tab tab = tabPanel.getLinkedTab();
Tabbox tabbox = (Tabbox) tab.getTabbox(); tab.close();
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();
cleanUp(); cleanUp();
} }

View File

@ -24,7 +24,6 @@ import java.io.StringWriter;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; 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.Label;
import org.adempiere.webui.component.ListItem; import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Tabbox;
import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.event.DialogEvents;
@ -615,20 +612,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
@Override @Override
public void onClose(Tabpanel tabPanel) { public void onClose(Tabpanel tabPanel) {
Tab tab = tabPanel.getLinkedTab(); Tab tab = tabPanel.getLinkedTab();
Tabbox tabbox = (Tabbox) tab.getTabbox(); tab.close();
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();
cleanUp(); cleanUp();
} }