From 2a2c8a2e2c6938f5e0752cb7fc07feb462af54c1 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Fri, 30 Nov 2012 01:12:26 +0800 Subject: [PATCH] http://jira.idempiere.com/browse/IDEMPIERE-520 --- .../webui/adwindow/CompositeADTabbox.java | 4 +- .../adempiere/webui/adwindow/DetailPane.java | 4 +- .../webui/desktop/TabbedDesktop.java | 68 ++++++++++--------- 3 files changed, 42 insertions(+), 34 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java index f2f71bb0bf..be9bd17eac 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java @@ -206,7 +206,9 @@ public class CompositeADTabbox extends AbstractADTabbox @Override public void onEvent(Event event) throws Exception { ExecutionCtrl ctrl = (ExecutionCtrl) Executions.getCurrent(); - if (ctrl.getNextEvent() != null) { + Event evt = ctrl.getNextEvent(); + if (evt != null) { + Events.sendEvent(evt); Events.postEvent(new Event(ON_POST_INIT_EVENT, layout)); return; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java index 846110213d..b48298ec75 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java @@ -398,7 +398,9 @@ public class DetailPane extends Panel implements EventListener { updateProcessToolbar(); } else if (event.getName().equals(ON_REDRAW_EVENT)) { ExecutionCtrl ctrl = (ExecutionCtrl) Executions.getCurrent(); - if (ctrl.getNextEvent() != null) { + Event evt = ctrl.getNextEvent(); + if (evt != null) { + Events.sendEvent(evt); Events.postEvent(new Event(ON_REDRAW_EVENT, this)); return; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java index d05f180e04..73f2b92b89 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java @@ -15,10 +15,8 @@ package org.adempiere.webui.desktop; import java.io.IOException; import java.util.List; -import java.util.concurrent.TimeUnit; import org.adempiere.util.Callback; -import org.adempiere.util.ContextRunnable; import org.adempiere.webui.adwindow.ADWindow; import org.adempiere.webui.apps.ProcessDialog; import org.adempiere.webui.apps.wf.WFPanel; @@ -28,10 +26,7 @@ import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Window; import org.adempiere.webui.panel.ADForm; import org.adempiere.webui.part.WindowContainer; -import org.adempiere.webui.util.IServerPushCallback; -import org.adempiere.webui.util.ServerPushTemplate; import org.adempiere.webui.window.WTask; -import org.compiere.Adempiere; import org.compiere.model.MQuery; import org.compiere.model.MTask; import org.compiere.util.Env; @@ -40,6 +35,9 @@ import org.compiere.wf.MWorkflow; import org.zkoss.image.AImage; import org.zkoss.util.media.AMedia; 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.Iframe; import org.zkoss.zul.Tab; import org.zkoss.zul.Tabpanels; @@ -138,8 +136,14 @@ public abstract class TabbedDesktop extends AbstractDesktop { final Tab tab = windowContainer.addWindow(tabPanel, adWindow.getTitle(), true); tab.setImage(IN_PROGRESS_IMAGE); tab.setClosable(false); - OpenWindowRunnable runnable = new OpenWindowRunnable(adWindow, tab, tabPanel, callback); - Adempiere.getThreadPoolExecutor().schedule(runnable, 10, TimeUnit.MILLISECONDS); + final OpenWindowRunnable runnable = new OpenWindowRunnable(adWindow, tab, tabPanel, callback); + tabPanel.addEventListener("onOpenWindow", new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + runnable.run(); + } + }); + Events.echoEvent(new Event("onOpenWindow", tabPanel)); } /** @@ -222,8 +226,14 @@ public abstract class TabbedDesktop extends AbstractDesktop { final Tab tab = windowContainer.insertAfter(windowContainer.getSelectedTab(), tabPanel, wnd.getTitle(), true, true); tab.setImage(IN_PROGRESS_IMAGE); tab.setClosable(false); - OpenWindowRunnable runnable = new OpenWindowRunnable(wnd, tab, tabPanel, null); - Adempiere.getThreadPoolExecutor().schedule(runnable, 100, TimeUnit.MICROSECONDS); + final OpenWindowRunnable runnable = new OpenWindowRunnable(wnd, tab, tabPanel, null); + tabPanel.addEventListener("onOpenWindow", new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + runnable.run(); + } + }); + Events.echoEvent(new Event("onOpenWindow", tabPanel)); } /** @@ -332,7 +342,7 @@ public abstract class TabbedDesktop extends AbstractDesktop { { } - class OpenWindowRunnable extends ContextRunnable { + class OpenWindowRunnable implements Runnable { private final ADWindow adWindow; private final Tab tab; @@ -347,30 +357,24 @@ public abstract class TabbedDesktop extends AbstractDesktop { } @Override - protected void doRun() { - ServerPushTemplate template = new ServerPushTemplate(windowContainer.getComponent().getDesktop()); - template.executeAsync(new IServerPushCallback() { - @Override - public void updateUI() { - preOpenNewTab(); - if (adWindow.createPart(tabPanel) != null ) { - tab.setImage(null); - tab.setClosable(true); - if (adWindow.getMImage() != null) { - try { - AImage aImage = adWindow.getAImage(); - tab.setImageContent(aImage); - } catch (IOException e) { - } - } - if (callback != null) { - callback.onCallback(adWindow); - } - } else { - tab.onClose(); + public void run() { + preOpenNewTab(); + if (adWindow.createPart(tabPanel) != null ) { + tab.setImage(null); + tab.setClosable(true); + if (adWindow.getMImage() != null) { + try { + AImage aImage = adWindow.getAImage(); + tab.setImageContent(aImage); + } catch (IOException e) { } } - }); + if (callback != null) { + callback.onCallback(adWindow); + } + } else { + tab.onClose(); + } } } }