From 517506f75a4fe556d167a77796f5012af540eb9e Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Thu, 27 Dec 2007 10:24:41 +0000 Subject: [PATCH] [ 1855851 ] Propose New Look for Collapseable Field Group - cleanup and javadoc --- client/src/org/compiere/grid/VPanel.java | 42 ++++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/client/src/org/compiere/grid/VPanel.java b/client/src/org/compiere/grid/VPanel.java index ecf7294132..343ac3918d 100644 --- a/client/src/org/compiere/grid/VPanel.java +++ b/client/src/org/compiere/grid/VPanel.java @@ -94,6 +94,7 @@ public final class VPanel extends CTabbedPane m_gbc.ipadx = 0; m_gbc.ipady = 0; + //set up map used for label and field alignment labels.put(0, new ArrayList()); labels.put(2, new ArrayList()); @@ -138,6 +139,8 @@ public final class VPanel extends CTabbedPane private HashMap> fillers = new HashMap>(); + private HashMap collapsibleEndFiller = new HashMap(); + /** Logger */ private static CLogger log = CLogger.getCLogger (VPanel.class); @@ -258,6 +261,8 @@ public final class VPanel extends CTabbedPane m_gbc.insets = m_firstLabelInset; m_tab.getCollapsiblePane().getContentPane().add(label, m_gbc); labels.get(m_gbc.gridx).add(label); + + moveCollapsibleEndFiller(m_tab.getCollapsiblePane()); } else // Label or null { @@ -295,6 +300,8 @@ public final class VPanel extends CTabbedPane m_tab.getCollapsiblePane().getContentPane().add(field, m_gbc); if (!mField.isLongField()) fields.get(m_gbc.gridx).add(field); + + moveCollapsibleEndFiller(m_tab.getCollapsiblePane()); } else // Label or null { @@ -310,6 +317,23 @@ public final class VPanel extends CTabbedPane } } // addField + /** + * Move the end spacer of the collapsible pane + * @param collapsiblePane + */ + private void moveCollapsibleEndFiller(JXCollapsiblePane collapsiblePane) { + Component end = collapsibleEndFiller.get(collapsiblePane); + if (end != null) { + collapsiblePane.getContentPane().remove(end); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridheight = 1; + gbc.gridwidth = 1; + gbc.gridx = 0; + gbc.gridy = m_gbc.gridy + 1; + collapsiblePane.getContentPane().add(end, gbc); + } + } + /** * Add Group * @param fieldGroup field group @@ -388,6 +412,10 @@ public final class VPanel extends CTabbedPane return true; } // addGroup + /** + * Set up the grid bag layout of collapsible pane + * @param m_tab + */ private void setupCollapsiblePaneLayout(JXCollapsiblePane m_tab) { m_tab.getContentPane().setLayout(new GridBagLayout()); @@ -428,14 +456,14 @@ public final class VPanel extends CTabbedPane fields.get(3).add(label); m_tab.getContentPane().add(label, gbc); - gbc.gridheight = 2; - gbc.gridy = 99; + Component c = Box.createVerticalStrut(3); + gbc.gridheight = 1; + gbc.gridy = GridBagConstraints.RELATIVE; gbc.gridx = 0; gbc.weightx = 0; - m_tab.getContentPane().add(Box.createVerticalStrut(1), gbc); - - JPanel p = (JPanel)m_tab.getContentPane(); - + gbc.insets = m_zeroInset; + m_tab.getContentPane().add(c, gbc); + collapsibleEndFiller.put(m_tab, c); } /** @@ -733,6 +761,7 @@ public final class VPanel extends CTabbedPane @Override public void doLayout() { + //align labels int w = 0; Collection clabels = labels.get(0); for (CLabel l : clabels) { @@ -794,6 +823,7 @@ public final class VPanel extends CTabbedPane } } + //align fields w = 0; Collection collection = fields.get(1); for (Component c : collection) {