站内搜索: 请输入搜索关键词
当前页面: 图书首页 > Eclipse Rich Client Platform: Designing, Coding, and Packaging Java Applications

Section 7.1.  Views and Editors - Eclipse Rich Client Platform: Designing, Coding, and Packaging Java Applications

Previous Page
Next Page

7.1. Views and Editors

Before getting into the details of how to create the chat editor, let's step back a bit and consider whether it should be a view or an editor. When you created the Contacts view in Chapter 5, "Starting the Hyperbola Prototype," we mentioned that 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.

In Section 16.2.1, "Multiple Instances of the Same View," we show that it's possible to have multiple instances of the same view, so it is possible to allow chatting from within a view, or even better, in a separate window. For now, we use the editor mainly because you already know how to create a view and this gives us a chance to look at how to use editors.


Previous Page
Next Page