Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[albireo-dev] A small fix to address layout issues

I discovered a problem where SWT layouts were not being calculated properly when one of the controls was a SwingControl.

When we pass Swing's min/max/preferred sizes back to SWT during validateTree(), we have been querying the JRootPane. It turns out that JRootPane returns an unexpected width value for getMaximumSize(). It is always 0, and that can cause problems during the SWT layout operation. The Swing component may not display at all, depending on the layout type and parameters.

I've changed the code to get min/max/preferred values from the parent JApplet which seems to provide more sensible values.

We have quite a few nested anonymous classes which, in this case, made the problem hard to debug. I'll take a refactoring pass over the code to reduce the complexity here.

### Eclipse Workspace Patch 1.0
#P org.eclipse.albireo.core
Index: src/org/eclipse/albireo/core/SwingControl.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/core/SwingControl.java,v
retrieving revision 1.80
diff -u -r1.80 SwingControl.java
--- src/org/eclipse/albireo/core/SwingControl.java	6 May 2008 20:09:35 -0000	1.80
+++ src/org/eclipse/albireo/core/SwingControl.java	21 May 2008 21:54:00 -0000
@@ -417,7 +417,10 @@
                             // invalidate()/validateTree() calls.
                             protected void validateTree() {
                                 super.validateTree();
-                                updateCachedAWTSizes(getMinimumSize(), getPreferredSize(), getMaximumSize());
+                                // JRootPane returns strange values for at least getMaximumSize (max width is 
+                                // always set to 0), so get all the preferred sizes from the parent (JApplet). 
+                                updateCachedAWTSizes(getParent().getMinimumSize(), 
+                                        getParent().getPreferredSize(), getParent().getMaximumSize());
                             }
                         };
                     rootPane.setOpaque(true);

Back to the top