From 38cb19d2a5a3cc8345c08baf558d9847d03d047f Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 1 Dec 2008 02:49:47 +0000 Subject: [PATCH] [ 2171273 ] Parameter (in Report&Process) with dynamic validation [ 2175857 ] Parameter (in Report&Process) have no ZoomIn Improve process dialog layout Allow user to run the processs and report again --- .../src/org/adempiere/webui/Desktop.java | 38 +++-- .../adempiere/webui/apps/ProcessDialog.java | 50 ++++--- .../webui/apps/ProcessParameterPanel.java | 135 +++++++++++++++--- .../org/adempiere/webui/editor/WEditor.java | 26 ++++ .../org/adempiere/webui/panel/ADTabpanel.java | 21 +-- .../org/adempiere/webui/window/ADWindow.java | 3 +- 6 files changed, 206 insertions(+), 67 deletions(-) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java index 35c36800f3..b90d50598a 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java @@ -94,6 +94,8 @@ import org.zkoss.zul.Tabpanels; public class Desktop extends AbstractUIPart implements MenuListener, Serializable, IDesktop, EventListener { + public static final String WINDOWNO_ATTRIBUTE = "desktop.windowno"; + private static final long serialVersionUID = 9056511175189603883L; private static final CLogger logger = CLogger.getCLogger(Desktop.class); @@ -625,10 +627,11 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl public ProcessDialog openProcessDialog(int processId, boolean soTrx) { ProcessDialog pd = new ProcessDialog (processId, soTrx); if (pd.isValid()) { - pd.setPage(page); - pd.setClosable(true); - pd.setWidth("500px"); - pd.doHighlighted(); + DesktopTabpanel tabPanel = new DesktopTabpanel(); + pd.setParent(tabPanel); + String title = pd.getTitle(); + pd.setTitle(null); + windowContainer.addWindow(tabPanel, title, true); } return pd; } @@ -925,14 +928,26 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl */ public boolean closeActiveWindow() { - if ( windowContainer.closeActiveWindow() ) + if (windowContainer.getSelectedTab() != null) { - return true; - } - else - { - return false; + Tabpanel panel = (Tabpanel) windowContainer.getSelectedTab().getLinkedPanel(); + Component component = panel.getFirstChild(); + Object att = component.getAttribute(WINDOWNO_ATTRIBUTE); + if (att != null && (att instanceof Integer)) + if ( windowContainer.closeActiveWindow() ) + { + if (att != null && (att instanceof Integer)) + { + unregisterWindow((Integer) att); + } + return true; + } + else + { + return false; + } } + return false; } /** @@ -957,7 +972,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl { Tabpanel panel = (Tabpanel) child; Component component = panel.getFirstChild(); - Object att = component.getAttribute("desktop.windowno"); + Object att = component.getAttribute(WINDOWNO_ATTRIBUTE); if (att != null && (att instanceof Integer)) { if (windowNo == (Integer)att) @@ -966,6 +981,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl panel.getLinkedTab().onClose(); if (tab.getParent() == null) { + unregisterWindow(windowNo); return true; } else diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java index a78adff99f..3c084f4e66 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.webui.Desktop; import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.VerticalBox; @@ -40,7 +41,6 @@ import org.zkoss.zul.Html; import com.lowagie.text.Document; import com.lowagie.text.pdf.PdfContentByte; -import com.lowagie.text.pdf.PdfCopy; import com.lowagie.text.pdf.PdfImportedPage; import com.lowagie.text.pdf.PdfReader; import com.lowagie.text.pdf.PdfWriter; @@ -94,6 +94,7 @@ public class ProcessDialog extends Window implements EventListener//, ASyncProce log.info("Process=" + AD_Process_ID ); m_ctx = Env.getCtx();; m_WindowNo = SessionManager.getAppDesktop().registerWindow(this); + this.setAttribute(Desktop.WINDOWNO_ATTRIBUTE, m_WindowNo); m_AD_Process_ID = AD_Process_ID; Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", isSOTrx ? "Y" : "N"); try @@ -118,9 +119,9 @@ public class ProcessDialog extends Window implements EventListener//, ASyncProce centerPanel = new Panel(); vbox.appendChild(centerPanel); div = new Div(); - div.setAlign("right"); + div.setAlign("center"); Hbox hbox = new Hbox(); - String label = Msg.getMsg(Env.getCtx(), "Ok"); + String label = Msg.getMsg(Env.getCtx(), "Start"); bOK = new Button(label.replaceAll("&", "")); bOK.setImage("/images/Ok16.png"); bOK.setId("Ok"); @@ -136,15 +137,14 @@ public class ProcessDialog extends Window implements EventListener//, ASyncProce hbox.appendChild(btn); div.appendChild(hbox); vbox.appendChild(div); - this.appendChild(vbox); - - this.setBorder("normal"); + this.appendChild(vbox); } private int m_WindowNo; private Properties m_ctx; private int m_AD_Process_ID; private String m_Name = null; + @SuppressWarnings("unused") private boolean m_IsReport = false; private int[] m_ids = null; private StringBuffer m_messageText = new StringBuffer(); @@ -163,6 +163,8 @@ public class ProcessDialog extends Window implements EventListener//, ASyncProce private ProcessInfo m_pi = null; private boolean m_isLocked = false; + private boolean isResult; + private String initialMessage; /** @@ -180,10 +182,8 @@ public class ProcessDialog extends Window implements EventListener//, ASyncProce */ public void dispose() { - Env.clearWinContext(m_WindowNo); - SessionManager.getAppDesktop().unregisterWindow(m_WindowNo); + SessionManager.getAppDesktop().closeWindow(m_WindowNo); valid = false; - this.detach(); }// dispose /** @@ -242,14 +242,15 @@ public class ProcessDialog extends Window implements EventListener//, ASyncProce return false; // this.setTitle(m_Name); - message.setContent(m_messageText.toString()); + initialMessage = m_messageText.toString(); + message.setContent(initialMessage); bOK.setLabel(Msg.getMsg(Env.getCtx(), "Start")); // Move from APanel.actionButton m_pi = new ProcessInfo(m_Name, m_AD_Process_ID); m_pi.setAD_User_ID (Env.getAD_User_ID(Env.getCtx())); m_pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx())); - parameterPanel = new ProcessParameterPanel(m_WindowNo, m_pi); + parameterPanel = new ProcessParameterPanel(m_WindowNo, m_pi, "70%"); centerPanel.getChildren().clear(); if ( parameterPanel.init() ) { centerPanel.appendChild(parameterPanel); @@ -303,10 +304,10 @@ public class ProcessDialog extends Window implements EventListener//, ASyncProce if (component instanceof Button) { Button element = (Button)component; if ("Ok".equalsIgnoreCase(element.getId())) { - if (element.getLabel().length() > 0) + if (!isResult) this.startProcess(); else - this.dispose(); + restart(); } else if ("Cancel".equalsIgnoreCase(element.getId())) { this.dispose(); } @@ -377,24 +378,37 @@ public class ProcessDialog extends Window implements EventListener//, ASyncProce m_messageText.append(pi.getLogInfo(true)); message.setContent(m_messageText.toString()); - bOK.setLabel(""); + bOK.setLabel(Msg.getMsg(Env.getCtx(), "Parameter")); + bOK.setImage("/images/Reset16.png"); + isResult = true; m_ids = pi.getIDs(); //no longer needed, hide to give more space to display log - centerPanel.detach(); + centerPanel.setVisible(false); invalidate(); Clients.response(new AuEcho(this, "onAfterProcess", null)); } + private void restart() { + m_messageText = new StringBuffer(initialMessage); + message.setContent(initialMessage); + + centerPanel.setVisible(true); + + isResult = false; + + bOK.setLabel(Msg.getMsg(Env.getCtx(), "Start")); + bOK.setImage("/images/Ok16.png"); + + invalidate(); + } + public void onAfterProcess() { // afterProcessTask(); - // Close automatically - if (m_IsReport && !m_pi.isError()) - this.dispose(); // If the process is a silent one and no errors occured, close the dialog if(m_ShowHelp != null && m_ShowHelp.equals("S")) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java index 90ddbec7f4..492f4a295a 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java @@ -24,13 +24,17 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.logging.Level; +import org.adempiere.webui.component.Column; +import org.adempiere.webui.component.Columns; import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.GridFactory; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.editor.WEditor; +import org.adempiere.webui.editor.WEditorPopupMenu; import org.adempiere.webui.editor.WebEditorFactory; +import org.adempiere.webui.event.ContextMenuListener; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.window.FDialog; @@ -58,23 +62,50 @@ import org.zkoss.zul.Label; public class ProcessParameterPanel extends Panel implements ValueChangeListener, IProcessParameter { + private String width; + /** * Dynamic generated Parameter panel. * @param WindowNo window * @param pi process info */ public ProcessParameterPanel(int WindowNo, ProcessInfo pi) + { + this(WindowNo, pi, "100%"); + } // ProcessParameterPanel + + /** + * Dynamic generated Parameter panel. + * @param WindowNo window + * @param pi process info + */ + public ProcessParameterPanel(int WindowNo, ProcessInfo pi, String width) { // m_WindowNo = WindowNo; m_processInfo = pi; + this.width = width; // initComponent(); } // ProcessParameterPanel private void initComponent() { centerPanel = GridFactory.newGridLayout(); + centerPanel.setInnerWidth(width); this.appendChild(centerPanel); + + //setup columns + Columns columns = new Columns(); + centerPanel.appendChild(columns); + Column col = new Column(); + col.setWidth("30%"); + columns.appendChild(col); + col = new Column(); + col.setWidth("65%"); + columns.appendChild(col); + col = new Column(); + col.setWidth("5%"); + columns.appendChild(col); } private int m_WindowNo; @@ -87,6 +118,7 @@ implements ValueChangeListener, IProcessParameter private ArrayList m_wEditors2 = new ArrayList(); // for ranges private ArrayList m_mFields = new ArrayList(); private ArrayList m_mFields2 = new ArrayList(); + private ArrayList