我是 RCP 的初学者,今天刚刚开始构建 RCP 应用程序。我想要一个 GUI 组件,如编辑器中的按钮、组合框、复选框。我已经设法在扩展中添加一个编辑器并为它创建一个类。我有编写代码以在 creatPartControl 中创建标签,但它不起作用..我得到一个黑色窗口。我应该像这样添加编辑器吗
layout.addStandaloneView(Editor.id, true, IPageLayout.TOP,0.7f,
layout.getEditorArea());
layout.addStandaloneView(View.ID, true, IPageLayout.BOTTOM,0.4f,
layout.getEditorArea());
请帮我解决这个问题。如果可能,请举例说明如何添加编辑器并在其中创建标签和按钮。提前感谢您的帮助,代码在我的 Editor.java 内容中createPartControl()
parent.setLayout(new GridLayout());
Button b=new Button(parent,SWT.TOGGLE);
b.setText("Hello ");
Label label1 = new Label(parent, SWT.NONE);
label1.setText("First Name");
package com.hello;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;
public class Editor extends EditorPart {
public static final String ID = "TestApplication.editor3";
public Editor() {
// TODO Auto-generated constructor stub
}
@Override
public void doSave(IProgressMonitor monitor) {
// TODO Auto-generated method stub
}
@Override
public void doSaveAs() {
// TODO Auto-generated method stub
}
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
// TODO Auto-generated method stub
}
@Override
public boolean isDirty() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isSaveAsAllowed() {
// TODO Auto-generated method stub
return false;
}
@Override
public void createPartControl(Composite parent) {
Label label = new Label(parent, SWT.NONE);
label.setText("sssssss");
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
}