简体   繁体   English

将Eclipse UI表单添加到AbstractDecoratedTextEditor

[英]Adding eclipse UI form to a AbstractDecoratedTextEditor

I am trying to add a form in the lower half of text area in AbstractDecoratedTextEditor but the form shows up in the right half of the editor by default. 我试图在AbstractDecoratedTextEditor的文本区域的下半部分添加一个表单,但是默认情况下该表单显示在编辑器的右半部分。 Is there a way to have the form displayed in the lower half of the editor without writing a text editor from scratch and adding the text area and form in a grid layout ? 有没有一种方法可以使表单显示在编辑器的下半部分,而无需从头开始编写文本编辑器,而无需在网格布局中添加文本区域和表单? This is the class I have so far. 这是我到目前为止的课程。

public class Editor extends AbstractDecoratedTextEditor
{
  public Editor()
  {
    super();
    setDocumentProvider(new DocumentProvider());
  }

  @Override
  public void init(final IEditorSite site, final IEditorInput input) throws PartInitException
  {
    super.init(site, input);
    if (input instanceof EditorInput)
    {
       text = ((EditorInput) input).getText();
    }
  }

  @Override
  public void createPartControl(final Composite parent)
  {
    super.createPartControl(parent);

    final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    final Form form = toolkit.createForm(parent);
    form.setText("Testing.... 1 2 3.....");
  }
}

simply set layout of parent (composite).. you can set any layout. 只需设置父级(复合)的布局即可。您可以设置任何布局。 eg you can use FillLayout filllayout = new FillLayout(); 例如,您可以使用FillLayout filllayout = new FillLayout(); filllayout.type = SWT.VERTICAL; filllayout.type = SWT.VERTICAL; filllayout.spacing =5; filllayout.spacing = 5; filllayout.marginHeight=5; filllayout.marginHeight = 5; filllayout.marginWidth=5; filllayout.marginWidth = 5; parent.setLayout(filllayout); parent.setLayout(filllayout); super.createPartControl(parent); super.createPartControl(父级); Hope, this will work. 希望这会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM