[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[albireo-dev] SwingControl: add accessors
|
It's convenient for subclasses of SwingControl that they don't have to
remember themselves the value returned from the createSwingControl method,
and grovel through getParent() to find the top-level frame.
I'm adding these accessors. The /*final*/ marker is a reminder that
users should not override this method.
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.2
diff -c -3 -r1.2 SwingControl.java
*** src/org/eclipse/albireo/core/SwingControl.java 23 Jan 2008 18:14:58 -0000 1.2
--- src/org/eclipse/albireo/core/SwingControl.java 23 Jan 2008 18:25:43 -0000
***************
*** 11,16 ****
--- 11,17 ----
*******************************************************************************/
package org.eclipse.albireo.core;
+ import java.awt.Container;
import java.awt.EventQueue;
import java.awt.Frame;
***************
*** 32,37 ****
--- 33,41 ----
private JComponent swingComponent;
private boolean populated = false;
+ // ========================================================================
+ // Constructors
+
/**
* Constructs a new embedded Swing control, given its parent
* and a style value describing its behavior and appearance.
***************
*** 67,72 ****
--- 71,79 ----
setLayout(new FillLayout());
}
+ // ========================================================================
+ // Initialization
+
/**
* Populates the embedded composite with the Swing component.
* <p>
***************
*** 210,213 ****
--- 217,244 ----
*/
protected void afterComponentCreatedSWTThread() {
}
+
+ // ========================================================================
+ // Accessors
+
+ /**
+ * Returns the Swing component contained in this control.
+ * @return The embedded Swing component, or <code>null</code> if it has not
+ * yet been initialized.
+ */
+ public /*final*/ JComponent getSwingComponent() {
+ return swingComponent;
+ }
+
+ /**
+ * Returns the root of the AWT component hierarchy; this is the top-level
+ * parent of the embedded Swing component.
+ * @return An AWT container, usually a Window, or <code>null</code> if the
+ * initialization is not yet complete.
+ */
+ public /*final*/ Container getAWTHierarchyRoot() {
+ return frame;
+ }
+
+ // ========================================================================
}