Search code examples
javaeclipseuser-interfaceeclipse-pluginpreferences

Eclipse-Plugin: Separator Line between FieldEditor possible?


When you set up an eclipse plugin preference page, is it possible to add some sort of text or a separator line between the FieldEditors?

@Override
protected void createFieldEditors() {
    addField( new SomeFieldEditor(....));
    addField( new SomeFieldEditor(....));
}

Solution

  • You can use something like:

      Label label = new Label(getFieldEditorParent(), SWT.NONE);
    
      label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 3, 1));
    

    to add a blank like, or

      Label label = new Label(getFieldEditorParent(), SWT.SEPARATOR | SWT.HORIZONTAL);
    
      label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1));
    

    to add a horizontal separator.

    This assumes you are using the GRID layout. You might have to adjust the '3' in the GridData depending on how many columns the field editor end up using.