|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jgoodies.binding.beans.Model com.jgoodies.binding.value.AbstractValueModel cz.vity.freerapid.gui.MyPreferencesAdapter
public class MyPreferencesAdapter
A ValueModel implementation that reads and writes values from/to a key of a given Preferences
node under
a specified key. Write changes fire value changes.
Example:
String prefsKey = "isShowing"; Boolean defaultValue = Boolean.TRUE; Preferences prefs = Workbench.userPreferences(); ValueModel model = new PreferencesAdapter(prefs, prefsKey, defaultValue); JCheckBox showingBox = new JCheckBox("Show tips"); showingBox.setModel(new ToggleButtonAdapter(model));
Preferences
,
Serialized FormField Summary | |
---|---|
protected Object |
defaultValue
Holds the default value that is used if the preferences do not yet store a value. |
protected String |
key
Holds the preferences key that is used to access the stored value. |
protected Preferences |
prefs
Refers to the preferences node that is used to persist the bound data. |
protected Class<?> |
type
Refers to the type of accepted values. |
Fields inherited from class com.jgoodies.binding.value.AbstractValueModel |
---|
PROPERTYNAME_VALUE |
Constructor Summary | |
---|---|
protected |
MyPreferencesAdapter()
|
|
MyPreferencesAdapter(Preferences prefs,
String key,
Object defaultValue)
Constructs a PreferencesAdapter on the given Preferences using the specified key and default value,
all which must be non-null . |
|
MyPreferencesAdapter(String key,
Object defaultValue)
|
Method Summary | |
---|---|
boolean |
getBoolean()
Looks up, converts and returns the stored value from the preferences. |
double |
getDouble()
Looks up, converts and returns the stored value from the preferences. |
float |
getFloat()
Looks up, converts and returns the stored value from the preferences. |
int |
getInt()
Looks up, converts and returns the stored value from the preferences. |
String |
getKey()
|
long |
getLong()
Looks up, converts and returns the stored value from the preferences. |
String |
getString()
Looks up, converts and returns the stored value from the preferences. |
Object |
getValue()
Looks up and returns the value from the preferences. |
void |
setBoolean(boolean newValue)
Converts the given value to an Object and stores it in this adapter's Preferences under this adapter's preferences key. |
void |
setDouble(double newValue)
Converts the given value to an Object and stores it in this adapter's Preferences under this adapter's preferences key. |
void |
setFloat(float newValue)
Converts the given value to an Object and stores it in this adapter's Preferences under this adapter's preferences key. |
void |
setInt(int newValue)
Converts the given value to an Object and stores it in this adapter's Preferences under this adapter's preferences key. |
void |
setLong(long newValue)
Converts the given value to an Object and stores it in this adapter's Preferences under this adapter's preferences key. |
void |
setString(String newValue)
Converts the given value to an Object and stores it in this adapter's Preferences under this adapter's preferences key. |
void |
setValue(Object newValue)
Converts the given value to a string and puts it into the preferences. |
Methods inherited from class com.jgoodies.binding.value.AbstractValueModel |
---|
addValueChangeListener, booleanValue, doubleValue, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, floatValue, intValue, longValue, paramString, removeValueChangeListener, setValue, setValue, setValue, setValue, setValue, toString, valueString |
Methods inherited from class com.jgoodies.binding.beans.Model |
---|
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Preferences prefs
protected String key
protected Class<?> type
protected Object defaultValue
Constructor Detail |
---|
public MyPreferencesAdapter(String key, Object defaultValue)
protected MyPreferencesAdapter()
public MyPreferencesAdapter(Preferences prefs, String key, Object defaultValue)
Preferences
using the specified key and default value,
all which must be non-null
.
prefs
- the Preferences
used to store and retrievekey
- the key used to get and set values in the PreferencesdefaultValue
- the default value
NullPointerException
- if the Preferences, key, or default value is null
IllegalArgumentException
- if the default value is of a type other than Boolean, Double, Float, Integer,
Long, or String.Method Detail |
---|
public String getKey()
public Object getValue()
ClassCastException
- if the type of the default value cannot be read from the preferencespublic void setValue(Object newValue)
newValue
- the object to be stored
IllegalArgumentException
- if the new value cannot be stored in the preferences due to an illegal typepublic boolean getBoolean()
public double getDouble()
public float getFloat()
public int getInt()
public long getLong()
public String getString()
getString
in class com.jgoodies.binding.value.AbstractValueModel
public void setBoolean(boolean newValue)
newValue
- the value to put into the Preferences
ClassCastException
- if the default value is not a Booleanpublic void setDouble(double newValue)
newValue
- the value to put into the Preferences
ClassCastException
- if the default value is not a Doublepublic void setFloat(float newValue)
newValue
- the value to put into the Preferences
ClassCastException
- if the default value is not a Floatpublic void setInt(int newValue)
newValue
- the value to put into the Preferences
ClassCastException
- if the default value is not an Integerpublic void setLong(long newValue)
newValue
- the value to put into the Preferences
ClassCastException
- if the default value is not a Longpublic void setString(String newValue)
newValue
- the value to put into the Preferences
ClassCastException
- if the default value is not a String
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |