Ok, I have a(n) RCP application (that I didn't write), and an application I've developed using just SWT. What I want to do is basically imp开发者_如何学Pythonort and launch the main method of the SWT application with arguments, such that it runs in another window, like it's another process. The argument I want to pass is a complex data structure that I don't want to serialize.
I originally thought I could just design my SWT app to be a library and import it, have it spawn its shell, etc. But I neglected to think about how the SWT app's main loop has to run on the main thread, which seems problematic. So I started looking into integrating it with the eclipse plugin architecture. Problem: I don't know anything about the eclipse plugin architecture or RCP, and when I try to learn, I run into an inscrutable wall of things that are totally unlike what I want to do (ie building new buttons onto the eclipse workbench). How do I get started developing a plugin that just launches another window?
You will need some kind of button to launch your application so just must hook into the Eclipse menu system.
Try:
1) In Eclipse, File -> New Project-> Plug-in project
2) Make sure you check "This plug-in will make contributions to the ui"
3) Uncheck "generate activator" since you won't be needing it
4) Select "Hello World command" from the code template
Now you will have a sample handler and a method called execute where you could call your SWT-application with the display you're using in the RCP-application. If you really must call void main(String[] args) you could get the display by calling Display.getDefault(), which will either create a new display or use the one from the RCP-application.
You will also have to modify the plugin.xml file so it points to the correct menu in your RCP-application. If you want your launch command to be in the file menu etc.
Finally, right-click on your project and select Export -> Plug-in Development and create a jar-file where you launcher will be in. Drop that jar into the plugins folder of the RCP-application and you should be able to launch the SWT-application from the command you've just created.
There will probably be a couple of bumps on the way, but that's roughly what you will have to do.
精彩评论