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