+
Added the TopComponent
ability to bring their parent
Window
to front of other windows.
Index: openide/windows/test/unit/src/org/openide/windows/WindowSystemCompatibilityTest.java
*** /doma/jarda/netbeans-src/openide/windows/test/unit/src/org/openide/windows/WindowSystemCompatibilityTest.java
--- /doma/jarda/netbeans-src/openide/windows/test/unit/src/org/openide/windows/WindowSystemCompatibilityTest.java
***************
*** 1,0 ****
--- 1,96 ----
+ /*
+ * Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+ package org.openide.windows;
+
+ import junit.framework.*;
+ import org.openide.util.Lookup;
+ import org.openide.util.lookup.AbstractLookup;
+ import org.openide.util.lookup.InstanceContent;
+ import org.openide.util.lookup.Lookups;
+ import org.openide.util.lookup.ProxyLookup;
+
+ /** Tests that a window system implementation conforms to the expected
+ * behaviour.
+ *
+ * @author Jaroslav Tulach
+ */
+ public final class WindowSystemCompatibilityTest extends Object {
+ /** initialize the lookup for the test */
+ public static void init() {
+ System.setProperty("org.openide.util.Lookup", WindowSystemCompatibilityTest.class.getName() + "$Lkp");
+
+ Object o = Lookup.getDefault();
+ if (!(o instanceof Lkp)) {
+ Assert.fail("Wrong lookup object: " + o);
+ }
+ }
+
+ private WindowSystemCompatibilityTest(String testName) {
+ }
+
+ /** Checks the default implementation.
+ */
+ public static Test suite() {
+ return suite(null);
+ }
+
+ /** Executes the test for provided window manager.
+ */
+ public static Test suite(WindowManager wm) {
+ init();
+
+ Object o = Lookup.getDefault();
+ Lkp l = (Lkp)o;
+ l.assignWM(wm);
+
+ if (wm != null) {
+ Assert.assertEquals("Same engine found", wm, WindowManager.getDefault());
+ } else {
+ o = WindowManager.getDefault();
+ Assert.assertNotNull("Engine found", o);
+ Assert.assertEquals(DummyWindowManager.class, o.getClass());
+ }
+
+ TestSuite ts = new TestSuite();
+ ts.addTestSuite(WindowManagerHid.class);
+
+ return ts;
+ }
+
+ /** Default lookup used in the suite.
+ */
+ public static final class Lkp extends ProxyLookup {
+ private InstanceContent ic;
+
+ public Lkp() {
+ super(new Lookup[0]);
+
+ ic = new InstanceContent();
+ AbstractLookup al = new AbstractLookup(ic);
+
+ setLookups(new Lookup[] {
+ al, Lookups.metaInfServices(Lkp.class.getClassLoader())
+ });
+ }
+
+ final void assignWM(WindowManager executionEngine) {
+ // ic.setPairs(java.util.Collections.EMPTY_LIST);
+ if (executionEngine != null) {
+ ic.add(executionEngine);
+ }
+ }
+
+
+ }
+
+ }
Index: openide/windows/test/build-unit.xml
*** /doma/jarda/netbeans-src/openide/windows/test/build-unit.xml
--- /doma/jarda/netbeans-src/openide/windows/test/build-unit.xml
***************
*** 1,0 ****
--- 1,24 ----
+
+
+
+
+
+
+
+
+
+
+
+
Index: openide/windows/test/build.xml
*** /doma/jarda/netbeans-src/openide/windows/test/build.xml
--- /doma/jarda/netbeans-src/openide/windows/test/build.xml
***************
*** 1,0 ****
--- 1,26 ----
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: openide/windows/test/cfg-unit.xml
*** /doma/jarda/netbeans-src/openide/windows/test/cfg-unit.xml
--- /doma/jarda/netbeans-src/openide/windows/test/cfg-unit.xml
***************
*** 1,0 ****
--- 1,34 ----
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: openide/windows/manifest.mf
*** /doma/jarda/netbeans-src/openide/windows/manifest.mf
--- /doma/jarda/netbeans-src/openide/windows/manifest.mf
***************
*** 1,5 ****
Manifest-Version: 1.0
OpenIDE-Module: org.openide.windows
! OpenIDE-Module-Specification-Version: 6.3
OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties
--- 1,5 ----
Manifest-Version: 1.0
OpenIDE-Module: org.openide.windows
! OpenIDE-Module-Specification-Version: 6.4
OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties
Index: openide/windows/src/org/openide/windows/WindowManager.java
*** /doma/jarda/netbeans-src/openide/windows/src/org/openide/windows/WindowManager.java
--- /doma/jarda/netbeans-src/openide/windows/src/org/openide/windows/WindowManager.java
***************
*** 452,453 ****
--- 452,474 ----
* @since 4.15 */
public abstract TopComponent findTopComponent(String tcID);
+ /** Provides support for executing a piece of code in 'exclusive' manner,
+ * at the 'right' time. The behaviour is similar to {@link SwingUtilities#invokeLater}
+ * moreover it is guaranteed that only one Runnable runs at given time.
+ * This method can be invoked from any thread.
+ *
+ *
+ * The typical usecase is to call this method during startup of NetBeans
+ * based application. The default manager then waits till the main window
+ * is opened and then executes all the registered methods one by one.
+ *
+ * @param run the runnable that executes the exclusive code
+ * @since 6.4
+ */
+ public void invokeExclusively(Runnable run) {
+ SwingUtilities.invokeLater(run);
+ }
+
/** A manager that handles operations on top components.
* It is always attached to a {@link TopComponent}.
* @deprecated Do not use anymore. This interface is replaced by bunch of protedcted methods
Index: openide/windows/test/unit/src/org/openide/windows/WindowManagerHid.java
*** /doma/jarda/netbeans-src/openide/windows/test/unit/src/org/openide/windows/WindowManagerHid.java
--- /doma/jarda/netbeans-src/openide/windows/test/unit/src/org/openide/windows/WindowManagerHid.java
***************
*** 1,0 ****
--- 1,89 ----
+ /*
+ * Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+ package org.openide.windows;
+
+ import java.security.AllPermission;
+ import java.security.CodeSource;
+ import java.security.PermissionCollection;
+ import java.security.Permissions;
+ import javax.swing.SwingUtilities;
+ import junit.framework.TestCase;
+ import org.netbeans.junit.NbTestCase;
+ import org.openide.util.Lookup;
+
+ /** A piece of the test compatibility suite for the execution APIs.
+ *
+ * @author Jaroslav Tulach
+ */
+ public class WindowManagerHid extends NbTestCase {
+
+ public WindowManagerHid(String testName) {
+ super(testName);
+ }
+
+ public void testGetDefault() {
+ WindowManager result = WindowManager.getDefault();
+ assertNotNull(result);
+ }
+
+ public void testInvokeExclusively() throws Exception {
+ class R implements Runnable {
+ public boolean started;
+ public boolean finished;
+ public boolean block;
+
+ public synchronized void run() {
+ assertTrue("Runs only in AWT thread", SwingUtilities.isEventDispatchThread());
+ try {
+ started = true;
+ notifyAll();
+ if (block) {
+ wait();
+ }
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ finished = true;
+ notifyAll();
+ }
+ }
+
+ R run = new R();
+ R snd = new R();
+
+ WindowManager wm = WindowManager.getDefault();
+ synchronized (run) {
+ wm.invokeExclusively(run);
+ run.block = true;
+ run.wait();
+ }
+ assertTrue("started", run.started);
+ assertFalse("but not finished", run.finished);
+
+ wm.invokeExclusively(snd);
+
+ Thread.sleep(100);
+
+ assertFalse("Not started", snd.started);
+ synchronized (snd) {
+ synchronized (run) {
+ run.notifyAll();
+ run.wait();
+ }
+ assertTrue("run is finished", run.finished);
+ snd.wait();
+ assertTrue("snd also finished", snd.finished);
+ }
+ }
+ }