摘录自《Eclipse Rich Client Platform: Designing, Coding, and Packaging Java™ Applications》
Here, Hyperbola is the sample application used in this book, and it is a chatting application, like qq or MSN.
...views and editors contain the "real content" for your application. But how do you choose which one to use?
The rule of thumb is that editors are meant for the primary focus of attention while views provide supporting information for a given task. So, in Hyperbola, chatting is the primary task and browsing or managing contacts is a supporting function. This indicates that the Hyperbola chat area should be implemented as an editor.
Not all decisions are quite that clear-cut, however. Even the choice made here has been hotly discussed by the Hyperbola development team. It is, of course, technically possible to use a view to represent a unique chat instead of using the chat editor (an excellent exercise for the reader).
Here is a short list of differences between views and editors to help you decide which to use for your application:
-
Editors are shared between perspectives in the same window. For example, if you close an editor in one perspective, it is closed in all perspectives.
-
Editors and views cannot be mixed in the same stack. For example, you can't drag and drop views and editors into the same location in the perspective.
-
Views can be detached from a Workbench window.
-
Views can be shown without a title.
-
Editors add contributions to the main toolbar and menu whereas views add contributions to their local toolbar and menu. You can, however, associate action sets to appear when a view is active.
-
It is possible to ask for the active editor even if the editor does not have focus. This makes it easier to synchronize views with editors, for example, linking outline-style views to the current editor.