Developing an Eclipse RCP application

空扰寡人 提交于 2019-12-20 10:55:45

问题


It's my first time to develop an RCP application with Eclipse 3.8. My question may seem weird but it is really confusing for me. Where can I put the code for my application? If I create the needed classes for my app where can I use their objects? In the Application.java class? I'm confused, and Internet tutorials focus only on the visual aspect and SWT, not on how to code.


回答1:


An eclipse RCP application is basically an eclipse plugin.

I suggest starting off with an RCP application based on a simple template (e.g., the Hello World template). To create such an application, create a new plug-in project (New > Other > Plug-in Project), set the target platform to Eclipse 3.8, let the Wizard generate an Activator, tick the checkboxes "This plug-in will make contributions to the UI" and "Would you like to create a rich client application: Yes", and choose any of the available templates on the next wizard page.

Have a good look at the generated classes. You're right in assuming that basically Application.java is the starting point of your application. However, note that an Eclipse plug-in is an OSGi(-compliant) bundle, so there's also the plug-in/bundle activator. Something to also keep in mind is that one of the general configuration points is the plugin.xml and its extensions tab.

I suggest that you have a good look at some of the tutorials available (there are a few which help you get started without just focusing on the graphics level, although it is important that you get yourself accustomed to, e.g., the SWT and JFace APIs). I personally gained a lot from reading McAffer et al.s Eclipse RCP book.

There is a blog post which lists a number of options to get started with the Eclipse RCP. (Disclaimer: Shameless self-promotion)

Hope this helps.




回答2:


what i've realized is, the generated classes in a RCP project folder are only to manage the lifecycle and appearance of the RCP application, that's it.

For everything else we want our application to do, we need to write seperate classes.

For eg, if you created a view (class that implements IViewPart interface) then u need to add that view to the RCP application using plugin.xml file.

following is a short description of these classes (what basically they do)

  • Application.java - starting point of application, similar to main(-) method.
  • WorkbenchWindowAdvisor.java - for window size, title, menubar, toolbar, status bar configuration and visibility.
  • WorkbenchAdvisor.java - identifies the initial perspective and which WorkbenchWindowAdvisor to use.
  • Perspective.java - arrangement of views and editors (like we have in Java Perspective, Debug Perspective in Eclipse IDE)
  • ActionBarAdvisor.java - for creating actions but the use of commands framework is encouraged (see page no.292 of Eclipse Rich Client Platform, Second Edition- by Jeff McAffer http://www.amazon.com/Eclipse-Rich-Client-Platform-Edition/dp/0321603788 )


来源:https://stackoverflow.com/questions/11239963/developing-an-eclipse-rcp-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!