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.
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.
This is the proposed API and some implementation: http://www.netbeans.org/nonav/issues/showattachment.cgi/26122/p.diff
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.
Created attachment 33205 [details] diff of proposed solution
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}
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
Jesse, I updated the code according to your advices. Thanks a lot.
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
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
*** Issue 58347 has been marked as a duplicate of this issue. ***