在Eclipse插件中将Buttons \ Drop Down菜单添加到透视图的模式是什么?
显然我可以使用SWT将它们添加到画布中。但是我觉得我没有使用完整的Eclipse Workspace而错过了一个技巧。
任何Eclipse-Plugin开发人员都可以告诉我最适合的方法是什么?
答案 0 :(得分:1)
透视图可以包含视图,编辑器,扩展等。您必须使用视图或编辑器来添加按钮,组合和其他SWT控件。透视图定义了您的视图,编辑器等在eclipse工作台中的排列方式。
在eclipse插件中创建了一个plugin.xml文件。在里面你可以添加透视扩展。 e.g。
<extension
point="org.eclipse.ui.perspectives">
<perspective
class="perspectives.MyPerspective"
fixed="true"
id="Perspective.myPerspective"
name="MyPerspective">
</perspective>
</extension>
您可以从透视扩展中添加视图和编辑器,例如
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="Perspective.myPerspective">
<view
id="org.eclipse.jdt.ui.PackageExplorer"
minimized="false"
moveable="false"
ratio="0.5"
relationship="left"
relative="org.eclipse.ui.console.ConsoleView"
visible="true">
</view>
</perspectiveExtension>
</extension>
可以在透视图类中以编程方式添加视图和编辑器。
扩展IPerspectiveFactory。将您的代码放在createInitialLayout()中 e.g。
public void createInitialLayout(IPageLayout layout){
layout.addStandaloneView(MyView.ID, false, IPageLayout.LEFT, 0.25f,layout.getEditorArea());
// Multiple views and editors can be added here with its area and direction.
//You can set them moveable false or closable false. If you want them fixed.
}
你的观点类是这样的:
public class MyView extends ViewPart
{
public static final String ID = "myproject.views.MyView";
// ID is a normal string and could be anything
@Override
public void createPartControl(Composite parent) {
// Here parent is your composite where u can add your SWT controls e.g.
Text text = new Text(parent, SWT.BORDER);
}
}
我认为这对您有所帮助,如需帮助,您可以访问:
http://www.programcreek.com/2013/02/eclipse-plug-in-development-creat-a-perspective/
或