Adding and Using Preferences

Components can define their own specific preferences to be stored and retrieved from Isight. Typically, a component would use preferences to specify default values for various configuration options so that any new instances of the component would already have those options set to the desired values.

To define preferences for your component, add them to your component xml descriptor as follows:

    <Preferences>
        <Preference name="Default close option" tag="Default 
close option" type="com.engineous.datatype.Integer">
            <Value>1</Value>
        </Preference>
        <Preference name="Save workbook as parameter" tag="Save 
workbook as parameter" type="com.engineous.datatype.Bool">
            <Value>false</Value>
        </Preference>
    </Preferences>

Preferences can then be accessed in your component code in the following manner:

PreferenceSet prefs = myComponent.getMetaModel().getPreferences();
Preference closePref = prefs.getPreference("Default close 
option");
int closeOption = closePref.getAsInt();

Preference saveWorkbookPref = prefs.getPreference("Save 
workbook as parameter");
boolean saveWorkbookOption = saveWorkbookPref.getAsBoolean();

A preference value can be set by calling the setValue() method.

closePref.setValue(closeCombo.getSelectedIndex());

Changes to preferences are saved to the user’s fiper.preference file.