Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » inserting a simple texte between two FieldEditors
inserting a simple texte between two FieldEditors [message #306214] Tue, 25 July 2006 10:46 Go to next message
Eclipse UserFriend
How can i insert a simple texte between two FieldEditor s in the
createFieldEditors() method of a FieldEditorPreferencePage ?

merci,

Nicolas.
Re: inserting a simple texte between two FieldEditors [message #306235 is a reply to message #306214] Tue, 25 July 2006 22:52 Go to previous messageGo to next message
Eclipse UserFriend
Yeah, I don't think it's easy. What I have done is to add the text in one of the FieldEditor's
doFillIntoGrid() method, but that can get messy with layouts. I think FieldEditors are really
intended to be used only when you want plain simple preferences; iif you want anything else, better
off using regular old PreferencePage. (As a matter of fact I am creating an alternate field-editor
like system with more flexibility etc.; if I get it done, maybe I post it as an enhancement request.)

Paul
Re: inserting a simple texte between two FieldEditors [message #306239 is a reply to message #306214] Wed, 26 July 2006 01:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi Nicolas,

Nicolas Silb schrieb:
> How can i insert a simple texte between two FieldEditor s in the
> createFieldEditors() method of a FieldEditorPreferencePage ?

create your own FieldEditor class and override the following functions:

<code>
class LabelField extends FieldEditor {
private Label l;

/** Adjust layout after all editors are known */
protected void adjustForNumColumns(int numColumns) {
GridData d = new GridData();
d.horizontalSpan = numColumns;
l.setLayoutData(d);
}
/** Insert label/button/whatever, layout is done later */
protected void doFillIntoGrid(Composite parent,int numColumns) {
l = new Label(parent,SWT.NONE);
l.setText(getLabelText());
}
/** How many columns do we need? */
public int getNumberOfControls() {
return 1;
}

</code>

It could make sense to override doStore()/doLoad() et.al. too.

Bye

G&uuml;nther
Re: inserting a simple texte between two FieldEditors [message #306252 is a reply to message #306239] Wed, 26 July 2006 03:57 Go to previous messageGo to next message
Eclipse UserFriend
Thanks! i couldn't believe it was not already available!

i don't understand:

l.setText(getLabelText());

How do you populate FieldEditor.labelText to make getLabelText() return
something?

NiC

"Guenther Koegel" <guenther.koegel@mind8.com> a
Re: inserting a simple texte between two FieldEditors [message #306331 is a reply to message #306252] Thu, 27 July 2006 02:28 Go to previous messageGo to next message
Eclipse UserFriend
Salut Nicolas,

Nicolas Silb schrieb:
> Thanks! i couldn't believe it was not already available!

well, the FieldEditors are especially designed and "shrink wrapped" to
solve exactly the purpose of three tasks: retrieve, display and store
properties. In case you want to (re-)use them for an other purpose it's
getting difficult. Here a simple example:

Create an label plus a text field that does *NOT* load/store the text as
a property.

<code>
StringFieldEditor sfe = new StringFieldEditor("",
"LicenseCode",
getFieldEditorParent(){
public void doLoad()
{/*ignore preference store settings*/
}
public void doStore()
{/*leave preference store alone*/
}
};
</code>

In case you need more or other elements use a separate class inheriting
from FieldEditor. I did that to have a button on the preference page.

> i don't understand:
>
> l.setText(getLabelText());
>
> How do you populate FieldEditor.labelText to make getLabelText() return
> something?

The function "getLabelText()" returns the second parameter you gave to
the FieldEditor constructor. The first is the property name and the last
one is used as parent for the GUI elements. Do not use the default
constructor, it's empty!

Have a look into the implementation of the FieldEditor to get an
impression what it can do and what not.

Bye

G&uuml;nther
Re: inserting a simple texte between two FieldEditors [message #306339 is a reply to message #306331] Thu, 27 July 2006 05:03 Go to previous message
Eclipse UserFriend
Thanks. All works well.
Included is the class LabelField for other interested people. Documentation
is in the class comments. Xith sample to beark a long text in many
LabelFields.

Nicolas


Note:
it is important to call init(name, text): it makes a null pointer excp when
cliking the "Set Default Value" button in the eclipse pref page if no name
is defined.


Previous Topic:Java Structure Compare
Next Topic:Question about the eclipse.buildScript Ant task
Goto Forum:
  


Current Time: Mon May 12 14:43:59 EDT 2025

Powered by FUDForum. Page generated in 0.12660 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top