當 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";
對應的視景是定義在瀏覽器外掛程式的 Manifest 中︰
<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); }
瀏覽器視景定義兩個視圖(一個可見,另一個有位置保留區),並且將編輯區隱藏。如果需要視景與其對應佈置的完整討論,請參閱 視景。