Thanks.
>>>Hello,
>>>
>>>We are developing a
plugin on Eclipse. We also use a third-party
>>>Swing-based
graphical package for its sophisticated graphical
editing
>>>functions. In our proof-of-concept demo, we have
successfully launch the
>>>Swing-based application using
swing-in-process approach and also launched
>>>SWT ApplicationWindow
from the Swing widget on Windows platform.
>>>
>>>Here
are my concerns/questions:
>>>
>>>1. As I understand,
SWT has its own event model than the Swing/AWT event
>>>model. How
will these two different event models interact with the
>>>platform
event loop in the Swing-in-process approach? Do both SWT and
AWT
>>>event model try to read and dispatch the platform event loop?
Where can I
>>>find in-depth articles about the SWT threading/event
model?
>>>
>
>
>>The event loops run on
different threads in your VM. In a scenario where
>>the Swing
components run in an external frame, there is next to none
>>interaction, they run separate event loops. You do need to avoid
>>deadlocks, of course, if you have communication between the two GUI
>>clients. You may not call SWT from the Swing thread or vice versa,
if
>>you do, you'll notice pretty fast. :-) For one story on Swing/SWT
>>interaction, see
http://www.csr.uvic.ca/shrimpviews/shrimp.pdf.
>>
>
>>If you would like to run full Swing in an SWT Canvas widget at
native
>>Swing speed, see my earlier post today. Using that software,
you can put
>>any Swing, Java 2D etc. anywhere you can put an SWT
Canvas widget,
>>inside your Eclipse workbench.
>>
>
>
>>>2. Will the approach that I use in the demo cause any
potential performace
>>>problems? Our real swing application has
much more complicate controls
>>>than the simple JButton. Here are
the snippet of my demo.
>>>
>
>
>>No, I don't
think so.
>>
>
>
>>>Launch Swing application
from Eclipse
plugin:
>>>-------------------------------------------------------
>>>public
class HelloView extends ViewPart {
>>> public void
createPartControl(Composite parent) {
>>>
...
>>> SelectionListener selectionListener = new
SelectionAdapter() {
>>> public void widgetSelected(SelectionEvent
event)
{
>>> ...
>>> launchSwingWidget
();
>>> };
>>> };
>>> swingButton.addSelectionListener(selectionListener);
>>>
}
>>>
>>>
>>>
>>> public void launchSwingWidget()
{
>>>
>>>
...
>>>
>>>
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>>>
frame.pack();
>>>
frame.setVisible(true);
>>>
}
>>>}
>>>
>>>Launch SWT
ApplicationWindow from the Swing
widget:
>>>---------------------------------------------------------
>>>
>>>public
class SwingApplication {
>>>
>>>
public Component createComponents()
{
>>>
...
>>>
button.addActionListener(new ActionListener()
{
>>>
>>>
public void actionPerformed(ActionEvent e)
{
>>> Display.getDefault().syncExec(new Runnable()
{
>>> public void run() {
>>> ApplicationWindow
swtWindow =
new
>>>ApplicationWindow(Display.getCurrent().getActiveShell());
>>> swtWindow.open();
>>> }
>>> });
>>>
>>>
}
>>>
});
>>>}
>>>
>>>Thanks,
>>>
>>>Xiaoping