diff options
author | Silenio Quarti <silenio> | 2005-08-02 17:44:11 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2005-08-02 17:44:11 +0000 |
commit | 964f59eb93aac781c2eac1ad63437d26303b0d27 (patch) | |
tree | 5c738b6703baf1d25144824dc2a7349c523edfe5 | |
parent | f92c8f667c089c683c12fe548693cb4621d6c940 (diff) | |
download | eclipse.platform.swt-964f59eb93aac781c2eac1ad63437d26303b0d27.tar.gz eclipse.platform.swt-964f59eb93aac781c2eac1ad63437d26303b0d27.tar.xz eclipse.platform.swt-964f59eb93aac781c2eac1ad63437d26303b0d27.zip |
104301
4 files changed, 64 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/emulated/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/emulated/org/eclipse/swt/awt/SWT_AWT.java index b205b8ef33..0acc96f66d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT AWT/emulated/org/eclipse/swt/awt/SWT_AWT.java +++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/emulated/org/eclipse/swt/awt/SWT_AWT.java @@ -32,6 +32,18 @@ public class SWT_AWT { */ public static String embeddedFrameClass; + /** + * Key for looking up the embedded frame for a Composite using + * getData(). + */ + static String EMBEDDED_FRAME_KEY = "org.eclipse.swt.awt.SWT_AWT.embeddedFrame"; + +public static Frame getFrame (Composite parent) { + if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + if ((parent.getStyle () & SWT.EMBEDDED) == 0) return null; + return (Frame)parent.getData(EMBEDDED_FRAME_KEY); +} + /** * Creates a new <code>java.awt.Frame</code>. This frame is the root for * the AWT components that will be embedded within the composite. In order diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java index b56c83ea91..301f51c403 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java +++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java @@ -47,6 +47,12 @@ public class SWT_AWT { */ public static String embeddedFrameClass; + /** + * Key for looking up the embedded frame for a Composite using + * getData(). + */ + static String EMBEDDED_FRAME_KEY = "org.eclipse.swt.awt.SWT_AWT.embeddedFrame"; + static boolean loaded, swingInitialized; static native final int /*long*/ getAWTHandle (Canvas canvas); @@ -80,6 +86,12 @@ static synchronized void initializeSwing() { } catch (Throwable e) {} } +public static Frame getFrame (Composite parent) { + if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + if ((parent.getStyle () & SWT.EMBEDDED) == 0) return null; + return (Frame)parent.getData(EMBEDDED_FRAME_KEY); +} + /** * Creates a new <code>java.awt.Frame</code>. This frame is the root for * the AWT components that will be embedded within the composite. In order @@ -136,6 +148,7 @@ public static Frame new_Frame (final Composite parent) { } } final Frame frame = (Frame) value; + parent.setData(EMBEDDED_FRAME_KEY, frame); if (Device.DEBUG) { loadLibrary(); setDebug(frame, true); diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/motif/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/motif/org/eclipse/swt/awt/SWT_AWT.java index 4575c5a3a2..f809478a3f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT AWT/motif/org/eclipse/swt/awt/SWT_AWT.java +++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/motif/org/eclipse/swt/awt/SWT_AWT.java @@ -47,6 +47,12 @@ public class SWT_AWT { */ public static String embeddedFrameClass; + /** + * Key for looking up the embedded frame for a Composite using + * getData(). + */ + static String EMBEDDED_FRAME_KEY = "org.eclipse.swt.awt.SWT_AWT.embeddedFrame"; + static boolean loaded, swingInitialized; static native final int /*long*/ getAWTHandle (Canvas canvas); @@ -80,6 +86,12 @@ static synchronized void initializeSwing() { } catch (Throwable e) {} } +public static Frame getFrame (Composite parent) { + if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + if ((parent.getStyle () & SWT.EMBEDDED) == 0) return null; + return (Frame)parent.getData(EMBEDDED_FRAME_KEY); +} + /** * Creates a new <code>java.awt.Frame</code>. This frame is the root for * the AWT components that will be embedded within the composite. In order @@ -136,6 +148,7 @@ public static Frame new_Frame (final Composite parent) { } } final Frame frame = (Frame) value; + parent.setData(EMBEDDED_FRAME_KEY, frame); if (Device.DEBUG) { loadLibrary(); setDebug(frame, true); diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java index 47e9237ea8..c973160f2c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java +++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java @@ -49,6 +49,12 @@ public class SWT_AWT { */ public static String embeddedFrameClass; + /** + * Key for looking up the embedded frame for a Composite using + * getData(). + */ + static String EMBEDDED_FRAME_KEY = "org.eclipse.swt.awt.SWT_AWT.embeddedFrame"; + static boolean loaded, swingInitialized; static native final int getAWTHandle (Canvas canvas); @@ -83,6 +89,25 @@ static synchronized void initializeSwing() { } /** + * Answers a <code>java.awt.Frame</code> which is the embedded frame + * associated with the specified composite. + * + * @param parent the parent <code>Composite</code> of the <code>java.awt.Frame</code> + * @return a <code>java.awt.Frame</code> the embedded frame or <code>null</code>. + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> + * </ul> + * + * @since 3.2 + */ +public static Frame getFrame (Composite parent) { + if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + if ((parent.getStyle () & SWT.EMBEDDED) == 0) return null; + return (Frame)parent.getData(EMBEDDED_FRAME_KEY); +} + +/** * Creates a new <code>java.awt.Frame</code>. This frame is the root for * the AWT components that will be embedded within the composite. In order * for the embedding to succeed, the composite must have been created @@ -141,6 +166,7 @@ public static Frame new_Frame (final Composite parent) { SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e); } final Frame frame = (Frame) value; + parent.setData(EMBEDDED_FRAME_KEY, frame); /* * This is necessary to make lightweight components |