diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WRequest.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WRequest.java index 1800482da7..75ef08fa81 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WRequest.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WRequest.java @@ -18,6 +18,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.logging.Level; +import org.adempiere.util.Callback; import org.adempiere.webui.adwindow.ADWindow; import org.adempiere.webui.session.SessionManager; import org.compiere.model.GridTab; @@ -57,7 +58,7 @@ import org.zkoss.zul.Menupopup; * @author Teo Sarca, SC ARHIPAC SERVICE SRL *
  • BF [ 1904928 ] Request: Related Request field not filled */ -public class WRequest implements EventListener +public class WRequest implements EventListener { /** * Constructor @@ -180,7 +181,7 @@ public class WRequest implements EventListener m_popup.open(invoker); } // getZoomTargets - public void onEvent(Event e) throws Exception + public void onEvent(final Event e) throws Exception { if (e.getTarget() instanceof Menuitem) { @@ -206,60 +207,68 @@ public class WRequest implements EventListener } int AD_Window_ID = WINDOW_REQUESTS_ALL; // 232=all - 201=my - ADWindow frame = SessionManager.getAppDesktop().openWindow(AD_Window_ID, query); - if(frame == null) - return; - // New - set Table/Record - if (e.getTarget() == m_new) - { - GridTab tab = frame.getADWindowContent().getActiveGridTab(); - tab.dataNew (false); - tab.setValue("AD_Table_ID", new Integer(m_AD_Table_ID)); - tab.setValue("Record_ID", new Integer(m_Record_ID)); - // - if (m_C_BPartner_ID != 0) - tab.setValue("C_BPartner_ID", new Integer(m_C_BPartner_ID)); - // - if (m_AD_Table_ID == MBPartner.Table_ID) - tab.setValue("C_BPartner_ID", new Integer(m_Record_ID)); - else if (m_AD_Table_ID == MUser.Table_ID) - tab.setValue("AD_User_ID", new Integer(m_Record_ID)); - // - else if (m_AD_Table_ID == MProject.Table_ID) - tab.setValue("C_Project_ID", new Integer(m_Record_ID)); - else if (m_AD_Table_ID == MAsset.Table_ID) - tab.setValue("A_Asset_ID", new Integer(m_Record_ID)); - // - else if (m_AD_Table_ID == MOrder.Table_ID) - tab.setValue("C_Order_ID", new Integer(m_Record_ID)); - else if (m_AD_Table_ID == MInvoice.Table_ID) - tab.setValue("C_Invoice_ID", new Integer(m_Record_ID)); - // - else if (m_AD_Table_ID == MProduct.Table_ID) - tab.setValue("M_Product_ID", new Integer(m_Record_ID)); - else if (m_AD_Table_ID == MPayment.Table_ID) - tab.setValue("C_Payment_ID", new Integer(m_Record_ID)); - // - else if (m_AD_Table_ID == MInOut.Table_ID) - tab.setValue("M_InOut_ID", new Integer(m_Record_ID)); - else if (m_AD_Table_ID == MRMA.Table_ID) - tab.setValue("M_RMA_ID", new Integer(m_Record_ID)); - // - else if (m_AD_Table_ID == MCampaign.Table_ID) - tab.setValue("C_Campaign_ID", new Integer(m_Record_ID)); - // - else if (m_AD_Table_ID == MRequest.Table_ID) - tab.setValue(MRequest.COLUMNNAME_R_RequestRelated_ID, new Integer(m_Record_ID)); - // FR [2842165] - Order Ref link from SO line creating new request - else if (m_AD_Table_ID == MOrderLine.Table_ID) { - MOrderLine oLine = new MOrderLine(Env.getCtx(), m_Record_ID, null); - if (oLine != null) { - tab.setValue(MOrderLine.COLUMNNAME_C_Order_ID, new Integer(oLine.getC_Order_ID())); - } + SessionManager.getAppDesktop().openWindow(AD_Window_ID, query, new Callback() { + + @Override + public void onCallback(ADWindow result) { + if(result == null) + return; + + onNew(e, result); + } + }); + } + } + + private void onNew(Event e, ADWindow frame) { + // New - set Table/Record + if (e.getTarget() == m_new) + { + GridTab tab = frame.getADWindowContent().getActiveGridTab(); + tab.dataNew (false); + tab.setValue("AD_Table_ID", new Integer(m_AD_Table_ID)); + tab.setValue("Record_ID", new Integer(m_Record_ID)); + // + if (m_C_BPartner_ID != 0) + tab.setValue("C_BPartner_ID", new Integer(m_C_BPartner_ID)); + // + if (m_AD_Table_ID == MBPartner.Table_ID) + tab.setValue("C_BPartner_ID", new Integer(m_Record_ID)); + else if (m_AD_Table_ID == MUser.Table_ID) + tab.setValue("AD_User_ID", new Integer(m_Record_ID)); + // + else if (m_AD_Table_ID == MProject.Table_ID) + tab.setValue("C_Project_ID", new Integer(m_Record_ID)); + else if (m_AD_Table_ID == MAsset.Table_ID) + tab.setValue("A_Asset_ID", new Integer(m_Record_ID)); + // + else if (m_AD_Table_ID == MOrder.Table_ID) + tab.setValue("C_Order_ID", new Integer(m_Record_ID)); + else if (m_AD_Table_ID == MInvoice.Table_ID) + tab.setValue("C_Invoice_ID", new Integer(m_Record_ID)); + // + else if (m_AD_Table_ID == MProduct.Table_ID) + tab.setValue("M_Product_ID", new Integer(m_Record_ID)); + else if (m_AD_Table_ID == MPayment.Table_ID) + tab.setValue("C_Payment_ID", new Integer(m_Record_ID)); + // + else if (m_AD_Table_ID == MInOut.Table_ID) + tab.setValue("M_InOut_ID", new Integer(m_Record_ID)); + else if (m_AD_Table_ID == MRMA.Table_ID) + tab.setValue("M_RMA_ID", new Integer(m_Record_ID)); + // + else if (m_AD_Table_ID == MCampaign.Table_ID) + tab.setValue("C_Campaign_ID", new Integer(m_Record_ID)); + // + else if (m_AD_Table_ID == MRequest.Table_ID) + tab.setValue(MRequest.COLUMNNAME_R_RequestRelated_ID, new Integer(m_Record_ID)); + // FR [2842165] - Order Ref link from SO line creating new request + else if (m_AD_Table_ID == MOrderLine.Table_ID) { + MOrderLine oLine = new MOrderLine(Env.getCtx(), m_Record_ID, null); + if (oLine != null) { + tab.setValue(MOrderLine.COLUMNNAME_C_Order_ID, new Integer(oLine.getC_Order_ID())); } } - - frame = null; } } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java index c5ac1ec68c..fc738eb6a2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java @@ -273,7 +273,7 @@ public class WFPanel extends Borderlayout implements EventListener private void start(MWFNode wfn) { if (wfn.getAD_Window_ID() > 0) { - SessionManager.getAppDesktop().openWindow(wfn.getAD_Window_ID()); + SessionManager.getAppDesktop().openWindow(wfn.getAD_Window_ID(), null); } else if (wfn.getAD_Form_ID() > 0) { SessionManager.getAppDesktop().openForm(wfn.getAD_Form_ID()); } else if (wfn.getAD_Process_ID() > 0) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPFavourites.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPFavourites.java index 6b45d0d3ab..17f1581114 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPFavourites.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPFavourites.java @@ -15,6 +15,7 @@ package org.adempiere.webui.dashboard; import java.util.Enumeration; +import org.adempiere.util.Callback; import org.adempiere.webui.adwindow.ADWindow; import org.adempiere.webui.exception.ApplicationException; import org.adempiere.webui.panel.TreeSearchPanel; @@ -285,12 +286,17 @@ public class DPFavourites extends DashboardPanel implements EventListener query.addRestriction("1=2"); query.setRecordCount(0); - ADWindow frame = SessionManager.getAppDesktop().openWindow(menu.getAD_Window_ID(), query); - if(frame == null) - return; - - GridTab tab = frame.getADWindowContent().getActiveGridTab(); - tab.dataNew(false); + SessionManager.getAppDesktop().openWindow(menu.getAD_Window_ID(), query, new Callback() { + + @Override + public void onCallback(ADWindow result) { + if(result == null) + return; + + GridTab tab = result.getADWindowContent().getActiveGridTab(); + tab.dataNew(false); + } + }); } catch (Exception e) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java index c764bff879..4de02ac58e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java @@ -148,7 +148,7 @@ public class DPRecentItems extends DashboardPanel implements EventListener callback); /** * @@ -150,7 +151,7 @@ public interface IDesktop extends UIPart { * @param query * @return ADWindow */ - public ADWindow openWindow(int windowId, MQuery query); + public void openWindow(int windowId, MQuery query, Callback callback); /** * Open operating system task window 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 51ef74592e..d05f180e04 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 @@ -17,6 +17,7 @@ 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; @@ -120,8 +121,8 @@ public abstract class TabbedDesktop extends AbstractDesktop { * @param windowId * @return ADWindow */ - public ADWindow openWindow(int windowId) { - return openWindow(windowId, null); + public void openWindow(int windowId, Callback callback) { + openWindow(windowId, null, callback); } /** @@ -130,17 +131,15 @@ public abstract class TabbedDesktop extends AbstractDesktop { * @param query * @return ADWindow */ - public ADWindow openWindow(int windowId, MQuery query) { + public void openWindow(int windowId, MQuery query, Callback callback) { final ADWindow adWindow = new ADWindow(Env.getCtx(), windowId, query); final DesktopTabpanel tabPanel = new DesktopTabpanel(); final Tab tab = windowContainer.addWindow(tabPanel, adWindow.getTitle(), true); tab.setImage(IN_PROGRESS_IMAGE); tab.setClosable(false); - OpenWindowRunnable runnable = new OpenWindowRunnable(adWindow, tab, tabPanel); - Adempiere.getThreadPoolExecutor().schedule(runnable, 100, TimeUnit.MICROSECONDS); - - return adWindow; + OpenWindowRunnable runnable = new OpenWindowRunnable(adWindow, tab, tabPanel, callback); + Adempiere.getThreadPoolExecutor().schedule(runnable, 10, TimeUnit.MILLISECONDS); } /** @@ -223,7 +222,7 @@ 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); + OpenWindowRunnable runnable = new OpenWindowRunnable(wnd, tab, tabPanel, null); Adempiere.getThreadPoolExecutor().schedule(runnable, 100, TimeUnit.MICROSECONDS); } @@ -234,7 +233,7 @@ public abstract class TabbedDesktop extends AbstractDesktop { */ public void showWindow(int AD_Window_ID, MQuery query) { - openWindow(AD_Window_ID, query); + openWindow(AD_Window_ID, query, null); } /** @@ -338,19 +337,17 @@ public abstract class TabbedDesktop extends AbstractDesktop { private final ADWindow adWindow; private final Tab tab; private final DesktopTabpanel tabPanel; + private Callback callback; - protected OpenWindowRunnable(ADWindow adWindow, Tab tab, DesktopTabpanel tabPanel) { + protected OpenWindowRunnable(ADWindow adWindow, Tab tab, DesktopTabpanel tabPanel, Callback callback) { this.adWindow = adWindow; this.tab = tab; this.tabPanel = tabPanel; + this.callback = callback; } @Override protected void doRun() { - try { - Thread.sleep(1); - } catch (InterruptedException e) { - } ServerPushTemplate template = new ServerPushTemplate(windowContainer.getComponent().getDesktop()); template.executeAsync(new IServerPushCallback() { @Override @@ -366,6 +363,9 @@ public abstract class TabbedDesktop extends AbstractDesktop { } catch (IOException e) { } } + if (callback != null) { + callback.onCallback(adWindow); + } } else { tab.onClose(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractMenuPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractMenuPanel.java index ece46840cf..aba84a8d40 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractMenuPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractMenuPanel.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.Enumeration; import java.util.Properties; +import org.adempiere.util.Callback; import org.adempiere.webui.adwindow.ADWindow; import org.adempiere.webui.exception.ApplicationException; import org.adempiere.webui.session.SessionManager; @@ -297,12 +298,16 @@ public abstract class AbstractMenuPanel extends Panel implements EventListener() { + @Override + public void onCallback(ADWindow result) { + if(result == null) + return; + + GridTab tab = result.getADWindowContent().getActiveGridTab(); + tab.dataNew(false); + } + }); } catch (Exception e) {