Preferences

The first step on working with customized preferences is to set up an xml-file containing all desired application settings. You should copy the basic defaultprefs.xml from the skeleton project and edit it to fit your needs. Setting up this file is all you have to do to provide persistent settings and have a comfortable way of editing them via the Preference Dialog. Let's have a look at the structure of this file:

Example 9.3. An example preferences.xml file

<list>
 <!-- a first group / tab: GUI related -->
 <set name="prefs.tab.gui">
  <set name="prefs.grp.common">
   <attribute name="prefs.common.language" value="Deutsch">
    <constraint>(value in ('Deutsch' | 'English')</constraint>
   </attribute>
  </set>
  <set name="prefs.grp.surface">
   <attribute name="prefs.surface.showtooltips" 
              type="Boolean" value="true"/>
  </set>
 </set> 
 
 <!-- a second group / tab: files and folders -->
 <set name="prefs.tab.paths">
  <set name="prefs.grp.paths">
   <attribute name="prefs.path.lastdir" 
         type="com.tensegrity.gui.template.DirectoryLocationAttribute" 
         value="" />  
  </set>
 </set>
</list>

You can access the Preference instance of your application with a call to method getPreferences() defined in interface Application. For example, if you want to figure out which language was set you call

application.getPreferences().get("prefs.common.language");

Section Loading Preferences shows how to load a custom preferences file with the help of a LaunchTask.