JFace在RadioGroupFieldEditor附近添加一个文本框

时间:2019-07-05 06:49:59

标签: eclipse eclipse-plugin jface

我尝试在Eclipse菜单中添加一些首选项,为此我在JFace中创建了RadioGroupFieldEditor部分,并且在RadioGroupField的最后一个单选附近,我想要一个文本区域,如下图所示: enter image description here

但是我无法做到这一点。我用两列创建一个GridLayout,其中一列我想要RadioGroupFieldEditor,另一列我想要文本字段。文本字段放置在RadioGroupField下方,而不是我期望的第二列。

代码如下:

    protected Control createContents(Composite parent) {
    Composite fieldEditorParent = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    fieldEditorParent.setLayout(layout);
    fieldEditorParent.setFont(parent.getFont());

    createAGroup(fieldEditorParent);

    return fieldEditorParent;
  }

  private void createAGroup(Composite parent) {
    Group group = new Group(parent, SWT.NONE);
    group.setText("Group");
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    group.setLayout(layout);

    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    group.setLayoutData(data);

    GridLayout subLayout = new GridLayout();
    subLayout.numColumns = 3;

    Composite expertUserComposite1 = new Composite(group, SWT.NONE);
    expertUserComposite1.setLayout(subLayout);
    new Button(expertUserComposite1, SWT.RADIO | SWT.LEFT);
    new Label(expertUserComposite1, SWT.BEGINNING).setText("aaa");
    new Text(expertUserComposite1, SWT.BORDER);

    Composite expertUserComposite2 = new Composite(group, SWT.NONE);
    expertUserComposite2.setLayout(subLayout);
    new Button(expertUserComposite2, SWT.RADIO | SWT.LEFT);
    new Label(expertUserComposite2, SWT.BEGINNING).setText("bbb");

    Composite expertUserComposite3 = new Composite(group, SWT.NONE);
    expertUserComposite3.setLayout(subLayout);

    new RadioGroupFieldEditor(IExportCSVPreferences.DELIMITER_NAME_CURRENT,
        "RadioGroup", 1,
        new String[][] { { "line1", "line1" }, { "line2", "line2" }, { "line3", "line3" } },
        expertUserComposite3);
    new Text(expertUserComposite3, SWT.BORDER);

    Composite expertUserComposite4 = new Composite(group, SWT.NONE);
    expertUserComposite4.setLayout(subLayout);

    new RadioGroupFieldEditor(IExportCSVPreferences.DELIMITER_NAME_CURRENT, "RadioGroup", 1,
        new String[][] { { "line1", "line1" }, { "line2", "line2" }, { "line3", "line3" } }, expertUserComposite4,
        true);
    new Text(expertUserComposite4, SWT.BORDER);
  }

结果如下: enter image description here

0 个答案:

没有答案