Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to open modal Swing dialog from Eclipse
How to open modal Swing dialog from Eclipse [message #462245] Sun, 09 October 2005 13:59 Go to next message
Eclipse UserFriend
Originally posted by: hans_martin_.gmx.de

I am developing an Eclipse plugin using some Swing classes. What is the
correct way of opening Swing dialogs from SWT? From an
org.eclipse.jface.action.Action I can open the dialog without problems
using SwingUtilities.invokeLater(...) where the dialog is opened in the
Runnable, but the resulting dialog is not modal.

I guess I haven't fully understood the event handling - are there any
online documents explaining the AWT-SWT threading issues?

Any help appreciated
Hans
Re: How to open modal Swing dialog from Eclipse [message #462251 is a reply to message #462245] Sun, 09 October 2005 21:55 Go to previous messageGo to next message
Haris Peco is currently offline Haris PecoFriend
Messages: 1072
Registered: July 2009
Senior Member
Hans Martin wrote:

> I am developing an Eclipse plugin using some Swing classes. What is the
> correct way of opening Swing dialogs from SWT? From an
> org.eclipse.jface.action.Action I can open the dialog without problems
> using SwingUtilities.invokeLater(...) where the dialog is opened in the
> Runnable, but the resulting dialog is not modal.
>
> I guess I haven't fully understood the event handling - are there any
> online documents explaining the AWT-SWT threading issues?
>
> Any help appreciated
> Hans
Open swt dialog and put swing control in
Re: How to open modal Swing dialog from Eclipse [message #462253 is a reply to message #462251] Sun, 09 October 2005 21:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hans_martin_.gmx.de

> Open swt dialog and put swing control in

I thought about this as well, but is this the only way? The pure Swing
dialog shows up nicely and it would be quite an overhead if I had to
reimplement control logic for close, ok etc. Furthermore I would need to
change the dialog launching code everywhere in the Swing code.

Also, assuming I do this, how can I then ensure that the Swing thread
"waits" until the SWT dialog is closed?

Thanks for any clarification
Hans
Re: How to open modal Swing dialog from Eclipse [message #462254 is a reply to message #462253] Mon, 10 October 2005 01:58 Go to previous messageGo to next message
Haris Peco is currently offline Haris PecoFriend
Messages: 1072
Registered: July 2009
Senior Member
Hans,
Hans Martin wrote:
>> Open swt dialog and put swing control in
>
> I thought about this as well, but is this the only way?
I don't sure
> The pure Swing
> dialog shows up nicely and it would be quite an overhead if I had to
> reimplement control logic for close, ok etc. Furthermore I would need to
> change the dialog launching code everywhere in the Swing code.
>
create simple swt dialog and in composite add your swing control (panel from
swing dialog)
> Also, assuming I do this, how can I then ensure that the Swing thread
> "waits" until the SWT dialog is closed?
>
capture shell events

Peco
Re: How to open modal Swing dialog from Eclipse [message #462329 is a reply to message #462245] Mon, 10 October 2005 16:17 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
You do have a second option which is to use the SWT_AWT.getFrame(Composite) method. This will return an instance of Frame which you can then use to parent your dialog. AFAIK, it should be modal after that.

You can wrap an SWT Shell around your existing dialog, and SWT will provide all the functionality of the Swing version. However, I do agree that it's a major overhead (not to mention maintenance problem) to do so.
Re: How to open modal Swing dialog from Eclipse [message #462376 is a reply to message #462329] Tue, 11 October 2005 15:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hans_martin_.gmx.de

Daniel Spiewak wrote:

> You do have a second option which is to use the SWT_AWT.getFrame(Composite)
method. This will return an instance of Frame which you can then use to
parent your dialog. AFAIK, it should be modal after that.

This is essentially what I am doing now, but the dialog is not modal.
getFrame would just return the WEmbeddedFrame which I also get by asking
any nested Swing component for its top level ancester. Since the embedded
frame is part of the overall Eclipse Shell, the Shell is not blocked.


> You can wrap an SWT Shell around your existing dialog, and SWT will provide
all the functionality of the Swing version. However, I do agree that it's a
major overhead (not to mention maintenance problem) to do so.

Unless someone else has some good ideas, I really have to wrap all Swing
dialogs with SWT Shells :( I would consider this a serious flaw in the
SWT_AWT class.
Re: How to open modal Swing dialog from Eclipse [message #462378 is a reply to message #462376] Tue, 11 October 2005 20:22 Go to previous message
Haris Peco is currently offline Haris PecoFriend
Messages: 1072
Registered: July 2009
Senior Member
Do you try frame.setAlwaysOnTop(true) ?

Hans Martin wrote:

> Daniel Spiewak wrote:
>
>> You do have a second option which is to use the
>> SWT_AWT.getFrame(Composite)
> method. This will return an instance of Frame which you can then use to
> parent your dialog. AFAIK, it should be modal after that.
>
> This is essentially what I am doing now, but the dialog is not modal.
> getFrame would just return the WEmbeddedFrame which I also get by asking
> any nested Swing component for its top level ancester. Since the embedded
> frame is part of the overall Eclipse Shell, the Shell is not blocked.
>
>
>> You can wrap an SWT Shell around your existing dialog, and SWT will
>> provide
> all the functionality of the Swing version. However, I do agree that it's
> a major overhead (not to mention maintenance problem) to do so.
>
> Unless someone else has some good ideas, I really have to wrap all Swing
> dialogs with SWT Shells :( I would consider this a serious flaw in the
> SWT_AWT class.
Previous Topic:StyledText and different font size
Next Topic:Need help on running SWT/OpenGL demos
Goto Forum:
  


Current Time: Sat Apr 20 01:32:33 GMT 2024

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

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

Back to the top