使用Eclipse Workbench的小技巧
Perspective 設計
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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
1 2 3 4 5 6 7 |
ActionFactory.CLOSE_PERSPECTIVE.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow()).run(); try { PlatformUI.getWorkbench().showPerspective("com.slab.MainPerspective", PlatformUI.getWorkbench().getActiveWorkbenchWindow()); } catch (WorkbenchException e) { e.printStackTrace(); } |