From 916b0dc1ec82a86fdbbbe44d69df81bfce2846c7 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 29 May 2012 00:35:45 -0500 Subject: [PATCH] IDEMPIERE-282 Swing displaying labels for non-displayed parameters --- .../src/org/compiere/apps/ProcessDialog.java | 3 ++- .../org/compiere/apps/ProcessModalDialog.java | 5 +++-- .../compiere/apps/ProcessParameterPanel.java | 20 ++++++++++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessDialog.java b/org.adempiere.ui.swing/src/org/compiere/apps/ProcessDialog.java index d012dc951b..0ea0621ce4 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessDialog.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/ProcessDialog.java @@ -73,7 +73,7 @@ public class ProcessDialog extends CFrame /** * */ - private static final long serialVersionUID = 790447068287846414L; + private static final long serialVersionUID = 7486479305726277406L; /** * @deprecated @@ -318,6 +318,7 @@ public class ProcessDialog extends CFrame 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.setWindow(this); centerPanel.removeAll(); if (parameterPanel.init()) { // hasfields diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessModalDialog.java b/org.adempiere.ui.swing/src/org/compiere/apps/ProcessModalDialog.java index cb23ee749e..47e333cdb9 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessModalDialog.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/ProcessModalDialog.java @@ -57,11 +57,11 @@ import org.compiere.util.Msg; public class ProcessModalDialog extends CDialog implements ActionListener { - + /** * */ - private static final long serialVersionUID = 6613814452809135635L; + private static final long serialVersionUID = -1573751323319156081L; /** * Dialog to start a process/report @@ -303,6 +303,7 @@ public class ProcessModalDialog extends CDialog 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.setWindow(this); centerPanel.removeAll(); if (parameterPanel.init()) { // hasfields diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessParameterPanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/ProcessParameterPanel.java index d980f71237..c61b110224 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessParameterPanel.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/ProcessParameterPanel.java @@ -18,6 +18,7 @@ import java.awt.Component; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; +import java.awt.Window; import java.beans.PropertyChangeEvent; import java.beans.PropertyVetoException; import java.beans.VetoableChangeListener; @@ -63,7 +64,7 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe /** * */ - private static final long serialVersionUID = 4042260793108029845L; + private static final long serialVersionUID = 3871379020889713432L; /** * Dynamic generated Parameter panel. @@ -103,10 +104,12 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe private ArrayList m_mFields = new ArrayList(); private ArrayList m_mFields2 = new ArrayList(); private ArrayList m_separators = new ArrayList(); + private ArrayList m_labels = new ArrayList(); // private BorderLayout mainLayout = new BorderLayout(); private CPanel centerPanel = new CPanel(); private GridBagLayout centerLayout = new GridBagLayout(); + private Window m_win = null; /** * Static Layout @@ -129,6 +132,7 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe m_mFields.clear(); m_mFields2.clear(); m_separators.clear(); + m_labels.clear(); this.removeAll(); } // dispose @@ -298,6 +302,7 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe gbc.insets = labelInset; centerPanel.add(label, gbc); } + m_labels.add(label); // Field Preparation gbc.insets = fieldInset; @@ -438,6 +443,7 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe **/ public void dynamicDisplay() { Component[] comps = centerPanel.getComponents(); + boolean changedSize = false; for (int i = 0; i < comps.length; i++) { Component comp = comps[i]; if (comp instanceof CLabel) @@ -450,7 +456,9 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe if (m_mFields.get(index).isDisplayed(true)) { // check // context if (!comp.isVisible()) { + changedSize = true; comp.setVisible(true); // visibility + m_labels.get(index).setVisible(true); if (m_mFields.get(index).getVO().isRange) m_separators.get(index).setText(" - "); } @@ -460,7 +468,9 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe m_vEditors2.get(index).setReadWrite(rw); } else { if (comp.isVisible()) { + changedSize = true; comp.setVisible(false); + m_labels.get(index).setVisible(false); if (m_mFields.get(index).getVO().isRange) m_separators.get(index).setText(""); } @@ -468,6 +478,10 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe } } } + if (m_win != null && changedSize) { + m_win.pack(); + m_win.setLocationRelativeTo(null); + } } // Dynamic Display. /** @@ -633,4 +647,8 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe f.restoreValue(); } } + + public void setWindow(Window win) { + m_win = win; + } } // ProcessParameterPanel