summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT AWT
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT AWT')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/carbon/org/eclipse/swt/awt/SWT_AWT.java170
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/library/swt_awt.c45
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java239
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/common/org/eclipse/swt/awt/package.html17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/emulated/org/eclipse/swt/awt/SWT_AWT.java117
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/library/swt_awt.c73
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java333
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/motif/library/swt_awt.c72
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/motif/org/eclipse/swt/awt/SWT_AWT.java325
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/win32/library/swt_awt.c45
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/win32/library/swt_awt.rc45
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java398
12 files changed, 0 insertions, 1879 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/carbon/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/carbon/org/eclipse/swt/awt/SWT_AWT.java
deleted file mode 100644
index d44c48146f..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/carbon/org/eclipse/swt/awt/SWT_AWT.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Scott Kovatch - interface to apple.awt.CHIViewEmbeddedFrame
- *******************************************************************************/
-package org.eclipse.swt.awt;
-
-import java.awt.Canvas;
-import java.awt.EventQueue;
-import java.awt.Frame;
-import java.lang.reflect.Constructor;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * This class provides a bridge between SWT and AWT, so that it
- * is possible to embed AWT components in SWT and vice versa.
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#awt">Swing/AWT snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- *
- * @since 3.0
- */
-public class SWT_AWT {
-
- /**
- * The name of the embedded Frame class. The default class name
- * for the platform will be used if <code>null</code>.
- */
- 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 {
- System.setProperty("apple.awt.usingSWT", "true");
- }
-
-/**
- * Returns 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
- * with the SWT.EMBEDDED style.
- * <p>
- * IMPORTANT: As of JDK1.5, the embedded frame does not receive mouse events.
- * When a lightweight component is added as a child of the embedded frame,
- * the cursor does not change. In order to work around both these problems, it is
- * strongly recommended that a heavyweight component such as <code>java.awt.Panel</code>
- * be added to the frame as the root of all components.
- * </p>
- *
- * @param parent the parent <code>Composite</code> of the new <code>java.awt.Frame</code>
- * @return a <code>java.awt.Frame</code> to be the parent of the embedded AWT components
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent Composite does not have the SWT.EMBEDDED style</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Frame new_Frame(final Composite parent) {
- if (parent == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if ((parent.getStyle() & SWT.EMBEDDED) == 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- final int handle = parent.handle;
-
- Class clazz = null;
- try {
- String className = embeddedFrameClass != null ? embeddedFrameClass : "apple.awt.CHIViewEmbeddedFrame";
- if (embeddedFrameClass == null) {
- clazz = Class.forName(className, true, ClassLoader.getSystemClassLoader());
- } else {
- clazz = Class.forName(className);
- }
- } catch (ClassNotFoundException cne) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, cne);
- } catch (Throwable e) {
- SWT.error (SWT.ERROR_UNSPECIFIED , e, " [Error while starting AWT]");
- }
-
- Object value = null;
- Constructor constructor = null;
- try {
- constructor = clazz.getConstructor (new Class [] {long.class});
- value = constructor.newInstance (new Object [] {new Long(handle)});
- } catch (Throwable e) {
- SWT.error(SWT.ERROR_NOT_IMPLEMENTED, e);
- }
- final Frame frame = (Frame) value;
- parent.setData(EMBEDDED_FRAME_KEY, frame);
-
- Listener listener = new Listener() {
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.Dispose: {
- parent.setVisible(false);
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.dispose ();
- }
- });
- break;
- }
- }
- }
- };
-
- parent.addListener(SWT.Dispose, listener);
-
- return frame;
-}
-
-/**
- * Creates a new <code>Shell</code>. This Shell is the root for
- * the SWT widgets that will be embedded within the AWT canvas.
- *
- * @param display the display for the new Shell
- * @param parent the parent <code>java.awt.Canvas</code> of the new Shell
- * @return a <code>Shell</code> to be the parent of the embedded SWT widgets
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the display is null</li>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent's peer is not created</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Shell new_Shell(final Display display, final Canvas parent) {
- if (display == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (parent == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- return null;
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/library/swt_awt.c b/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/library/swt_awt.c
deleted file mode 100644
index 1bb23d911c..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/library/swt_awt.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-#include "swt.h"
-#include "jawt_md.h"
-
-#define SWT_AWT_NATIVE(func) Java_org_eclipse_swt_awt_SWT_1AWT_##func
-
-#ifndef NO_getAWTHandle
-JNIEXPORT jintLong JNICALL SWT_AWT_NATIVE(getAWTHandle)
- (JNIEnv *env, jclass that, jobject canvas)
-{
- jintLong result = 0;
- JAWT awt;
- JAWT_DrawingSurface* ds;
- JAWT_DrawingSurfaceInfo* dsi;
- JAWT_MacOSXDrawingSurfaceInfo* dsi_cocoa;
- jint lock;
-
- awt.version = JAWT_VERSION_1_4;
- if (JAWT_GetAWT(env, &awt) != 0) {
- ds = awt.GetDrawingSurface(env, canvas);
- if (ds != NULL) {
- lock = ds->Lock(ds);
- if ((lock & JAWT_LOCK_ERROR) == 0) {
- dsi = ds->GetDrawingSurfaceInfo(ds);
- dsi_cocoa = (JAWT_MacOSXDrawingSurfaceInfo*)dsi->platformInfo;
- result = (jintLong)dsi_cocoa->cocoaViewRef;
- ds->FreeDrawingSurfaceInfo(dsi);
- ds->Unlock(ds);
- }
- }
- awt.FreeDrawingSurface(ds);
- }
- return result;
-}
-#endif
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java
deleted file mode 100755
index 64cab44bee..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Scott Kovatch - interface to apple.awt.CHIViewEmbeddedFrame
- *******************************************************************************/
-package org.eclipse.swt.awt;
-
-import java.awt.Canvas;
-import java.awt.EventQueue;
-import java.awt.Frame;
-import java.awt.Toolkit;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.internal.Library;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * This class provides a bridge between SWT and AWT, so that it
- * is possible to embed AWT components in SWT and vice versa.
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#awt">Swing/AWT snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- *
- * @since 3.0
- */
-public class SWT_AWT {
-
- /**
- * The name of the embedded Frame class. The default class name
- * for the platform will be used if <code>null</code>.
- */
- 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 {
- System.setProperty("apple.awt.usingSWT", "true");
- }
-
- static boolean loaded, swingInitialized;
-
- static native final int /*long*/ getAWTHandle (Canvas canvas);
-
- static synchronized void loadLibrary () {
- if (loaded) return;
- loaded = true;
- Toolkit.getDefaultToolkit();
- /*
- * Note that the jawt library is loaded explicitly
- * because it cannot be found by the library loader.
- * All exceptions are caught because the library may
- * have been loaded already.
- */
- try {
- System.loadLibrary("jawt");
- } catch (Throwable e) {}
- Library.loadLibrary("swt-awt");
- }
-
- static synchronized void initializeSwing() {
- if (swingInitialized) return;
- swingInitialized = true;
- try {
- /* Initialize the default focus traversal policy */
- Class[] emptyClass = new Class[0];
- Object[] emptyObject = new Object[0];
- Class clazz = Class.forName("javax.swing.UIManager");
- Method method = clazz.getMethod("getDefaults", emptyClass);
- if (method != null) method.invoke(clazz, emptyObject);
- } catch (Throwable e) {}
- }
-
-/**
- * Returns 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
- * with the SWT.EMBEDDED style.
- * <p>
- * IMPORTANT: As of JDK1.5, the embedded frame does not receive mouse events.
- * When a lightweight component is added as a child of the embedded frame,
- * the cursor does not change. In order to work around both these problems, it is
- * strongly recommended that a heavyweight component such as <code>java.awt.Panel</code>
- * be added to the frame as the root of all components.
- * </p>
- *
- * @param parent the parent <code>Composite</code> of the new <code>java.awt.Frame</code>
- * @return a <code>java.awt.Frame</code> to be the parent of the embedded AWT components
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent Composite does not have the SWT.EMBEDDED style</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Frame new_Frame(final Composite parent) {
- if (parent == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if ((parent.getStyle() & SWT.EMBEDDED) == 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-
- final int /*long*/ handle = parent.view.id;
-
- Class clazz = null;
- try {
- String className = embeddedFrameClass != null ? embeddedFrameClass : "apple.awt.CEmbeddedFrame";
- if (embeddedFrameClass == null) {
- clazz = Class.forName(className, true, ClassLoader.getSystemClassLoader());
- } else {
- clazz = Class.forName(className);
- }
- } catch (ClassNotFoundException cne) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, cne);
- } catch (Throwable e) {
- SWT.error (SWT.ERROR_UNSPECIFIED , e, " [Error while starting AWT]");
- }
-
- Object value = null;
- Constructor constructor = null;
- try {
- constructor = clazz.getConstructor (new Class [] {long.class});
- value = constructor.newInstance (new Object [] {new Long(handle)});
- } catch (Throwable e) {
- SWT.error(SWT.ERROR_NOT_IMPLEMENTED, e);
- }
- final Frame frame = (Frame) value;
- parent.setData(EMBEDDED_FRAME_KEY, frame);
-
- Listener listener = new Listener() {
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.Dispose: {
- parent.setVisible(false);
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.dispose ();
- }
- });
- break;
- }
- }
- }
- };
-
- parent.addListener(SWT.Dispose, listener);
-
- return frame;
-}
-
-/**
- * Creates a new <code>Shell</code>. This Shell is the root for
- * the SWT widgets that will be embedded within the AWT canvas.
- *
- * @param display the display for the new Shell
- * @param parent the parent <code>java.awt.Canvas</code> of the new Shell
- * @return a <code>Shell</code> to be the parent of the embedded SWT widgets
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the display is null</li>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent's peer is not created</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Shell new_Shell(final Display display, final Canvas parent) {
- if (display == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- return null;
-
-// TODO: Uncomment this code once Display/Shell related issues are ironed out.
-// int /*long*/ handle = 0;
-//
-// try {
-// loadLibrary ();
-// handle = getAWTHandle (parent);
-// } catch (Throwable e) {
-// SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e);
-// }
-// if (handle == 0) SWT.error (SWT.ERROR_INVALID_ARGUMENT, null, " [peer not created]");
-//
-// final Shell shell = Shell.cocoa_new (display, handle);
-// final ComponentListener listener = new ComponentAdapter () {
-// public void componentResized (ComponentEvent e) {
-// display.asyncExec (new Runnable () {
-// public void run () {
-// if (shell.isDisposed()) return;
-// Dimension dim = parent.getSize ();
-// shell.setSize (dim.width, dim.height);
-// }
-// });
-// }
-// };
-// parent.addComponentListener(listener);
-// shell.addListener(SWT.Dispose, new Listener() {
-// public void handleEvent(Event event) {
-// parent.removeComponentListener(listener);
-// }
-// });
-// shell.setVisible (true);
-// return shell;
-}
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/common/org/eclipse/swt/awt/package.html b/bundles/org.eclipse.swt/Eclipse SWT AWT/common/org/eclipse/swt/awt/package.html
deleted file mode 100644
index 710978ad27..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/common/org/eclipse/swt/awt/package.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-SWT AWT embedding support.
-<h2>
-Package Specification</h2>
-This package contains a class named <code>SWT_AWT</code> which
-provides support for embedding AWT widgets within SWT composites.
-This package requires JDK 1.5 or higher.
-It works on Windows, GTK, and Motif.
-</body>
-</html>
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
deleted file mode 100644
index 718a1160f5..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/emulated/org/eclipse/swt/awt/SWT_AWT.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.awt;
-
-import java.awt.Canvas;
-import java.awt.Frame;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * This class provides a bridge between SWT and AWT, so that it
- * is possible to embed AWT components in SWT and vice versa.
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#awt">Swing/AWT snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- *
- * @since 3.0
- */
-public class SWT_AWT {
-
- /**
- * The name of the embedded Frame class. The default class name
- * for the platform will be used if <code>null</code>.
- */
- 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";
-
-/**
- * Returns 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
- * with the SWT.EMBEDDED style.
- * <p>
- * IMPORTANT: As of JDK1.5, the embedded frame does not receive mouse events.
- * When a lightweight component is added as a child of the embedded frame,
- * the cursor does not change. In order to work around both these problems, it is
- * strongly recommended that a heavyweight component such as <code>java.awt.Panel</code>
- * be added to the frame as the root of all components.
- * </p>
- *
- * @param parent the parent <code>Composite</code> of the new <code>java.awt.Frame</code>
- * @return a <code>java.awt.Frame</code> to be the parent of the embedded AWT components
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent Composite does not have the SWT.EMBEDDED style</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Frame new_Frame (final Composite parent) {
- if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if ((parent.getStyle () & SWT.EMBEDDED) == 0) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
- return null;
-}
-
-/**
- * Creates a new <code>Shell</code>. This Shell is the root for
- * the SWT widgets that will be embedded within the AWT canvas.
- *
- * @param display the display for the new Shell
- * @param parent the parent <code>java.awt.Canvas</code> of the new Shell
- * @return a <code>Shell</code> to be the parent of the embedded SWT widgets
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the display is null</li>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent's peer is not created</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Shell new_Shell (final Display display, final Canvas parent) {
- if (display == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
- return null;
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/library/swt_awt.c b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/library/swt_awt.c
deleted file mode 100644
index c43fdc56a3..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/library/swt_awt.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-#include "swt.h"
-#include "jawt_md.h"
-
-#define SWT_AWT_NATIVE(func) Java_org_eclipse_swt_awt_SWT_1AWT_##func
-
-#ifndef NO_getAWTHandle
-JNIEXPORT jintLong JNICALL SWT_AWT_NATIVE(getAWTHandle)
- (JNIEnv *env, jclass that, jobject canvas)
-{
- JAWT awt;
- JAWT_DrawingSurface* ds;
- JAWT_DrawingSurfaceInfo* dsi;
- JAWT_X11DrawingSurfaceInfo* dsi_x11;
- jintLong result = 0;
- jint lock;
-
- awt.version = JAWT_VERSION_1_3;
- if (JAWT_GetAWT(env, &awt) != 0) {
- ds = awt.GetDrawingSurface(env, canvas);
- if (ds != NULL) {
- lock = ds->Lock(ds);
- if ((lock & JAWT_LOCK_ERROR) == 0) {
- dsi = ds->GetDrawingSurfaceInfo(ds);
- dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
- result = (jintLong)dsi_x11->drawable;
- ds->FreeDrawingSurfaceInfo(dsi);
- ds->Unlock(ds);
- }
- }
- awt.FreeDrawingSurface(ds);
- }
- return result;
-}
-#endif
-
-#ifndef NO_setDebug
-JNIEXPORT void JNICALL SWT_AWT_NATIVE(setDebug)
- (JNIEnv *env, jclass that, jobject frame, jboolean debug)
-{
- JAWT awt;
- JAWT_DrawingSurface* ds;
- JAWT_DrawingSurfaceInfo* dsi;
- JAWT_X11DrawingSurfaceInfo* dsi_x11;
- jint lock;
-
- awt.version = JAWT_VERSION_1_3;
- if (JAWT_GetAWT(env, &awt) != 0) {
- ds = awt.GetDrawingSurface(env, frame);
- if (ds != NULL) {
- lock = ds->Lock(ds);
- if ((lock & JAWT_LOCK_ERROR) == 0) {
- dsi = ds->GetDrawingSurfaceInfo(ds);
- dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
- XSynchronize(dsi_x11->display, debug);
- ds->FreeDrawingSurfaceInfo(dsi);
- ds->Unlock(ds);
- }
- }
- awt.FreeDrawingSurface(ds);
- }
-}
-#endif
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
deleted file mode 100644
index 2dead66273..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.awt;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-/* SWT Imports */
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.Device;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Event;
-
-/* AWT Imports */
-import java.awt.AWTEvent;
-import java.awt.Dimension;
-import java.awt.EventQueue;
-import java.awt.Canvas;
-import java.awt.Frame;
-import java.awt.Window;
-import java.awt.event.AWTEventListener;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-import java.awt.event.WindowEvent;
-
-
-/**
- * This class provides a bridge between SWT and AWT, so that it
- * is possible to embed AWT components in SWT and vice versa.
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#awt">Swing/AWT snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- *
- * @since 3.0
- */
-public class SWT_AWT {
-
- /**
- * The name of the embedded Frame class. The default class name
- * for the platform will be used if <code>null</code>.
- */
- 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 (Object canvas);
-static native final void setDebug (Frame canvas, boolean debug);
-
-static synchronized void loadLibrary () {
- if (loaded) return;
- loaded = true;
- /*
- * Note that the jawt library is loaded explicitly
- * because it cannot be found by the library loader.
- * All exceptions are caught because the library may
- * have been loaded already.
- */
- try {
- System.loadLibrary("jawt");
- } catch (Throwable e) {}
- Library.loadLibrary("swt-awt");
-}
-
-static synchronized void initializeSwing() {
- if (swingInitialized) return;
- swingInitialized = true;
- /*
- * Feature in GTK. The default X error handler
- * for GTK calls exit() after printing the X error.
- * Normally, this isn't that big a problem for SWT
- * applications because they don't cause X errors.
- * However, sometimes X errors are generated by AWT
- * that make SWT exit. The fix is to hide all X
- * errors when AWT is running.
- */
- OS.gdk_error_trap_push();
- try {
- /* Initialize the default focus traversal policy */
- Class[] emptyClass = new Class[0];
- Object[] emptyObject = new Object[0];
- Class clazz = Class.forName("javax.swing.UIManager");
- Method method = clazz.getMethod("getDefaults", emptyClass);
- if (method != null) method.invoke(clazz, emptyObject);
- } catch (Throwable e) {}
-}
-
-/**
- * Returns 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
- * with the SWT.EMBEDDED style.
- * <p>
- * IMPORTANT: As of JDK1.5, the embedded frame does not receive mouse events.
- * When a lightweight component is added as a child of the embedded frame,
- * the cursor does not change. In order to work around both these problems, it is
- * strongly recommended that a heavyweight component such as <code>java.awt.Panel</code>
- * be added to the frame as the root of all components.
- * </p>
- *
- * @param parent the parent <code>Composite</code> of the new <code>java.awt.Frame</code>
- * @return a <code>java.awt.Frame</code> to be the parent of the embedded AWT components
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent Composite does not have the SWT.EMBEDDED style</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Frame new_Frame (final Composite parent) {
- if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if ((parent.getStyle () & SWT.EMBEDDED) == 0) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- int /*long*/ handle = parent.embeddedHandle;
- /*
- * Some JREs have implemented the embedded frame constructor to take an integer
- * and other JREs take a long. To handle this binary incompatibility, use
- * reflection to create the embedded frame.
- */
- Class clazz = null;
- try {
- String className = embeddedFrameClass != null ? embeddedFrameClass : "sun.awt.X11.XEmbeddedFrame";
- clazz = Class.forName(className);
- } catch (Throwable e) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e, " [need JDK 1.5 or greater]");
- }
- initializeSwing ();
- Object value = null;
- Constructor constructor = null;
- try {
- constructor = clazz.getConstructor (new Class [] {int.class, boolean.class});
- value = constructor.newInstance (new Object [] {new Integer ((int)/*64*/handle), Boolean.TRUE});
- } catch (Throwable e1) {
- try {
- constructor = clazz.getConstructor (new Class [] {long.class, boolean.class});
- value = constructor.newInstance (new Object [] {new Long (handle), Boolean.TRUE});
- } catch (Throwable e2) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e2);
- }
- }
- final Frame frame = (Frame) value;
- parent.setData(EMBEDDED_FRAME_KEY, frame);
- if (Device.DEBUG) {
- loadLibrary();
- setDebug(frame, true);
- }
- try {
- /* Call registerListeners() to make XEmbed focus traversal work */
- Method method = clazz.getMethod("registerListeners", null);
- if (method != null) method.invoke(value, null);
- } catch (Throwable e) {}
- final AWTEventListener awtListener = new AWTEventListener() {
- public void eventDispatched(AWTEvent event) {
- if (event.getID() == WindowEvent.WINDOW_OPENED) {
- final Window window = (Window) event.getSource();
- if (window.getParent() == frame) {
- parent.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (parent.isDisposed()) return;
- Shell shell = parent.getShell();
- loadLibrary();
- int /*long*/ awtHandle = getAWTHandle(window);
- if (awtHandle == 0) return;
- int /*long*/ xWindow = OS.gdk_x11_drawable_get_xid(OS.GTK_WIDGET_WINDOW(OS.gtk_widget_get_toplevel(shell.handle)));
- OS.XSetTransientForHint(OS.GDK_DISPLAY(), awtHandle, xWindow);
- }
- });
- }
- }
- }
- };
- frame.getToolkit().addAWTEventListener(awtListener, AWTEvent.WINDOW_EVENT_MASK);
- final Listener shellListener = new Listener () {
- public void handleEvent (Event e) {
- switch (e.type) {
- case SWT.Deiconify:
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEICONIFIED));
- }
- });
- break;
- case SWT.Iconify:
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ICONIFIED));
- }
- });
- break;
- }
- }
- };
- Shell shell = parent.getShell ();
- shell.addListener (SWT.Deiconify, shellListener);
- shell.addListener (SWT.Iconify, shellListener);
-
- Listener listener = new Listener () {
- public void handleEvent (Event e) {
- switch (e.type) {
- case SWT.Dispose:
- Shell shell = parent.getShell ();
- shell.removeListener (SWT.Deiconify, shellListener);
- shell.removeListener (SWT.Iconify, shellListener);
- parent.setVisible(false);
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.getToolkit().removeAWTEventListener(awtListener);
- frame.dispose ();
- }
- });
- break;
- case SWT.Resize:
- if (Library.JAVA_VERSION >= Library.JAVA_VERSION(1, 6, 0)) {
- final Rectangle clientArea = parent.getClientArea();
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.setSize (clientArea.width, clientArea.height);
- }
- });
- }
- break;
- }
- }
- };
- parent.addListener (SWT.Dispose, listener);
- parent.addListener (SWT.Resize, listener);
-
- parent.getDisplay().asyncExec(new Runnable() {
- public void run () {
- if (parent.isDisposed()) return;
- final Rectangle clientArea = parent.getClientArea();
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.setSize (clientArea.width, clientArea.height);
- frame.validate ();
- }
- });
- }
- });
- return frame;
-}
-
-/**
- * Creates a new <code>Shell</code>. This Shell is the root for
- * the SWT widgets that will be embedded within the AWT canvas.
- *
- * @param display the display for the new Shell
- * @param parent the parent <code>java.awt.Canvas</code> of the new Shell
- * @return a <code>Shell</code> to be the parent of the embedded SWT widgets
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the display is null</li>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent's peer is not created</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Shell new_Shell (final Display display, final Canvas parent) {
- if (display == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int /*long*/ handle = 0;
- try {
- loadLibrary ();
- handle = getAWTHandle (parent);
- } catch (Throwable e) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e);
- }
- if (handle == 0) SWT.error (SWT.ERROR_INVALID_ARGUMENT, null, " [peer not created]");
-
- final Shell shell = Shell.gtk_new (display, handle);
- final ComponentListener listener = new ComponentAdapter () {
- public void componentResized (ComponentEvent e) {
- display.syncExec (new Runnable () {
- public void run () {
- if (shell.isDisposed()) return;
- Dimension dim = parent.getSize ();
- shell.setSize (dim.width, dim.height);
- }
- });
- }
- };
- parent.addComponentListener(listener);
- shell.addListener(SWT.Dispose, new Listener() {
- public void handleEvent(Event event) {
- parent.removeComponentListener(listener);
- }
- });
- shell.setVisible (true);
- return shell;
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/motif/library/swt_awt.c b/bundles/org.eclipse.swt/Eclipse SWT AWT/motif/library/swt_awt.c
deleted file mode 100644
index ff5c83e9a4..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/motif/library/swt_awt.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2000, 2005 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* IBM Corporation - initial API and implementation
-*******************************************************************************/
-
-#include "jawt_md.h"
-
-#define SWT_AWT_NATIVE(func) Java_org_eclipse_swt_awt_SWT_1AWT_##func
-
-#ifndef NO_getAWTHandle
-JNIEXPORT jint JNICALL SWT_AWT_NATIVE(getAWTHandle)
- (JNIEnv *env, jclass that, jobject canvas)
-{
- JAWT awt;
- JAWT_DrawingSurface* ds;
- JAWT_DrawingSurfaceInfo* dsi;
- JAWT_X11DrawingSurfaceInfo* dsi_x11;
- jint result = 0;
- jint lock;
-
- awt.version = JAWT_VERSION_1_3;
- if (JAWT_GetAWT(env, &awt) != 0) {
- ds = awt.GetDrawingSurface(env, canvas);
- if (ds != NULL) {
- lock = ds->Lock(ds);
- if ((lock & JAWT_LOCK_ERROR) == 0) {
- dsi = ds->GetDrawingSurfaceInfo(ds);
- dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
- result = (jint)dsi_x11->drawable;
- ds->FreeDrawingSurfaceInfo(dsi);
- ds->Unlock(ds);
- }
- }
- awt.FreeDrawingSurface(ds);
- }
- return result;
-}
-#endif
-
-#ifndef NO_setDebug
-JNIEXPORT void JNICALL SWT_AWT_NATIVE(setDebug)
- (JNIEnv *env, jclass that, jobject frame, jboolean debug)
-{
- JAWT awt;
- JAWT_DrawingSurface* ds;
- JAWT_DrawingSurfaceInfo* dsi;
- JAWT_X11DrawingSurfaceInfo* dsi_x11;
- jint lock;
-
- awt.version = JAWT_VERSION_1_3;
- if (JAWT_GetAWT(env, &awt) != 0) {
- ds = awt.GetDrawingSurface(env, frame);
- if (ds != NULL) {
- lock = ds->Lock(ds);
- if ((lock & JAWT_LOCK_ERROR) == 0) {
- dsi = ds->GetDrawingSurfaceInfo(ds);
- dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
- XSynchronize(dsi_x11->display, debug);
- ds->FreeDrawingSurfaceInfo(dsi);
- ds->Unlock(ds);
- }
- }
- awt.FreeDrawingSurface(ds);
- }
-}
-#endif
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
deleted file mode 100644
index f8e51f124c..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/motif/org/eclipse/swt/awt/SWT_AWT.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.awt;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-/* SWT Imports */
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.OS;
-import org.eclipse.swt.graphics.Device;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Event;
-
-/* AWT Imports */
-import java.awt.AWTEvent;
-import java.awt.Dimension;
-import java.awt.EventQueue;
-import java.awt.Canvas;
-import java.awt.Frame;
-import java.awt.Window;
-import java.awt.event.AWTEventListener;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-import java.awt.event.WindowEvent;
-
-
-/**
- * This class provides a bridge between SWT and AWT, so that it
- * is possible to embed AWT components in SWT and vice versa.
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#awt">Swing/AWT snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- *
- * @since 3.0
- */
-public class SWT_AWT {
-
- /**
- * The name of the embedded Frame class. The default class name
- * for the platform will be used if <code>null</code>.
- */
- 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 (Object canvas);
-static native final void setDebug (Frame canvas, boolean debug);
-
-static synchronized void loadLibrary () {
- if (loaded) return;
- loaded = true;
- /*
- * Note that the jawt library is loaded explicitily
- * because it cannot be found by the library loader.
- * All exceptions are caught because the library may
- * have been loaded already.
- */
- try {
- System.loadLibrary("jawt");
- } catch (Throwable e) {}
- Library.loadLibrary("swt-awt");
-}
-
-static synchronized void initializeSwing() {
- if (swingInitialized) return;
- swingInitialized = true;
- try {
- /* Initialize the default focus traversal policy */
- Class[] emptyClass = new Class[0];
- Object[] emptyObject = new Object[0];
- Class clazz = Class.forName("javax.swing.UIManager");
- Method method = clazz.getMethod("getDefaults", emptyClass);
- if (method != null) method.invoke(clazz, emptyObject);
- } catch (Throwable e) {}
-}
-
-/**
- * Returns 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
- * with the SWT.EMBEDDED style.
- * <p>
- * IMPORTANT: As of JDK1.5, the embedded frame does not receive mouse events.
- * When a lightweight component is added as a child of the embedded frame,
- * the cursor does not change. In order to work around both these problems, it is
- * strongly recommended that a heavyweight component such as <code>java.awt.Panel</code>
- * be added to the frame as the root of all components.
- * </p>
- *
- * @param parent the parent <code>Composite</code> of the new <code>java.awt.Frame</code>
- * @return a <code>java.awt.Frame</code> to be the parent of the embedded AWT components
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent Composite does not have the SWT.EMBEDDED style</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Frame new_Frame (final Composite parent) {
- if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if ((parent.getStyle () & SWT.EMBEDDED) == 0) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- int /*long*/ handle = parent.embeddedHandle;
- /*
- * Some JREs have implemented the embedded frame constructor to take an integer
- * and other JREs take a long. To handle this binary incompatability, use
- * reflection to create the embedded frame.
- */
- Class clazz = null;
- try {
- String className = embeddedFrameClass != null ? embeddedFrameClass : "sun.awt.X11.XEmbeddedFrame";
- clazz = Class.forName(className);
- } catch (Throwable e) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e, " [need JDK 1.5 or greater]");
- }
- initializeSwing ();
- Object value = null;
- Constructor constructor = null;
- try {
- constructor = clazz.getConstructor (new Class [] {int.class, boolean.class});
- value = constructor.newInstance (new Object [] {new Integer ((int)/*64*/handle), Boolean.TRUE});
- } catch (Throwable e1) {
- try {
- constructor = clazz.getConstructor (new Class [] {long.class, boolean.class});
- value = constructor.newInstance (new Object [] {new Long (handle), Boolean.TRUE});
- } catch (Throwable e2) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e2);
- }
- }
- final Frame frame = (Frame) value;
- parent.setData(EMBEDDED_FRAME_KEY, frame);
- if (Device.DEBUG) {
- loadLibrary();
- setDebug(frame, true);
- }
- try {
- /* Call registerListeners() to make XEmbed focus traversal work */
- Method method = clazz.getMethod("registerListeners", null);
- if (method != null) method.invoke(value, null);
- } catch (Throwable e) {}
- final AWTEventListener awtListener = new AWTEventListener() {
- public void eventDispatched(AWTEvent event) {
- if (event.getID() == WindowEvent.WINDOW_OPENED) {
- final Window window = (Window) event.getSource();
- if (window.getParent() == frame) {
- parent.getDisplay().asyncExec(new Runnable() {
- public void run() {
- Shell shell = parent.getShell();
- loadLibrary();
- int awtHandle = getAWTHandle(window);
- if (awtHandle == 0) return;
- int xtParent = OS.XtParent (shell.handle);
- while (xtParent != 0 && !OS.XtIsSubclass (xtParent, OS.shellWidgetClass ())) {
- xtParent = OS.XtParent (xtParent);
- }
- OS.XSetTransientForHint(OS.XtDisplay(xtParent), awtHandle, OS.XtWindow(xtParent));
- }
- });
- }
- }
- }
- };
- frame.getToolkit().addAWTEventListener(awtListener, AWTEvent.WINDOW_EVENT_MASK);
- final Listener shellListener = new Listener () {
- public void handleEvent (Event e) {
- switch (e.type) {
- case SWT.Deiconify:
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEICONIFIED));
- }
- });
- break;
- case SWT.Iconify:
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ICONIFIED));
- }
- });
- break;
- }
- }
- };
- Shell shell = parent.getShell ();
- shell.addListener (SWT.Deiconify, shellListener);
- shell.addListener (SWT.Iconify, shellListener);
-
- Listener listener = new Listener () {
- public void handleEvent (Event e) {
- switch (e.type) {
- case SWT.Dispose:
- Shell shell = parent.getShell ();
- shell.removeListener (SWT.Deiconify, shellListener);
- shell.removeListener (SWT.Iconify, shellListener);
- parent.setVisible(false);
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.getToolkit().removeAWTEventListener(awtListener);
- frame.dispose ();
- }
- });
- break;
- case SWT.Resize:
- if (Library.JAVA_VERSION >= Library.JAVA_VERSION(1, 6, 0)) {
- final Rectangle clientArea = parent.getClientArea();
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.setSize (clientArea.width, clientArea.height);
- }
- });
- }
- break;
- }
- }
- };
- parent.addListener (SWT.Dispose, listener);
- parent.addListener (SWT.Resize, listener);
-
- parent.getDisplay().asyncExec(new Runnable() {
- public void run () {
- if (parent.isDisposed()) return;
- final Rectangle clientArea = parent.getClientArea();
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.setSize (clientArea.width, clientArea.height);
- frame.validate ();
- }
- });
- }
- });
- return frame;
-}
-
-/**
- * Creates a new <code>Shell</code>. This Shell is the root for
- * the SWT widgets that will be embedded within the AWT canvas.
- *
- * @param display the display for the new Shell
- * @param parent the parent <code>java.awt.Canvas</code> of the new Shell
- * @return a <code>Shell</code> to be the parent of the embedded SWT widgets
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the display is null</li>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent's peer is not created</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Shell new_Shell (final Display display, final Canvas parent) {
- if (display == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int /*long*/ handle = 0;
- try {
- loadLibrary ();
- handle = getAWTHandle (parent);
- } catch (Throwable e) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e);
- }
- if (handle == 0) SWT.error (SWT.ERROR_INVALID_ARGUMENT, null, " [peer not created]");
-
- final Shell shell = Shell.motif_new (display, handle);
- final ComponentListener listener = new ComponentAdapter () {
- public void componentResized (ComponentEvent e) {
- display.syncExec (new Runnable () {
- public void run () {
- if (shell.isDisposed()) return;
- Dimension dim = parent.getSize ();
- shell.setSize (dim.width, dim.height);
- }
- });
- }
- };
- parent.addComponentListener(listener);
- shell.addListener(SWT.Dispose, new Listener() {
- public void handleEvent(Event event) {
- parent.removeComponentListener(listener);
- }
- });
- shell.setVisible (true);
- return shell;
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/library/swt_awt.c b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/library/swt_awt.c
deleted file mode 100644
index 0df8e82fb7..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/library/swt_awt.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-#include "swt.h"
-#include "jawt_md.h"
-
-#define SWT_AWT_NATIVE(func) Java_org_eclipse_swt_awt_SWT_1AWT_##func
-
-#ifndef NO_getAWTHandle
-JNIEXPORT jintLong JNICALL SWT_AWT_NATIVE(getAWTHandle)
- (JNIEnv *env, jclass that, jobject canvas)
-{
- JAWT awt;
- JAWT_DrawingSurface* ds;
- JAWT_DrawingSurfaceInfo* dsi;
- JAWT_Win32DrawingSurfaceInfo* dsi_win;
- jintLong result = 0;
- jint lock;
-
- awt.version = JAWT_VERSION_1_3;
- if (JAWT_GetAWT(env, &awt) != 0) {
- ds = awt.GetDrawingSurface(env, canvas);
- if (ds != NULL) {
- lock = ds->Lock(ds);
- if ((lock & JAWT_LOCK_ERROR) == 0) {
- dsi = ds->GetDrawingSurfaceInfo(ds);
- dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
- result = (jintLong)dsi_win->hwnd;
- ds->FreeDrawingSurfaceInfo(dsi);
- ds->Unlock(ds);
- }
- }
- awt.FreeDrawingSurface(ds);
- }
- return result;
-}
-#endif
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/library/swt_awt.rc b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/library/swt_awt.rc
deleted file mode 100644
index e46095f457..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/library/swt_awt.rc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-#include "windows.h"
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION SWT_COMMA_VERSION
- PRODUCTVERSION 0,0,0,0
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x40000L
- FILETYPE 0x2L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "CompanyName", "Eclipse Foundation\0"
- VALUE "FileDescription", "SWT for Windows native library\0"
- VALUE "FileVersion", SWT_FILE_VERSION
- VALUE "InternalName", "SWT\0"
- VALUE "LegalCopyright", "Copyright (c) 2000, 2006 IBM Corp. All Rights Reserved.\0"
- VALUE "OriginalFilename", SWT_ORG_FILENAME
- VALUE "ProductName", "Standard Widget Toolkit\0"
- VALUE "ProductVersion", "0,0,0,0\0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
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
deleted file mode 100644
index 8d1d39d5e0..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.awt;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-/* SWT Imports */
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Event;
-
-/* AWT Imports */
-import java.awt.Dimension;
-import java.awt.EventQueue;
-import java.awt.Canvas;
-import java.awt.Frame;
-import java.awt.Toolkit;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-import java.awt.event.WindowEvent;
-import java.awt.event.FocusEvent;
-
-/**
- * This class provides a bridge between SWT and AWT, so that it
- * is possible to embed AWT components in SWT and vice versa.
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#awt">Swing/AWT snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- *
- * @since 3.0
- */
-public class SWT_AWT {
-
- /**
- * The name of the embedded Frame class. The default class name
- * for the platform will be used if <code>null</code>.
- */
- 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);
-
-static synchronized void loadLibrary () {
- if (loaded) return;
- loaded = true;
- Toolkit.getDefaultToolkit();
- /*
- * Note that the jawt library is loaded explicitly
- * because it cannot be found by the library loader.
- * All exceptions are caught because the library may
- * have been loaded already.
- */
- try {
- System.loadLibrary("jawt");
- } catch (Throwable e) {}
- Library.loadLibrary("swt-awt");
-}
-
-static synchronized void initializeSwing() {
- if (swingInitialized) return;
- swingInitialized = true;
- try {
- /* Initialize the default focus traversal policy */
- Class[] emptyClass = new Class[0];
- Object[] emptyObject = new Object[0];
- Class clazz = Class.forName("javax.swing.UIManager");
- Method method = clazz.getMethod("getDefaults", emptyClass);
- if (method != null) method.invoke(clazz, emptyObject);
- } catch (Throwable e) {}
-}
-
-/**
- * Returns 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
- * with the SWT.EMBEDDED style.
- * <p>
- * IMPORTANT: As of JDK1.5, the embedded frame does not receive mouse events.
- * When a lightweight component is added as a child of the embedded frame,
- * the cursor does not change. In order to work around both these problems, it is
- * strongly recommended that a heavyweight component such as <code>java.awt.Panel</code>
- * be added to the frame as the root of all components.
- * </p>
- *
- * @param parent the parent <code>Composite</code> of the new <code>java.awt.Frame</code>
- * @return a <code>java.awt.Frame</code> to be the parent of the embedded AWT components
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent Composite does not have the SWT.EMBEDDED style</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Frame new_Frame (final Composite parent) {
- if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if ((parent.getStyle () & SWT.EMBEDDED) == 0) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- final int /*long*/ handle = parent.handle;
- final Frame[] result = new Frame[1];
- final Throwable[] exception = new Throwable[1];
- Runnable runnable = new Runnable () {
- public void run () {
- try {
- /*
- * Some JREs have implemented the embedded frame constructor to take an integer
- * and other JREs take a long. To handle this binary incompatibility, use
- * reflection to create the embedded frame.
- */
- Class clazz = null;
- try {
- String className = embeddedFrameClass != null ? embeddedFrameClass : "sun.awt.windows.WEmbeddedFrame";
- clazz = Class.forName(className);
- } catch (Throwable e) {
- exception[0] = e;
- return;
- }
- initializeSwing ();
- Object value = null;
- Constructor constructor = null;
- try {
- constructor = clazz.getConstructor (new Class [] {int.class});
- value = constructor.newInstance (new Object [] {new Integer ((int)/*64*/handle)});
- } catch (Throwable e1) {
- try {
- constructor = clazz.getConstructor (new Class [] {long.class});
- value = constructor.newInstance (new Object [] {new Long (handle)});
- } catch (Throwable e2) {
- exception[0] = e2;
- return;
- }
- }
- final Frame frame = (Frame) value;
- /*
- * This is necessary to make lightweight components
- * directly added to the frame receive mouse events
- * properly.
- */
- frame.addNotify();
-
- /*
- * TEMPORARY CODE
- *
- * For some reason, the graphics configuration of the embedded
- * frame is not initialized properly. This causes an exception
- * when the depth of the screen is changed.
- */
- try {
- clazz = Class.forName("sun.awt.windows.WComponentPeer");
- Field field = clazz.getDeclaredField("winGraphicsConfig");
- field.setAccessible(true);
- field.set(frame.getPeer(), frame.getGraphicsConfiguration());
- } catch (Throwable e) {}
-
- result[0] = frame;
- } finally {
- synchronized(result) {
- result.notify();
- }
- }
- }
- };
- if (EventQueue.isDispatchThread() || parent.getDisplay().getSyncThread() != null) {
- runnable.run();
- } else {
- EventQueue.invokeLater(runnable);
- OS.ReplyMessage(0);
- boolean interrupted = false;
- MSG msg = new MSG ();
- int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_SENDMESSAGE;
- while (result[0] == null && exception[0] == null) {
- OS.PeekMessage (msg, 0, 0, 0, flags);
- try {
- synchronized (result) {
- result.wait(50);
- }
- } catch (InterruptedException e) {
- interrupted = true;
- }
- }
- if (interrupted) {
- Compatibility.interrupt();
- }
- }
- if (exception[0] != null) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, exception[0]);
- }
- final Frame frame = result[0];
-
- parent.setData(EMBEDDED_FRAME_KEY, frame);
-
- /* Forward the iconify and deiconify events */
- final Listener shellListener = new Listener () {
- public void handleEvent (Event e) {
- switch (e.type) {
- case SWT.Deiconify:
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEICONIFIED));
- }
- });
- break;
- case SWT.Iconify:
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ICONIFIED));
- }
- });
- break;
- }
- }
- };
- Shell shell = parent.getShell ();
- shell.addListener (SWT.Deiconify, shellListener);
- shell.addListener (SWT.Iconify, shellListener);
-
- /*
- * Generate the appropriate events to activate and deactivate
- * the embedded frame. This is needed in order to make keyboard
- * focus work properly for lightweights.
- */
- Listener listener = new Listener () {
- public void handleEvent (Event e) {
- switch (e.type) {
- case SWT.Dispose:
- Shell shell = parent.getShell ();
- shell.removeListener (SWT.Deiconify, shellListener);
- shell.removeListener (SWT.Iconify, shellListener);
- parent.setVisible(false);
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- try {
- frame.dispose ();
- } catch (Throwable e) {}
- }
- });
- break;
- case SWT.FocusIn:
- case SWT.Activate:
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 4, 0)) {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ACTIVATED));
- frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_GAINED));
- } else if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 5, 0)) {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ACTIVATED));
- frame.dispatchEvent (new WindowEvent (frame, 207 /*WindowEvent.WINDOW_GAINED_FOCUS*/));
- } else {
- if (frame.isActive()) return;
- try {
- Class clazz = frame.getClass();
- Method method = clazz.getMethod("synthesizeWindowActivation", new Class[]{boolean.class});
- if (method != null) method.invoke(frame, new Object[]{new Boolean(true)});
- } catch (Throwable e) {}
- }
- }
- });
- break;
- case SWT.Deactivate:
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 4, 0)) {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEACTIVATED));
- frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_LOST));
- } else if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 5, 0)) {
- frame.dispatchEvent (new WindowEvent (frame, 208 /*WindowEvent.WINDOW_LOST_FOCUS*/));
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEACTIVATED));
- } else {
- if (!frame.isActive()) return;
- try {
- Class clazz = frame.getClass();
- Method method = clazz.getMethod("synthesizeWindowActivation", new Class[]{boolean.class});
- if (method != null) method.invoke(frame, new Object[]{new Boolean(false)});
- } catch (Throwable e) {}
- }
- }
- });
- break;
- }
- }
- };
- if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 5, 0)) {
- parent.addListener (SWT.Activate, listener);
- } else {
- parent.addListener (SWT.FocusIn, listener);
- }
- parent.addListener (SWT.Deactivate, listener);
- parent.addListener (SWT.Dispose, listener);
-
- parent.getDisplay().asyncExec(new Runnable() {
- public void run () {
- if (parent.isDisposed()) return;
- final Rectangle clientArea = parent.getClientArea();
- EventQueue.invokeLater(new Runnable () {
- public void run () {
- frame.setSize (clientArea.width, clientArea.height);
- frame.validate ();
- }
- });
- }
- });
- return frame;
-}
-
-/**
- * Creates a new <code>Shell</code>. This Shell is the root for
- * the SWT widgets that will be embedded within the AWT canvas.
- *
- * @param display the display for the new Shell
- * @param parent the parent <code>java.awt.Canvas</code> of the new Shell
- * @return a <code>Shell</code> to be the parent of the embedded SWT widgets
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the display is null</li>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent's peer is not created</li>
- * </ul>
- *
- * @since 3.0
- */
-public static Shell new_Shell (final Display display, final Canvas parent) {
- if (display == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int /*long*/ handle = 0;
- try {
- loadLibrary ();
- handle = getAWTHandle (parent);
- } catch (Throwable e) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e);
- }
- if (handle == 0) SWT.error (SWT.ERROR_INVALID_ARGUMENT, null, " [peer not created]");
-
- final Shell shell = Shell.win32_new (display, handle);
- final ComponentListener listener = new ComponentAdapter () {
- public void componentResized (ComponentEvent e) {
- display.syncExec (new Runnable () {
- public void run () {
- if (shell.isDisposed()) return;
- Dimension dim = parent.getSize ();
- shell.setSize (dim.width, dim.height);
- }
- });
- }
- };
- parent.addComponentListener(listener);
- shell.addListener(SWT.Dispose, new Listener() {
- public void handleEvent(Event event) {
- parent.removeComponentListener(listener);
- }
- });
- shell.setVisible (true);
- return shell;
-}
-}