Class semper.preferences.Preferences
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class semper.preferences.Preferences

java.lang.Object
   |
   +----semper.preferences.Preferences

public class Preferences
extends Object
The Preferences Manager is a static class that manage the set of preferences used in a SEMPER application. This class is the main interface to preferences. The Preferences Manager can be initialised assuming the following managers have been initialised before: Preferences must be saved before the user can consult them. A preferences environment is stored in pieces in the archive. Each group correspond to a different file. In addition a standard file contains a list of all groups in the environment. Access Control is enforced when adding, deleting,getting and editing a preferences group. Access control for preferences retrievement is managed by the archive manager through its encryption service.
Version:
$Revision: 1.33 $ $Date: 1997/03/14 13:47:34 $
Author:
Louis Salvail (CWI)
See Also:
Configuration, PrefGroup

Variable Index

 o groupMapping
 o root
 o superGroupMapping

Constructor Index

 o Preferences()

Method Index

 o addGroup(PrefGroup)
Allows to add a new group in the current preferences environment.
 o addToRoot(String)
Adds or moves a group directly below the root subgroup.
 o addToSubGroup(String, String)
This method is used to add a group in a subgroup.
 o cancel(PrefGroup, boolean)
This method is called when the user's modifications for a preferences group are canceled.
 o delAllGroups()
Delete all groups in the current environment iff no one is in edition.
 o delGroup(String)
Allows to delete a group from the current preferences environment.
 o displayMenuStruct()
Display the internal menu structure of the Preferences manager on the standard output.
 o editGroup(String, PrefFrame)
This is called when interactive edition of the preferences are needed.
 o flattenSubGroupsStructure()
This get rid of the menu-submenu strcuture by putting all groups in the current environment directly below the root of the menu structure.
 o freezeMenuStruct()
This method is called when the preferences menu has to be freezed on the tinguin.
 o getGroup(String)
Allows to get the group object with the corresponding groupname.
 o groupsList()
Gives an enumeration of all preferences groups currently loaded in the preferences environment.
 o init()
This is for Preferences initialisation.
 o isInitialised()
Returns true if a successfull init() call has been done.
 o loadPreferences()
Get the state of a the last preferences environment which has been saved.
 o loadPreferences(AccessName)
Get the state of a previously save state of the preferences environment.
 o newSubGroupBelow(String, String)
Creates or moves a subgroup below another one.
 o newSubGroupBelowRoot(String)
Puts a new subgroup below the root.
 o numberOfGroups()
Gives the number of preferences groups in the current preferences environment.
 o removeFromSubGroup(String, String)
Removes a group from a subgroup.
 o savePreferences()
Save in the archive the actual state of the preferences environment in the default file.
 o savePreferences(AccessName)
Save the actual state of the preferences environment.
 o update(PrefGroup)
This method is called when the user's modifications for a preferences group are accepted.
 o upToDate()
Indicates preferences are up to date which means that there is no need to save them again.
 o whichAreNotLoaded(String[])
This returns an enumeration of the input groups not already loaded in the preferences environment.

Variables

 o root
  public final static String root
 o groupMapping
  protected static Hashtable groupMapping
 o superGroupMapping
  protected static Hashtable superGroupMapping

Constructors

 o Preferences
  public Preferences()

Methods

 o init
  public static boolean init() throws PreferencesException
This is for Preferences initialisation. Configuration must be initialised first. Preferences data are loaded from the standard file in the Archive. Archive and Access control have to be initialised first. The capability for preferences inspection is stored in the standard MediumRole of the access control. If the only problem is that no default Preferences file has been found then an initialised empty environment is returned. If no error is thrown then the preferences manager is initialised after the call. If an error is thrown the preferences manager is not initialised after the call. Right after the Preferences are loaded from the default file, preferences groups in the PreferencesAdditions list are inserted as well. N.B. The Access control is unplugued right now.
Returns:
true iff the default preferences file has been found and loaded successfully.
Throws: PreferencesException
when Configuration or Archive or Access are not initialised.
See Also:
PreferencesAdditions
 o isInitialised
  public static boolean isInitialised()
Returns true if a successfull init() call has been done.
Returns:
true iff configuration are loaded and Preferences are initiliazed.
 o whichAreNotLoaded
  public static Vector whichAreNotLoaded(String groupNames[])
This returns an enumeration of the input groups not already loaded in the preferences environment. This is used when a manager wants to determine if its preferences groups have been loaded at initialisation. For those not in the environment, the manager should build the appropropriate groups.
Parameters:
groupNames - contains the group names for which the presence is tested.
Returns:
a vector of the input group names not already in the preferences.
 o groupsList
  public static Enumeration groupsList()
Gives an enumeration of all preferences groups currently loaded in the preferences environment.
Returns:
Enumeration of all groups.
 o displayMenuStruct
  public static void displayMenuStruct()
Display the internal menu structure of the Preferences manager on the standard output.
 o numberOfGroups
  public static int numberOfGroups()
Gives the number of preferences groups in the current preferences environment.
Returns:
the number of preferences groups.
 o addGroup
  public static boolean addGroup(PrefGroup group)
Allows to add a new group in the current preferences environment. If the group already exists, nothing is done.
Parameters:
group - is the group to be added in the preferences environment.
Returns:
true if and only if the group already exists.
 o delGroup
  public static boolean delGroup(String groupName)
Allows to delete a group from the current preferences environment. Nothing is done if the group does not exist.
Parameters:
groupName - is the group name to delete.
Returns:
true if and only if the group already existed.
 o getGroup
  public static PrefGroup getGroup(String groupName) throws PreferencesNoSuchGroupException
Allows to get the group object with the corresponding groupname.
Parameters:
groupName - is the name of the group to retrieve.
Returns:
PrefGroup object with the given group name.
Throws: PreferencesNoSuchGroupException
if no group with the given name has been found.
 o freezeMenuStruct
  public static synchronized void freezeMenuStruct() throws PreferencesException
This method is called when the preferences menu has to be freezed on the tinguin.
Returns:
none.
Throws: PreferencesException
when no menu structure can be retrieved.
 o flattenSubGroupsStructure
  public static void flattenSubGroupsStructure()
This get rid of the menu-submenu strcuture by putting all groups in the current environment directly below the root of the menu structure.
Returns:
none.
 o addToRoot
  public static void addToRoot(String gname)
Adds or moves a group directly below the root subgroup.
Parameters:
gname - the name of the group to add to the root. If the group was part of another subgroup then the group is moved to be part of the root subgroup.
Returns:
none.
 o addToSubGroup
  public static boolean addToSubGroup(String gname,
                                      String sgname)
This method is used to add a group in a subgroup. If the subgroup does not exist then it is created. If the group is already in the subgroup then nothing is done. If the group is part of another subgroup then the group is moved from the previous subgroup to the input one.
Parameters:
gname - is the name for the group to be added (i.e. the name corresponding to a PrefGroup object already in the preferences environment).
sgname - is the name of the subgroup where to put the group. This is only a string, not a PrefGroup.
Returns:
true if and only if the group exists.
 o removeFromSubGroup
  public static boolean removeFromSubGroup(String gname,
                                           String sgname)
Removes a group from a subgroup. The group is put as a part of the root subgroup. If the group is not part of the specified subgroup nothing is done.
Parameters:
gname - is the name for the group to remove. Should be the name of an existing PrefGroup object already in the environment.
sgname - is the name of the subgroup (i.e. this does not correspond to PrefGroup object; a subgroup is not a PrefGroup).
Returns:
true iff something is done.
 o newSubGroupBelowRoot
  public static boolean newSubGroupBelowRoot(String sgname)
Puts a new subgroup below the root. If the new subgroup already exists nothing is done.
Parameters:
sgname - is the name for the new subgroup. If the group already exists, then the subgroup becomes immediatly below the root.
Returns:
true iff the subgroup did not exist.
 o newSubGroupBelow
  public static boolean newSubGroupBelow(String sgname,
                                         String above)
Creates or moves a subgroup below another one. If a cycle is formed when the subgroup is added then nohing is done.
Parameters:
sgname - the subgroup to be put or moved
above - is the subgroup where to put the new subgroup
Returns:
true iff no cycle has been detected.
 o editGroup
  public static synchronized void editGroup(String groupName,
                                            PrefFrame p) throws PreferencesNoSuchGroupException, PreferencesException
This is called when interactive edition of the preferences are needed. This method build the frame for interactive edition of a preferences group. The user-capability has to be unlocked for the method to be executed. If the preferences have not been save (they are not up to date) when calling this method, then preferences are automatically saved before launching interactive editing.
Parameters:
groupName - is the group name to edit.
prefFrame - is the frame in which the components are displayed.
Returns:
none
Throws: PreferencesNoSuchGroupException
when the group is not found.
Throws: PreferencesException
when the capability to edit is not part of an unlocked role.
 o update
  protected static synchronized boolean update(PrefGroup g) throws PreferencesNoSuchGroupException, PreferencesException
This method is called when the user's modifications for a preferences group are accepted. The new fields values are applied to each PrefField object of the group. If the current environment is not upToDate, nothing is done.
Parameters:
g - is the group to update.
Returns:
true if the modifications are correct and performed. Return false otherwise, in that case no modifications are performed.
Throws: PreferencesNoSuchGroupException
when the group to update is not found.
Throws: PreferencesException
when prolems occur during saving preferences.
 o cancel
  protected static synchronized void cancel(PrefGroup g,
                                            boolean isCancel) throws PreferencesNoSuchGroupException
This method is called when the user's modifications for a preferences group are canceled. The fields values before modification are shown back to the user.
Parameters:
g - is the group where the cancelled actions are performed.
isCancel - is true when the group is no more in edition after the method is executed.
Returns:
none.
Throws: PreferencesNoSuchGroupException
when the group to cancel is not in the current environment.
 o savePreferences
  public static synchronized void savePreferences(AccessName fileAccess) throws PreferencesException
Save the actual state of the preferences environment. The file is stored encrypted using Archive encryption facilities. If the input AccessName is the same than the one previously used to load the current environment, the preferences environment file is upToDate.
Parameters:
filename - is an handle for the file to store (to be completed).
Returns:
none
Throws: PreferencesException
when saving cannot be completed.
See Also:
ArchiveMan
 o savePreferences
  public static synchronized void savePreferences() throws PreferencesException
Save in the archive the actual state of the preferences environment in the default file. The file is stored encrypted using Archive encryption facilities. The resulting preferences environment is upToDate.
Returns:
none
Throws: PreferencesException
when saving cannot be completed.
See Also:
ArchiveMan
 o loadPreferences
  public static synchronized boolean loadPreferences(AccessName fileAccess) throws PreferencesException
Get the state of a previously save state of the preferences environment. The resulting preferences environment is upToDate.
Parameters:
fileAccess - is the accessname for the file to retrieve (to be completed) from archive manager.
Returns:
true iff the preferences file with the corresponding fileAccess has been loaded successfully.
Throws: PreferencesException
when a group is currently in edition or when a problem with archive is detected.
See Also:
upToDate
 o loadPreferences
  public static synchronized boolean loadPreferences() throws PreferencesException
Get the state of a the last preferences environment which has been saved. The resulting preferences environment is upToDate.
Returns:
true iff the default preferences file has been found and loaded.
Throws: PreferencesException
when the file is not found.
Throws: PreferencesException
when a group is currently in edition.
See Also:
upToDate
 o delAllGroups
  protected static void delAllGroups() throws PreferencesException
Delete all groups in the current environment iff no one is in edition.
Returns:
none.
Throws: PreferencesException
when at least one group is currently in edition.
 o upToDate
  public static boolean upToDate()
Indicates preferences are up to date which means that there is no need to save them again.
Returns:
true iff the preferences have to be saved.

All Packages  Class Hierarchy  This Package  Previous  Next  Index