From 374e23a700a35be901ccd58ec2137a4a6f723e86 Mon Sep 17 00:00:00 2001 From: Murilo Habermann Torquato Date: Mon, 15 Apr 2019 17:18:28 -0300 Subject: [PATCH] IDEMPIERE-3953 open special forms from process related to info windows --- .../src/org/adempiere/webui/panel/ADForm.java | 23 +++++++++- .../org/adempiere/webui/panel/InfoPanel.java | 43 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADForm.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADForm.java index 8f25684897..45c57c7640 100755 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADForm.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADForm.java @@ -134,11 +134,31 @@ public abstract class ADForm extends Window implements EventListener, IHe */ public static ADForm openForm (int adFormID) { - return openForm(adFormID, null); + return openForm(adFormID, null, null); } + /** + * Open a form base on it's ID + * + * @param adFormID + * @param gridTab + * @return + */ public static ADForm openForm (int adFormID, GridTab gridTab) { + return openForm(adFormID, gridTab, null); + } + + /** + * Open a form base on it's ID and a Process Info parameters + * + * @param adFormID + * @param gridTab + * @param pi + * @return + */ + public static ADForm openForm (int adFormID, GridTab gridTab, ProcessInfo pi) + { ADForm form; MForm mform = new MForm(Env.getCtx(), adFormID, null); String formName = mform.getClassname(); @@ -156,6 +176,7 @@ public abstract class ADForm extends Window implements EventListener, IHe if (form != null) { form.gridTab = gridTab; + form.setProcessInfo(pi); form.init(adFormID, name); return form; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index 8823370493..748b8007c8 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -2044,6 +2044,49 @@ public abstract class InfoPanel extends Window implements EventListener, MPInstance instance = new MPInstance(Env.getCtx(), processId, 0); instance.saveEx(); final int pInstanceID = instance.getAD_PInstance_ID(); + // devCoffee - enable use of special forms from process related with info windows + m_pi.setAD_PInstance_ID(pInstanceID); + + int adFormID = m_process.getAD_Form_ID(); + if (adFormID != 0 ) + { + String title = m_process.getName(); + if (title == null || title.length() == 0) + title = m_process.getValue(); + + // store in T_Selection table selected rows for Execute Process that retrieves from T_Selection in code. + DB.createT_SelectionNew(pInstanceID, getSaveKeys(getInfoColumnIDFromProcess(processId)), null); + + ADForm form = ADForm.openForm(adFormID, null, m_pi); + Mode mode = form.getWindowMode(); + form.setAttribute(Window.MODE_KEY, form.getWindowMode()); + form.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT); + + if (mode == Mode.HIGHLIGHTED || mode == Mode.MODAL) { + form.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + ; + } + }); + form.doHighlighted(); + form.focus(); + } + else { + form.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + updateListSelected(); + recordSelectedData.clear(); + Clients.response(new AuEcho(InfoPanel.this, "onQueryCallback", null)); + onUserQuery(); + } + }); + + SessionManager.getAppDesktop().showWindow(form); + } + return; + } // Execute Process m_pi.setAD_PInstance_ID(pInstanceID); m_pi.setAD_InfoWindow_ID(infoWindow.getAD_InfoWindow_ID());