首先申明下,本文为笔者学习《Eclipse插件开发学习笔记》的笔记,并加入笔者自己的理解和归纳总结。
1. 创建透视图
扩展点【org.eclipse.ui.perspectives】
在【extensions】中添加【org.eclipse.ui.perspectives】
在【org.eclipse.ui.perspectives】中添加【perspective】,在【class】中指定透视图类,继承IPerspectiveFactory
类。
<extension
point="org.eclipse.ui.perspectives">
<perspective
class="com.plugin.blog.demo.perspective.DemoPerspectiveFactory"
icon="icons/icon_perspective.png"
id="com.plugin.blog.demo.perspective.DemoPerspectiveFactory"
name="DemoPerspective">
</perspective>
</extension>
DemoPerspectiveFactory
类,继承IPerspectiveFactory
类。
public class DemoPerspectiveFactory implements IPerspectiveFactory {
public final static String ID_VIEW = "com.plugin.blog.demo.view.DemoViewPart";
@Override
public void createInitialLayout(IPageLayout layout) {
String editorArea = layout.getEditorArea();
IFolderLayout left = layout.createFolder("left",
IPageLayout.LEFT, 0.25f, editorArea);
left.addView(ID_VIEW);
IFolderLayout bottom = layout.createFolder("bottom",
IPageLayout.BOTTOM, 0.66f, editorArea);
bottom.addView(IPageLayout.ID_PROP_SHEET);
}
}
显示如下
2. 打开透视图
通过菜单【Window】打开透视图
也可以通过右上角按钮打开
3. 扩展已有透视图
扩展点【org.eclipse.ui.perspectiveExtensions】
在【org.eclipse.ui.perspectiveExtensions】中添加【perspectiveExtension】,在【targetID】中指定透视图类。
在【perspectiveExtension】中添加【view】,【id】指定要添加的View
,【relative】是相关联的视图,【relationship】是与相关联的视图的位置。
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="com.plugin.blog.demo.perspective.DemoPerspectiveFactory">
<view
id="org.eclipse.ui.views.TaskList"
minimized="false"
relationship="stack"
relative="org.eclipse.ui.views.PropertySheet">
</view>
<view
id="org.eclipse.ui.views.BookmarkView"
minimized="false"
relationship="bottom"
relative="com.plugin.blog.demo.view.DemoViewPart">
</view>
</perspectiveExtension>
</extension>
显示如下