您的位置:首页 > 移动开发

RCP开发中Editor与View的选择

2007-07-16 13:45 176 查看
摘录自《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.

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐