使用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(); }