May 30, 2008

To View or not to View ...

Newbies to Eclipse plugin development will face this dilemma: whether to make xyz a view or an editor. During a training session one of the attendees said, "the choice is simple, if its full of various UI widgets, it would probably better to be a view and if its full of text, then it goes as an editor". The other said, "editors can have multiple intances, but there can be only one instance for a view".



Actually that is not the case. I showed them the Console View (full-of-text) and the Shapes GEF Editor (full of UI). I also showed multiple instances of Console View.



To the workbench, technically there is no much difference between these two - both are IWorkbenchParts. Its more of user experience that they provide. Most of the time, your user will be spending time in viewing and editing the data. It goes natural to give an editor to do all the editing stuff. Views generally do the navigation part and stay as helpers to the editors.



I could see only two differences views & editors:

  • Editors contribute to the global action bars, and views to its local action bar.

  • In the layout, editors have a special place called editorArea where all the editors will go. Views can go anywhere else, including fast views, detachable ones, etc.



But what about the "saving" thing? Views doesn't support "Save" or "Save As..."?

Well, by default it doesn't support. In case you ever need to do a Save from your view, just make your ViewPart to implement ISaveablePart, you will have the Save & Save As action items will enabled. If your view becomes dirty, workbench will show the * hint in the title. Here is the screen shot of the SampleView implementing ISaveablePart and in dirty state:







Update[3-Jun-2008]

Dave on View versus Editor in RCP

Tom on What is the difference between a view and editor

3 comments:

Kevin McGuire said...

Editors were intended as the place you did the meat of your work. Thus they get an edit-save lifecycle which supports extended modification cycles. Although you can save from a view it's instantaneous.

I say "were" because we've seen some interesting workflows which require a lot of real estate, which are the main focus of the task, and which don't conform well to being editors. IBM Jazz has some of these cases. The role of editors vs. views is certainly something worth visiting in e4.

Matthias said...

Thank you for this tipp. Saving resources behind a view made me a lot of headcache - but it can be that simple! I love it =)!

Anator said...

Thanks for the tip. Never knew that it is possible to "save" a view.

prasad