Community
Participate
Working Groups
3.1 stream (HEAD) org.eclipse.ui.workbench plug-in org.eclipse.ui.internal.commands.ws.WidgetMethodHandler import java.awt.Component; import javax.swing.FocusManager; import javax.swing.SwingUtilities; The fix for bug 63235 introduced an explicit dependency on Swing and AWT into the Eclipse Platform code base. We've always been careful to avoid any compile- time/link-time dependencies on Swing and AWT. That way customers can run the Eclipse Platform with reduced class libraries, and not have to have the full set of javax libraries. These compile-time/link-time dependencies should be removed. It necessary, they should be replaced by equivalent reflective code without compile- time/link-time dependencies.
I should add that a reflective solution should only be considered as a last ditch solution. I'd first consider ways for the Swing/AWT-aware plug-in to register the necessary piece of code with the platform. This would keep the Swing dependencies all together.
This fix was ported to the 3.0.* maintenance stream and is also present in the 3.0.1 release.
I could do this via reflection. What do you propose in the way of registration? However, I'm curious about something. SWT_AWT (in "org.eclipse.swt") imports AWT. "org.eclipse.ui.workbench" depends on "org.eclipse.swt". Is this just a case of relying on the fact the class loader will not load SWT_AWT?
Yep. The class SWT_AWT (in the org.eclipse.swt.awt package) only gets loaded if someone references it. In embedded configurations of SWT (e.g., Win CE), this class is omitted entirely. As for ways to do it without reflection, I haven't any concrete suggestions. I trust you'll find a good solution.
There were two options I saw. I could create two fragments: a Swing-enabled fragment and a normal fragment, each providing the requisite handler. Or, I could just use reflection and fail out when the classes aren't available. At this stage in the game, it seems safer to use reflection. And this is what I've done.
Verified by inspection of the code in I20050509-2010.