views:

442

answers:

1

Hello, I have following problems with layout settings in the FieldEditorPreferencePage.
My code is something like that:

public void createFieldEditors () {
Group pv = new group(getfieldEditorParent(), SWT.SHADOW_OUT);
Group of = new group(getfieldEditorParent(), SWT.SHADOW_OUT);
pv.setText(“pv”);
of.setText(“of”);
GridLayout layout = new GridLayout(2,false);
pv.setLayout(layout);
of.setLayout(layout);
addField(new StringFieldEditor(“PreferenceStore name”,“Text:”, pv);
addField(new StringFieldEditor(“PreferenceStore name”,“Text:”, pv);
addField(new StringFieldEditor(“PreferenceStore name”,“Text:”, of);
addField(new StringFieldEditor(“PreferenceStore name”,“Text:”, of);
and so on.
}


The problem that is it does not works with GridLayout. The StringFieldEditors are not parallel. The number of columns is always 1. Also I try to change the size of the StringFieldEditors in the groups but it doesn’t work too.
Somebody any ideas. Thanks.

+1  A: 

The probleam is that when you are using FieldEditorPreferencePage, you can use only FieldEditor subclasses as components. Here's a snippet from a documentation..

FieldEditorPreferencePage implements a page that uses these field editors to display and store the preference values on the page. Instead of creating SWT controls to fill its contents, a FieldEditorPreferencePage subclass creates field editors to display the contents. All of the fields on the page must be implemented as field editors.

That means you have two options how to achieve what you want:

  1. Implement your own subclass of FieldEditor, which would represent the Group widget.

  2. Do not extend FieldEditorPreferencePage, but only a PreferencePage instead. Than you have to implement createContents method instead of createFieldEditors. You will also have to manage loading and saving of the properties. But I think this way might be easier if you want to provide some complex layout.

You may find some information more here

Martin Lazar
preference page + groups + field editor = insane layout too
Imaskar