Jo Grant asked me to post this entry since he is out on vacation this week. He describes how you can develop ViewParts that can be put as components in composite applications and in the sideshelf at the same time."Any legal ViewPart can be used as a shelf view. Any legal Viewpart with allowMultiple=True can be used as a component. So it is possible to create one view that can be used as both a shelf view and a component.
However a component isn't that interesting unless it has actions or properties that let it communicate with other components. And such actions and properties are not helpful for a shelf view. So, in general this is the architecture I would recommend for reusing code between shelf views and components.
1) First create all of the custom UI you wish to make in a SWT Composite or Canvas. Be sure to include public APIs for all of the features you wish to expose or consume that relate to that UI.
2) Create a ViewPart for your sideshelf and place an instance of your Composite or Canvas upon it. Connect up whatever way you wish your sideshelf component to interact with the rest of the platform (e.g. wiring in the eclipse selection model, etc) to your control.
3) Create a ViewPart for your component and place an instance of your Composite or Canvas upon it. Create your WSDL to expose the properties and actions you wish, and within this view part connect up the property broker to your UI control.
Using this approach you have all the work of the visualization in a single place. You can then reuse that in two different places that each require different ways of linking to your display logic. If other areas come up where you wish this sort of visualization (e.g. a pop-up dialog box from a toolbar icon) you can use your UI control again.
An example: I wish to display "business cards" from my name and address book. It would be nice to do so either in the sideshelf or as a component. So the first thing I did was create a ContactPanel control subclassed from Composite. It had an API setContactID() which, when called, would search your names and address book, find the corresponding record, extract the information, and display it on it's UI.
For the component then, I created a ViewPart whose UI was one of these ContactPanels. I created a WSDL file that declared a single action to receive a contact ID. The ViewPart then contained the glue to route the calling of that action to a call to the setContactID() API on the ContactPanel.
For the sideshelf, I created a ViewPart which had a drop down combo box, and an instance of the ContactPanel. The ViewPart registered as a listener to the PropertyBroker and looked for property changes that were of an email address type. As it noted these, it used the combo box as a "most recently used" type list. When the user selected a name from the drop down, that value was passed to the setContactID() API on the ContactPanel"