Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Distinguish between event fired by a SWT and AWT / Swing component in mixed environment
Distinguish between event fired by a SWT and AWT / Swing component in mixed environment [message #730620] Wed, 28 September 2011 17:54 Go to next message
venk Missing name is currently offline venk Missing nameFriend
Messages: 12
Registered: March 2011
Junior Member
We are using a mixed UI toolkit environment (AWT / swing components hosted in eclipse IDE). The toolbar is eclipse's toolbar with SWT buttons whereas the editor is AWT / swing component (we are using legacy editors). The editor is essentially a tabbed pane containing various swing widgets such as JTextField, JTextArea, etc. One of the text widgets has a focus listener which fires a change event (focusLost) when it loses focus. However, an additional check is performed, event.isTemporary() to ensure that the we do not execute the action if the event is temporary (since we also have popups for which the event is temporary and we do not want to execute the action when a popup is shown). If I change the focus by jumping across different text components in the editor, it correctly fires the focusLost event (which also happens to be permanent). However, when I click on the Save button in the toolbar (which happens to be a SWT button), the event is fired but event.isTemporary() returns true (which I did not expect). I believe this is happening because there is a mismatch between swing and SWT event mechanisms. I also noticed that event.getOppositeComponent() returns null when I click the Save button. I would like to know if there is a better way to distinguish between the event fired when in SWT versus AWt/swing.

Thanks!
Re: Distinguish between event fired by a SWT and AWT / Swing component in mixed environment [message #730762 is a reply to message #730620] Thu, 29 September 2011 05:34 Go to previous message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 2011-09-28 19:54, venk wrote:
> We are using a mixed UI toolkit environment (AWT / swing components
> hosted in eclipse IDE). The toolbar is eclipse's toolbar with SWT
> buttons whereas the editor is AWT / swing component (we are using legacy
> editors). The editor is essentially a tabbed pane containing various
> swing widgets such as JTextField, JTextArea, etc. One of the text
> widgets has a focus listener which fires a change event (focusLost) when
> it loses focus. However, an additional check is performed,
> event.isTemporary() to ensure that the we do not execute the action if
> the event is temporary (since we also have popups for which the event is
> temporary and we do not want to execute the action when a popup is
> shown). If I change the focus by jumping across different text
> components in the editor, it correctly fires the focusLost event (which
> also happens to be permanent). However, when I click on the Save button
> in the toolbar (which happens to be a SWT button), the event is fired
> but event.isTemporary() returns true (which I did not expect). I believe
> this is happening because there is a mismatch between swing and SWT
> event mechanisms. I also noticed that event.getOppositeComponent()
> returns null when I click the Save button. I would like to know if there
> is a better way to distinguish between the event fired when in SWT
> versus AWt/swing.

IMO mixing AWT/Swing and SWT is always a problematic thing. I can say
this, because we need to do the same thing ;-)

You did not explain, *how* you perform the integration. I can only
recommend to use the last official release of Albireo with the so-called
SwingControl used as "bridge" for these two worlds. The SwingControl
composite has fixed a *lot* of focus issues and others that may occur.

It is extremely unfortunate, that this library is no longer under active
development. We still sometimes see unexpected focus-losses once in a
while, but much less compared to using the "raw" SWT_AWT bridge.

HTH & Greetings from Bremen,

Daniel Krügler
Previous Topic:Navigation buttons at top of TextEditor frame
Next Topic:How to get the "Help>Welcome" entry available
Goto Forum:
  


Current Time: Tue Nov 25 22:33:10 GMT 2014

Powered by FUDForum. Page generated in 0.02351 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software