Eclipse Search

Loading

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

0 comments:

Post a Comment