Eclipse RCP Meets Spring: A Perfect Thick-Client Match : Page 2
Eclipse Rich Client Platform (RCP) is fast becoming the framework of choice for building thick client applications. Get a step-by-step guide to leveraging Eclipse RCP with Spring.
by Stephen Lum
Jun 22, 2006
Page 2 of 5
Refactoring the Default View Class
As you can see, the Eclipse wizard created a class for you called View. Not very helpful, is it? Take the following steps to refactor the default view class:
Let's rename it by right clicking on View.java in the Package Explorer. Go to Refactor -> Rename. For new name, enter ExplorerView and click Preview. In the panel that pops up, you will see that the Perspective class will be refactored to use ExplorerView.ID instead of View.ID (see Figure 6). Click OK.
Unfortunately, Eclipse's refactoring is a bit weak--especially compared with IntelliJ's. For a refactoring like this, IntelliJ would not only change the class as expected, it would apply the refactor against your .xml files as well! This is invaluable, especially in a Spring/Hibernate/XML config-heavy world. But I digress…
You must update the refactoring in plugin.xml manually. Open plugin.xml, and click on the plugin.xml tab. Find the extension for View, and update as follows:
Figure 7. More Refactoring Update Plugin.XML Manually
That should be it for this very simple refactor, right? I'd like to say yes, but sadly you are not done. Open class ExplorerView. Change the static variable ID to be initialized to EclipseTradeClient.explorerView. This corresponds to the ID you just set in plugin.xml.
Finally, you are finished with the refactor. Now, let's test that everything was changed correctly. Go back to plugin.xml in the editor, and click the Overview tab. Click Launch an Eclipse application, which should result in Figure 8.
Now let's change the names of the nodes. Open class ExplorerView. Find the inner class ViewContentProvider, and change method Object getElements(Object parent) to return a string array of "Watch List", "Order History":