This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 67934 - API for running modules code when UI is ready
Summary: API for running modules code when UI is ready
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: David Simonek
URL:
Keywords: API, UI
: 58347 (view as bug list)
Depends on:
Blocks: 83954
  Show dependency tree
 
Reported: 2005-11-01 16:31 UTC by David Simonek
Modified: 2008-12-22 21:12 UTC (History)
9 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
diff of proposed solution (25.64 KB, patch)
2006-08-23 16:27 UTC, David Simonek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Simonek 2005-11-01 16:31:07 UTC
Scenario: Modules needs to run a piece of their code in specific time, right
after UI of the system is ready. Currently, the only way to achieve this is to
listen to main window opening, which is ugly hack and have some other bad
consequences, see 65431.

Usage examples: 
- Java core needs to run classpath scanning if some projects are open.
- autoupdate needs to check for uvailable updates

Yarda already solved this issue by writing new API which passed fast track API
review, see attachments in issue 65431.
Comment 1 Jaroslav Tulach 2005-11-01 18:27:01 UTC
This is the proposed API and some implementation: 
 
http://www.netbeans.org/nonav/issues/showattachment.cgi/26122/p.diff 
Comment 2 David Simonek 2006-08-23 16:26:06 UTC
Hi, I slightly modified Jarda's work and I'm prepare to integrate into main
trunk. I'll attach new diff, almost the same as original Jarda's work.

Given that this API already passed API review, here is just description on my
little changes:

- I renamed WindowManager.invokeExclusively(Runnable) to
WindowManager.invokeWhenUIReady(Runnable). 
Such API is easier to understand and javadoc can be hore helpful, because method
is less generic. I saw no value (no use case) of having semantically generic
method for WindowManager implementations that would invoke given runnable at
unspecified time. That's why I chose easier to learn and use, less generic API.

- updated docs, api changes and spec version. Cleaner code because of generics use.

I noone objects, I'll integrate tomorrow, thanks.
Comment 3 David Simonek 2006-08-23 16:27:19 UTC
Created attachment 33205 [details]
diff of proposed solution
Comment 4 Jesse Glick 2006-08-23 18:49:32 UTC
Why does AU still call

RequestProcessor.getDefault().post(updateChecker, 5000);

rather than simply

updateChecker.run()

?


Perhaps

if (! Boolean.getBoolean("netbeans.full.hack") && !
Boolean.getBoolean("netbeans.close")) {

could be moved into WM.iWUIR()? To reduce the number of places where these
system properties are referred to?


AU should dep on o.o.windows 6.8.


+     /**
+      * {@inheritDoc}
+      */

is unnecessary (even for a non-API class!); Javadoc is inherited by default.


WindowSystemCompatibilityTest could be simplified using o.n.junit.MockServices.


Default impl in WindowManager.java should just call

EventQueue.invokeLater(run);

Failing that, DummyWindowManager.java should include an override with that body.


{@link SwingUtilities#invokeLater} => {@link EventQueue#invokeLater}
Comment 5 Jiri Rechtacek 2006-08-24 07:42:43 UTC
Jesse, the 5000 delay was motivated to wait while Window system is warming up.
If the patch ensures that the Window System is up then not need to delay anymore. 
Need to test it. Thanks
Comment 6 David Simonek 2006-08-24 17:05:51 UTC
Jesse, I updated the code according to your advices. Thanks a lot.
Comment 7 David Simonek 2006-08-25 14:25:45 UTC
API + impl integrated into main trunk:

Checking in autoupdate/src/org/netbeans/modules/autoupdate/Autoupdater.java;
/cvs/autoupdate/src/org/netbeans/modules/autoupdate/Autoupdater.java,v  <-- 
Autoupdater.java
new revision: 1.58; previous revision: 1.57
done
Checking in core/windows/src/org/netbeans/core/windows/WindowManagerImpl.java;
/cvs/core/windows/src/org/netbeans/core/windows/WindowManagerImpl.java,v  <-- 
WindowManagerImpl.java
new revision: 1.45; previous revision: 1.44
done
Checking in core/windows/nbproject/project.xml;
/cvs/core/windows/nbproject/project.xml,v  <--  project.xml
new revision: 1.18; previous revision: 1.17
done
Checking in java/javacore/nbproject/project.xml;
/cvs/java/javacore/nbproject/project.xml,v  <--  project.xml
new revision: 1.18; previous revision: 1.17
done
Checking in openide/windows/manifest.mf;
/cvs/openide/windows/manifest.mf,v  <--  manifest.mf
new revision: 1.9; previous revision: 1.8
done
Checking in openide/windows/apichanges.xml;
/cvs/openide/windows/apichanges.xml,v  <--  apichanges.xml
new revision: 1.6; previous revision: 1.5
done
Checking in java/javacore/src/org/netbeans/modules/javacore/JavaCoreModule.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/JavaCoreModule.java,v  <--
 JavaCoreModule.java
new revision: 1.19; previous revision: 1.18
done
Checking in openide/windows/src/org/openide/windows/WindowManager.java;
/cvs/openide/windows/src/org/openide/windows/WindowManager.java,v  <-- 
WindowManager.java
new revision: 1.9; previous revision: 1.8
done
Checking in autoupdate/nbproject/project.xml;
/cvs/autoupdate/nbproject/project.xml,v  <--  project.xml
new revision: 1.22; previous revision: 1.21
Comment 8 David Simonek 2006-08-25 14:40:59 UTC
tests integrated:

Checking in WindowManagerHid.java;
/cvs/openide/windows/test/unit/src/org/openide/windows/WindowManagerHid.java,v 
<--  WindowManagerHid.java
initial revision: 1.1
done
RCS file:
/cvs/openide/windows/test/unit/src/org/openide/windows/WindowSystemCompatibilityTest.java,v
done
Checking in WindowSystemCompatibilityTest.java;
/cvs/openide/windows/test/unit/src/org/openide/windows/WindowSystemCompatibilityTest.java,v
 <--  WindowSystemCompatibilityTest.java
initial revision: 1.1

Checking in WMCompatTest.java;
/cvs/core/windows/test/unit/src/org/netbeans/core/windows/WMCompatTest.java,v 
<--  WMCompatTest.java
initial revision: 1.1
Comment 9 David Simonek 2006-08-29 11:16:49 UTC
*** Issue 58347 has been marked as a duplicate of this issue. ***