当 Rich Client 应用程序使用 WorkbenchAdvisor 作为定制工作台的主要方法时,它必须提供显示在工作台窗口中的透视图。必须在应用程序的工作台顾问程序类中标识此透视图。在 BrowserAdvisor 类中指定了以下内容:
public String getInitialWindowPerspectiveId() {
return BrowserApp.BROWSER_PERSPECTIVE_ID;
}
而 BrowserApp 定义了:
public static final String PLUGIN_ID = "org.eclipse.ui.examples.rcp.browser";
public static final String BROWSER_PERSPECTIVE_ID = PLUGIN_ID + ".browserPerspective";
在浏览器插件的清单中定义了相应的透视图:
<extension
point="org.eclipse.ui.perspectives">
<perspective
id="org.eclipse.ui.examples.rcp.browser.browserPerspective"
name="%perspectives.browser.name"
class="org.eclipse.ui.examples.rcp.browser.BrowserPerspectiveFactory"
fixed="true"/>
</extension>
BrowserPerspectiveFactory 负责适当地布置视图。
public void createInitialLayout(IPageLayout layout) {
layout.addView(BrowserApp.BROWSER_VIEW_ID, IPageLayout.RIGHT, .25f, IPageLayout.ID_EDITOR_AREA);
layout.addPlaceholder(BrowserApp.HISTORY_VIEW_ID, IPageLayout.LEFT, .3f, IPageLayout.ID_EDITOR_AREA);
IViewLayout historyLayout = layout.getViewLayout(BrowserApp.HISTORY_VIEW_ID);
historyLayout.setCloseable(true);
layout.setEditorAreaVisible(false);
}
浏览器透视图定义了两个视图(一个视图可视,另一个视图用占位符表示),并且使编辑器区域不可视。有关透视图及其相应布局的完整讨论,请参阅透视图。