[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [albireo-dev] A small fix to address layout issues
|
Gordon Hirsch wrote:
> 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.
I agree that the class names SwingControl$11 are not self-explaining.
Refactoring it like this, to get at least reasonable class names. What
else do you have in mind (reduce the complexity?).
Bruno
Index: 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.83
diff -c -3 -r1.83 SwingControl.java
*** org/eclipse/albireo/core/SwingControl.java 28 May 2008 14:21:36 -0000 1.83
--- org/eclipse/albireo/core/SwingControl.java 28 May 2008 15:15:57 -0000
***************
*** 404,446 ****
// only single component that satisfies all the above. This does not imply that
// we have a true applet; in particular, there is no notion of an applet lifecycle in this
// context.
! JApplet applet =
! new JApplet() {
! // Overridden from JApplet.
! protected JRootPane createRootPane() {
! JRootPane rootPane =
! new JRootPane() {
! // Keep the sizes cache up to date.
! // The JRootPane, not the JApplet, is the "validation root",
! // as determined by RepaintManager.addInvalidComponent().
! // It is here that we can intercept the relevant
! // invalidate()/validateTree() calls.
! protected void validateTree() {
! super.validateTree();
! // JRootPane returns a wrong value for getMaximumSize(),
! // namely [0,2147483647] instead of [2147483647,2147483647],
! // so we use the content pane's maximum size instead.
! updateCachedAWTSizes(getMinimumSize(),
! getPreferredSize(),
! getContentPane().getMaximumSize());
! }
! };
! rootPane.setOpaque(true);
! return rootPane;
! }
! };
! if (Platform.isWin32()) {
! // Avoid stack overflows by ensuring correct focus traversal policy
! // (see comments in scheduleComponentCreation() for details)
! applet.setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
! }
!
frame.add(applet);
return applet;
}
/**
* Creates the embedded Swing component. This method is called from the AWT event thread.
* <p>
* Implement this method to provide the Swing component that will be shown inside this composite.
--- 404,455 ----
// only single component that satisfies all the above. This does not imply that
// we have a true applet; in particular, there is no notion of an applet lifecycle in this
// context.
! JApplet applet = new ToplevelPanel();
! if (Platform.isWin32()) {
! // Avoid stack overflows by ensuring correct focus traversal policy
! // (see comments in scheduleComponentCreation() for details)
! applet.setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
! }
!
frame.add(applet);
return applet;
}
/**
+ * The top-level java.awt.Panel, added as child of the frame.
+ */
+ private class ToplevelPanel extends JApplet {
+ // Overridden from JApplet.
+ protected JRootPane createRootPane() {
+ JRootPane rootPane = new ToplevelRootPane();
+ rootPane.setOpaque(true);
+ return rootPane;
+ }
+ }
+
+ /**
+ * The top-level javax.swing.JRootPane, added as child of the toplevel
+ * Panel.
+ */
+ private class ToplevelRootPane extends JRootPane {
+ // Keep the sizes cache up to date.
+ // The JRootPane, not the JApplet, is the "validation root",
+ // as determined by RepaintManager.addInvalidComponent().
+ // It is here that we can intercept the relevant
+ // invalidate()/validateTree() calls.
+ protected void validateTree() {
+ super.validateTree();
+ // JRootPane returns a wrong value for getMaximumSize(),
+ // namely [0,2147483647] instead of [2147483647,2147483647],
+ // so we use the content pane's maximum size instead.
+ updateCachedAWTSizes(getMinimumSize(),
+ getPreferredSize(),
+ getContentPane().getMaximumSize());
+ }
+ }
+
+ /**
* Creates the embedded Swing component. This method is called from the AWT event thread.
* <p>
* Implement this method to provide the Swing component that will be shown inside this composite.