fbpx

Eclipse Rich Client Platform - Perspective Tips

使用Eclipse Workbench的小技巧


Perspective 設計

public class MainPerspective implements IPerspectiveFactory {

    public static String ID = "com.slab.MainPerspective";

    public void createInitialLayout(IPageLayout layout) {
        layout.setEditorAreaVisible(false);

        layout.addView(TreeView.ID, IPageLayout.TOP, 0.25f, layout.getEditorArea());

        layout.setEditorAreaVisible(false);
        layout.addView(LoginView.ID, IPageLayout.LEFT, 1f, layout.getEditorArea());
        layout.addView(WelcomeView.ID, IPageLayout.LEFT, 1f, layout.getEditorArea());

        IViewLayout vl = layout.getViewLayout(WelcomeView.ID);
        // 設定View不可關閉
        layout.getViewLayout(WelcomeView.ID).setCloseable(false);
        // 設定View不可移動
        layout.getViewLayout(WelcomeView.ID).setMoveable(false);
    }

}

使用 Action 顯示 Perspective

ActionFactory.CLOSE_PERSPECTIVE.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow()).run();

try {
    PlatformUI.getWorkbench().showPerspective("com.slab.MainPerspective", PlatformUI.getWorkbench().getActiveWorkbenchWindow());
} catch (WorkbenchException e) {
    e.printStackTrace();
}

 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料