com.tensegrity.gui.document
Class DocumentSettingsProvider

java.lang.Object
  extended bycom.tensegrity.gui.document.DocumentSettingsProvider
All Implemented Interfaces:
PreferenceDialogProvider
Direct Known Subclasses:
GraphDocumentSettingsProvider

public class DocumentSettingsProvider
extends java.lang.Object
implements PreferenceDialogProvider

Implementation of PreferenceDialogProvider for editing the documents settings in a preference style dialog.

Author:
BurkhardWick

Nested Class Summary
static interface DocumentSettingsProvider.DocSetting
           DocSetting
 
Constructor Summary
DocumentSettingsProvider(Document gDoc, java.util.Map mapPref2Doc, java.lang.String preferenceFileName, java.lang.Class refClass)
          Constructor
 
Method Summary
 void applyChanges()
          After an user has made changes in the PreferencesDialog this method is called to make the values the application can retrieve by calling getValue valid.
 void cancelChanges()
          Cancels all changes made since the last call to applyChanges().
 void flush()
          Saves the preferences-file.
 AttributeList getAttributeList()
          Returns the AttributeList holding the preference settings.
 PreferenceEvent[] getChangedPreferences()
          Returns an array of PreferencesEvents.
 AttributeSet getDefaultAttributeSet(java.lang.String name)
          Returns the top level set with the given name from the default list.
 boolean isRestorable()
          Indicates whether this preference instance is restorable.
static java.util.Map makeMap(java.lang.Object[] keys, java.lang.Object[] values)
          Creates a map by mapping each item of the first array to the item with the same index in the second array.
static DocumentSettingsProvider.DocSetting newDocSetting(Document gDoc, java.lang.String docKey, java.util.Map prefValue2DocValue)
          Creates a new DocSetting using the given information.
 DocumentSettingsProvider.DocSetting newDocSetting(java.lang.String docKey, java.util.Map prefValue2DocValue)
          Creates a new DocSetting using the given information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentSettingsProvider

public DocumentSettingsProvider(Document gDoc,
                                java.util.Map mapPref2Doc,
                                java.lang.String preferenceFileName,
                                java.lang.Class refClass)
                         throws ReadException,
                                java.lang.CloneNotSupportedException
Constructor

Parameters:
gDoc - The document which properties are edited
mapPref2Doc - A map matching keys from the preferences to the corresponding keys in the document
preferenceFileName - The name of the preference file
refClass - The reference class for loading the preferences file
Throws:
ReadException - When reading the preferences file fails
java.lang.CloneNotSupportedException - If cloning the preferences fails
Method Detail

applyChanges

public void applyChanges()
Description copied from interface: PreferenceDialogProvider
After an user has made changes in the PreferencesDialog this method is called to make the values the application can retrieve by calling getValue valid.

Specified by:
applyChanges in interface PreferenceDialogProvider

cancelChanges

public void cancelChanges()
Description copied from interface: PreferenceDialogProvider
Cancels all changes made since the last call to applyChanges().

Specified by:
cancelChanges in interface PreferenceDialogProvider

flush

public void flush()
           throws java.io.IOException
Description copied from interface: PreferenceDialogProvider
Saves the preferences-file. The default name of this file is preferences.xml and it is located in the user.dir.

Specified by:
flush in interface PreferenceDialogProvider
Throws:
java.io.IOException - if the preference-file could not be saved.

getAttributeList

public AttributeList getAttributeList()
Description copied from interface: PreferenceDialogProvider
Returns the AttributeList holding the preference settings.

Specified by:
getAttributeList in interface PreferenceDialogProvider
Returns:
the AttributeList holding the preference settings.

getDefaultAttributeSet

public AttributeSet getDefaultAttributeSet(java.lang.String name)
Description copied from interface: PreferenceDialogProvider
Returns the top level set with the given name from the default list.

Specified by:
getDefaultAttributeSet in interface PreferenceDialogProvider
Parameters:
name - the name of the set to retrieve.
Returns:
the found AttributeSet; null otherwise.

getChangedPreferences

public PreferenceEvent[] getChangedPreferences()
Description copied from interface: PreferenceDialogProvider
Returns an array of PreferencesEvents. Every listed entry reflects a change made to the preferences.

Specified by:
getChangedPreferences in interface PreferenceDialogProvider
Returns:
an array of PreferencesEvents reflecting the changes made to the preferences.

isRestorable

public boolean isRestorable()
Description copied from interface: PreferenceDialogProvider
Indicates whether this preference instance is restorable.

Specified by:
isRestorable in interface PreferenceDialogProvider
Returns:
true, if this preference instance is restorable.

newDocSetting

public DocumentSettingsProvider.DocSetting newDocSetting(java.lang.String docKey,
                                                         java.util.Map prefValue2DocValue)
Creates a new DocSetting using the given information.

Parameters:
docKey - The key of this setting in the document
prefValue2DocValue - The map for converting a preference value to a document value
Returns:
The created DocSetting

newDocSetting

public static DocumentSettingsProvider.DocSetting newDocSetting(Document gDoc,
                                                                java.lang.String docKey,
                                                                java.util.Map prefValue2DocValue)
Creates a new DocSetting using the given information.

Parameters:
gDoc - The graph document this setting is applied to
docKey - The key of this setting in the document
prefValue2DocValue - The map for converting a preference value to a document value
Returns:
The created DocSetting

makeMap

public static java.util.Map makeMap(java.lang.Object[] keys,
                                    java.lang.Object[] values)
Creates a map by mapping each item of the first array to the item with the same index in the second array.

Parameters:
keys - The array holding the keys
values - The array holding the values
Returns:
A map in which the keys are mapped to the values


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.