Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » FieldEditor does not write default-value
FieldEditor does not write default-value [message #462974] Mon, 24 October 2005 12:49 Go to next message
arne anka is currently offline arne ankaFriend
Messages: 133
Registered: July 2009
Senior Member
in a prefgerences-page i have two FieldEditors. to ease the use i display
default-values, so the suer has not to type in any values if he's happy
with default ones.
but the default values are not stored to the prefs -- thus any attempt to
use those values causes an error.
if i fill in arbitrary values, different from the default, it's stored --
but thus the ability to present default values seems meaningless to me.
what do i wrong, how do i force the FieldEditors to save even the
unchanged default?


public class LocalDBPreferencePage extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {

IPreferenceStore ips;

public LocalDBPreferencePage() {
super(GRID);
setPreferenceStore(ips=MyPlugin.getDefault().getPreferenceSt ore());
setDescription("Preference page for the local Derby-DB");
ips.setDefault("derbydbpath",
Platform.getLocation().toOSString());
ips.setDefault("derbydbname", "NJVDB");
}

public void createFieldEditors() {
Composite fep=getFieldEditorParent();

DirectoryFieldEditor dfe=new
DirectoryFieldEditor(PreferenceConstants.P_PATH, "&Speicherort der DB:",
fep);
dfe.setPreferenceName("derbydbpath");
addField(dfe);

StringFieldEditor sfeDBN=new
StringFieldEditor(PreferenceConstants.P_STRING, "Datenbankname:", fep);
sfeDBN.setPreferenceName("derbydbname");
addField(sfeDBN);
}

public void init(IWorkbench workbench) {}

}
Re: FieldEditor does not write default-value [message #462978 is a reply to message #462974] Mon, 24 October 2005 14:05 Go to previous messageGo to next message
arne anka is currently offline arne ankaFriend
Messages: 133
Registered: July 2009
Senior Member
solved the issue by calling ips.setDefault() in the plugin's
start()-method.
i still think the default-value should be saved to the props, but that's
probably rather a matter of taste ...
Re: FieldEditor does not write default-value [message #462979 is a reply to message #462974] Mon, 24 October 2005 16:07 Go to previous messageGo to next message
Haris Peco is currently offline Haris PecoFriend
Messages: 1072
Registered: July 2009
Senior Member
arne,
set default values in preference initializer
see extension point org.eclipse.core.runtime.preferences
and class
org.eclipse.core.runtime.preferences.AbstractPreferencesInit ializer

Peco
arne anka wrote:

> in a prefgerences-page i have two FieldEditors. to ease the use i display
> default-values, so the suer has not to type in any values if he's happy
> with default ones.
> but the default values are not stored to the prefs -- thus any attempt to
> use those values causes an error.
> if i fill in arbitrary values, different from the default, it's stored --
> but thus the ability to present default values seems meaningless to me.
> what do i wrong, how do i force the FieldEditors to save even the
> unchanged default?
>
>
> public class LocalDBPreferencePage extends FieldEditorPreferencePage
> implements IWorkbenchPreferencePage {
>
> IPreferenceStore ips;
>
> public LocalDBPreferencePage() {
> super(GRID);
> setPreferenceStore(ips=MyPlugin.getDefault().getPreferenceSt ore());
> setDescription("Preference page for the local Derby-DB");
> ips.setDefault("derbydbpath",
> Platform.getLocation().toOSString());
> ips.setDefault("derbydbname", "NJVDB");
> }
>
> public void createFieldEditors() {
> Composite fep=getFieldEditorParent();
>
> DirectoryFieldEditor dfe=new
> DirectoryFieldEditor(PreferenceConstants.P_PATH, "&Speicherort der DB:",
> fep);
> dfe.setPreferenceName("derbydbpath");
> addField(dfe);
>
> StringFieldEditor sfeDBN=new
> StringFieldEditor(PreferenceConstants.P_STRING, "Datenbankname:", fep);
> sfeDBN.setPreferenceName("derbydbname");
> addField(sfeDBN);
> }
>
> public void init(IWorkbench workbench) {}
>
> }
Re: FieldEditor does not write default-value [message #462981 is a reply to message #462978] Mon, 24 October 2005 16:09 Go to previous message
Haris Peco is currently offline Haris PecoFriend
Messages: 1072
Registered: July 2009
Senior Member
arne anka wrote:

> solved the issue by calling ips.setDefault() in the plugin's
> start()-method.
> i still think the default-value should be saved to the props, but that's
> probably rather a matter of taste ...

preferences initializer is better solution because it call without plugin
start
Previous Topic:How to find a TreeItem when using a TreeViewer
Next Topic:Problems with Table
Goto Forum:
  


Current Time: Sun Nov 23 02:27:37 GMT 2014

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

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