Package org.eclipse.jface.dialogs
Class DialogSettings
java.lang.Object
org.eclipse.jface.dialogs.DialogSettings
- All Implemented Interfaces:
IDialogSettings
Concrete implementation of a dialog settings (
IDialogSettings)
using a hash table and XML. The dialog store can be read
from and saved to a stream. All keys and values must be strings or array of
strings. Primitive types are converted to strings.
This class was not designed to be subclassed. Here is an example of using a DialogSettings:
DialogSettings settings = new DialogSettings("root");
settings.put("Boolean1",true);
settings.put("Long1",100);
settings.put("Array1",new String[]{"aaaa1","bbbb1","cccc1"});
DialogSettings section = new DialogSettings("sectionName");
settings.addSection(section);
section.put("Int2",200);
section.put("Float2",1.1);
section.put("Array2",new String[]{"aaaa2","bbbb2","cccc2"});
settings.save("c:\\temp\\test\\dialog.xml");
-
Constructor Summary
ConstructorsConstructorDescriptionDialogSettings(String sectionName) Create an empty dialog settings which loads and saves its content to a file. -
Method Summary
Modifier and TypeMethodDescriptionaddNewSection(String sectionName) Create a new section in the receiver and return it.voidaddSection(IDialogSettings section) Add a section in the receiver.Returns the value of the given key in this dialog settings.String[]Returns the value, an array of strings, of the given key in this dialog settings.booleangetBoolean(String key) Convenience API.doubleConvenience API.floatConvenience API.intConvenience API.longConvenience API.getName()Returns the IDialogSettings name.static IDialogSettingsgetOrCreateSection(IDialogSettings settings, String sectionName) Returns a section with the given name in the given dialog settings.getSection(String sectionName) Returns the section with the given name in this dialog settings.Returns all the sections in this dialog settings.voidLoad a dialog settings from a stream and fill the receiver with its content.voidLoad a dialog settings from a file and fill the receiver with its content.voidConvenience API.voidConvenience API.voidConvenience API.voidConvenience API.voidConvenience API.voidAdds the pairkey/valueto this dialog settings.voidAdds the pairkey/valueto this dialog settings.removeSection(String sectionName) Remove a section by name in the receiver.voidremoveSection(IDialogSettings section) Remove a section in the receiver.voidSave a dialog settings to a streamvoidSave a dialog settings to a file.
-
Constructor Details
-
DialogSettings
Create an empty dialog settings which loads and saves its content to a file. Use the methodsload(String)andstore(String)to load and store this dialog settings.- Parameters:
sectionName- the name of the section in the settings.
-
-
Method Details
-
addNewSection
Description copied from interface:IDialogSettingsCreate a new section in the receiver and return it.- Specified by:
addNewSectionin interfaceIDialogSettings- Parameters:
sectionName- the name of the new section- Returns:
- the new section
- See Also:
-
addSection
Description copied from interface:IDialogSettingsAdd a section in the receiver.- Specified by:
addSectionin interfaceIDialogSettings- Parameters:
section- the section to be added
-
removeSection
Remove a section in the receiver. If the given section does not exist, nothing is done.- Parameters:
section- the section to be removed. Must not benull.- Since:
- 3.9
-
removeSection
Remove a section by name in the receiver. If the given section does not exist, nothing is done.- Parameters:
sectionName- the name of the section to be removed. Must not benull.- Returns:
- The dialog section removed, or
nullif it wasn't there. - Since:
- 3.9
-
get
Description copied from interface:IDialogSettingsReturns the value of the given key in this dialog settings.- Specified by:
getin interfaceIDialogSettings- Parameters:
key- the key- Returns:
- the value, or
nullif none
-
getArray
Description copied from interface:IDialogSettingsReturns the value, an array of strings, of the given key in this dialog settings.- Specified by:
getArrayin interfaceIDialogSettings- Parameters:
key- the key- Returns:
- the array of string, or
nullif none
-
getBoolean
Description copied from interface:IDialogSettingsConvenience API. Convert the value of the given key in this dialog settings to a boolean and return it.- Specified by:
getBooleanin interfaceIDialogSettings- Parameters:
key- the key- Returns:
- the boolean value, or
falseif none
-
getDouble
Description copied from interface:IDialogSettingsConvenience API. Convert the value of the given key in this dialog settings to a double and return it.- Specified by:
getDoublein interfaceIDialogSettings- Parameters:
key- the key- Returns:
- the value coverted to double, or throws
NumberFormatExceptionif none - Throws:
NumberFormatException- if the string value does not contain a parsable number.- See Also:
-
getFloat
Description copied from interface:IDialogSettingsConvenience API. Convert the value of the given key in this dialog settings to a float and return it.- Specified by:
getFloatin interfaceIDialogSettings- Parameters:
key- the key- Returns:
- the value coverted to float, or throws
NumberFormatExceptionif none - Throws:
NumberFormatException- if the string value does not contain a parsable number.- See Also:
-
getInt
Description copied from interface:IDialogSettingsConvenience API. Convert the value of the given key in this dialog settings to a int and return it.- Specified by:
getIntin interfaceIDialogSettings- Parameters:
key- the key- Returns:
- the value coverted to int, or throws
NumberFormatExceptionif none - Throws:
NumberFormatException- if the string value does not contain a parsable number.- See Also:
-
getLong
Description copied from interface:IDialogSettingsConvenience API. Convert the value of the given key in this dialog settings to a long and return it.- Specified by:
getLongin interfaceIDialogSettings- Parameters:
key- the key- Returns:
- the value coverted to long, or throws
NumberFormatExceptionif none - Throws:
NumberFormatException- if the string value does not contain a parsable number.- See Also:
-
getName
Description copied from interface:IDialogSettingsReturns the IDialogSettings name.- Specified by:
getNamein interfaceIDialogSettings- Returns:
- the name
-
getOrCreateSection
Returns a section with the given name in the given dialog settings. If the section doesn't exist yet, then it is first created.- Parameters:
settings- the parent settingssectionName- the name of the section- Returns:
- the section
- Since:
- 3.7
-
getSection
Description copied from interface:IDialogSettingsReturns the section with the given name in this dialog settings.- Specified by:
getSectionin interfaceIDialogSettings- Parameters:
sectionName- the key- Returns:
- IDialogSettings (the section), or
nullif none - See Also:
-
getSections
Description copied from interface:IDialogSettingsReturns all the sections in this dialog settings.- Specified by:
getSectionsin interfaceIDialogSettings- Returns:
- the section, or
nullif none
-
load
Description copied from interface:IDialogSettingsLoad a dialog settings from a stream and fill the receiver with its content.- Specified by:
loadin interfaceIDialogSettings- Parameters:
r- a Reader specifying the stream where the settings are read from.
-
load
Description copied from interface:IDialogSettingsLoad a dialog settings from a file and fill the receiver with its content.- Specified by:
loadin interfaceIDialogSettings- Parameters:
fileName- the name of the file the settings are read from.- Throws:
IOException- on IO problem while loading
-
put
Description copied from interface:IDialogSettingsAdds the pairkey/valueto this dialog settings.- Specified by:
putin interfaceIDialogSettings- Parameters:
key- the key.value- the value to be associated with thekey
-
put
Description copied from interface:IDialogSettingsConvenience API. Converts the doublevalueto a string and adds the pairkey/valueto this dialog settings.- Specified by:
putin interfaceIDialogSettings- Parameters:
key- the key.value- the value to be associated with thekey
-
put
Description copied from interface:IDialogSettingsConvenience API. Converts the floatvalueto a string and adds the pairkey/valueto this dialog settings.- Specified by:
putin interfaceIDialogSettings- Parameters:
key- the key.value- the value to be associated with thekey
-
put
Description copied from interface:IDialogSettingsConvenience API. Converts the intvalueto a string and adds the pairkey/valueto this dialog settings.- Specified by:
putin interfaceIDialogSettings- Parameters:
key- the key.value- the value to be associated with thekey
-
put
Description copied from interface:IDialogSettingsConvenience API. Converts the longvalueto a string and adds the pairkey/valueto this dialog settings.- Specified by:
putin interfaceIDialogSettings- Parameters:
key- the key.value- the value to be associated with thekey
-
put
Description copied from interface:IDialogSettingsAdds the pairkey/valueto this dialog settings.- Specified by:
putin interfaceIDialogSettings- Parameters:
key- the key.value- the value to be associated with thekey
-
put
Description copied from interface:IDialogSettingsConvenience API. Converts the booleanvalueto a string and adds the pairkey/valueto this dialog settings.- Specified by:
putin interfaceIDialogSettings- Parameters:
key- the key.value- the value to be associated with thekey
-
save
Description copied from interface:IDialogSettingsSave a dialog settings to a stream- Specified by:
savein interfaceIDialogSettings- Parameters:
writer- a Writer specifying the stream the settings are written in.- Throws:
IOException- on IO problem while saving
-
save
Description copied from interface:IDialogSettingsSave a dialog settings to a file.- Specified by:
savein interfaceIDialogSettings- Parameters:
fileName- the name of the file the settings are written in.- Throws:
IOException- on IO problem while saving
-