Heng Sin Low 2012-11-30 01:12:26 +08:00
parent f9f09d0b9c
commit 2a2c8a2e2c
3 changed files with 42 additions and 34 deletions

View File

@ -206,7 +206,9 @@ public class CompositeADTabbox extends AbstractADTabbox
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
ExecutionCtrl ctrl = (ExecutionCtrl) Executions.getCurrent(); 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)); Events.postEvent(new Event(ON_POST_INIT_EVENT, layout));
return; return;
} }

View File

@ -398,7 +398,9 @@ public class DetailPane extends Panel implements EventListener<Event> {
updateProcessToolbar(); updateProcessToolbar();
} else if (event.getName().equals(ON_REDRAW_EVENT)) { } else if (event.getName().equals(ON_REDRAW_EVENT)) {
ExecutionCtrl ctrl = (ExecutionCtrl) Executions.getCurrent(); 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)); Events.postEvent(new Event(ON_REDRAW_EVENT, this));
return; return;
} }

View File

@ -15,10 +15,8 @@ package org.adempiere.webui.desktop;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import org.adempiere.util.Callback; import org.adempiere.util.Callback;
import org.adempiere.util.ContextRunnable;
import org.adempiere.webui.adwindow.ADWindow; import org.adempiere.webui.adwindow.ADWindow;
import org.adempiere.webui.apps.ProcessDialog; import org.adempiere.webui.apps.ProcessDialog;
import org.adempiere.webui.apps.wf.WFPanel; 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.component.Window;
import org.adempiere.webui.panel.ADForm; import org.adempiere.webui.panel.ADForm;
import org.adempiere.webui.part.WindowContainer; 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.adempiere.webui.window.WTask;
import org.compiere.Adempiere;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MTask; import org.compiere.model.MTask;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -40,6 +35,9 @@ import org.compiere.wf.MWorkflow;
import org.zkoss.image.AImage; import org.zkoss.image.AImage;
import org.zkoss.util.media.AMedia; import org.zkoss.util.media.AMedia;
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.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Iframe; import org.zkoss.zul.Iframe;
import org.zkoss.zul.Tab; import org.zkoss.zul.Tab;
import org.zkoss.zul.Tabpanels; import org.zkoss.zul.Tabpanels;
@ -138,8 +136,14 @@ public abstract class TabbedDesktop extends AbstractDesktop {
final Tab tab = windowContainer.addWindow(tabPanel, adWindow.getTitle(), true); final Tab tab = windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
tab.setImage(IN_PROGRESS_IMAGE); tab.setImage(IN_PROGRESS_IMAGE);
tab.setClosable(false); tab.setClosable(false);
OpenWindowRunnable runnable = new OpenWindowRunnable(adWindow, tab, tabPanel, callback); final OpenWindowRunnable runnable = new OpenWindowRunnable(adWindow, tab, tabPanel, callback);
Adempiere.getThreadPoolExecutor().schedule(runnable, 10, TimeUnit.MILLISECONDS); tabPanel.addEventListener("onOpenWindow", new EventListener<Event>() {
@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); final Tab tab = windowContainer.insertAfter(windowContainer.getSelectedTab(), tabPanel, wnd.getTitle(), true, true);
tab.setImage(IN_PROGRESS_IMAGE); tab.setImage(IN_PROGRESS_IMAGE);
tab.setClosable(false); tab.setClosable(false);
OpenWindowRunnable runnable = new OpenWindowRunnable(wnd, tab, tabPanel, null); final OpenWindowRunnable runnable = new OpenWindowRunnable(wnd, tab, tabPanel, null);
Adempiere.getThreadPoolExecutor().schedule(runnable, 100, TimeUnit.MICROSECONDS); tabPanel.addEventListener("onOpenWindow", new EventListener<Event>() {
@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 ADWindow adWindow;
private final Tab tab; private final Tab tab;
@ -347,11 +357,7 @@ public abstract class TabbedDesktop extends AbstractDesktop {
} }
@Override @Override
protected void doRun() { public void run() {
ServerPushTemplate template = new ServerPushTemplate(windowContainer.getComponent().getDesktop());
template.executeAsync(new IServerPushCallback() {
@Override
public void updateUI() {
preOpenNewTab(); preOpenNewTab();
if (adWindow.createPart(tabPanel) != null ) { if (adWindow.createPart(tabPanel) != null ) {
tab.setImage(null); tab.setImage(null);
@ -370,7 +376,5 @@ public abstract class TabbedDesktop extends AbstractDesktop {
tab.onClose(); tab.onClose();
} }
} }
});
}
} }
} }