Eclipse 插件中将按钮\下拉菜单添加到透视的模式是什么?
显然,我可以使用 SWT 将它们添加到画布中。 但是我觉得我没有使用完整的Eclipse Workspace,我错过了一个技巧。
任何Eclipse-Plugin开发人员都可以告诉我最好的方法是什么?
透视可以包含视图、编辑器、扩展等。您必须使用视图或编辑器来添加按钮,组合和其他SWT控件。透视定义了您的视图、编辑器等在 eclipse 工作台中的排列方式。
在 eclipse 插件中创建了一个插件.xml文件。在其中,您可以添加透视的扩展。例如
<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() 中例如
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/
或
http://www.vogella.com/tutorials/EclipsePlugin/article.html