RCP如何添加透视图

1、在plugin.xml添加透视图扩展点

<extension 
	point="org.eclipse.ui.perspectives">
	<perspective
		class="myviewrcp2.MyPerspective"
		icon="icons/samples.gif"
		id="myviewrcp2.MyPerspective"
		name="自定义透视图"/>
</extension>

2、添加透视图类

package myviewrcp2;

import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

public class MyPerspective implements IPerspectiveFactory {

	@Override
	public void createInitialLayout(IPageLayout layout) {
		// TODO Auto-generated method stub
		String editorArea = layout.getEditorArea();
		layout.addView(SampleView.ID, IPageLayout.LEFT, 0.45f, editorArea); 
        layout.addView(AnotherView.ID, IPageLayout.BOTTOM, 0.45f, editorArea); 
	}

}

3、在ApplicationWorkbenchWindowAdvisor类中设置可选择透视图的按钮

4、效果如图:

 

posted @ 2022-11-11 11:17  信铁寒胜  阅读(40)  评论(0编辑  收藏  举报