Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 77787 - [Commands] misc: dependency on Swing and AWT
Summary: [Commands] misc: dependency on Swing and AWT
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P2 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Douglas Pollock CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 80053
  Show dependency tree
 
Reported: 2004-11-03 18:27 EST by Jim des Rivieres CLA
Modified: 2005-05-11 15:05 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim des Rivieres CLA 2004-11-03 18:27:15 EST
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.
Comment 1 Jim des Rivieres CLA 2004-11-04 09:36:32 EST
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.
Comment 2 Jim des Rivieres CLA 2004-11-04 09:46:01 EST
This fix was ported to the 3.0.* maintenance stream and is also present in the 
3.0.1 release.
Comment 3 Douglas Pollock CLA 2004-11-04 11:33:59 EST
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? 
 
Comment 4 Jim des Rivieres CLA 2004-11-04 12:09:32 EST
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.
Comment 5 Douglas Pollock CLA 2005-04-21 12:14:06 EDT
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.
Comment 6 Douglas Pollock CLA 2005-05-11 15:05:15 EDT
Verified by inspection of the code in I20050509-2010.