pl.edu.agh.cast.project
Class UserPreferences

java.lang.Object
  extended by pl.edu.agh.cast.project.UserPreferences

public class UserPreferences
extends Object

Contains global user preferences.

Author:
AGH CAST Team

Nested Class Summary
static class UserPreferences.Pref
          Enumeration of user preferences.
 
Constructor Summary
UserPreferences()
           
 
Method Summary
 void changeMostRecentlyProjectName(org.eclipse.core.resources.IProject project, String newName)
          Changes MRU project name.
static UserPreferences getInstance()
          Returns single, shared instance of UserPreferences.
 List<MostRecentlyUsedProject> getMostRecentlyUsedProjects()
          Returns a list of MRU projects.
 String getPreference(UserPreferences.Pref pref)
          Returns the value of given preference.
 void initializeDefaults()
          Initializes default preference values.
 void registerMostRecentlyUsedProject(org.eclipse.core.resources.IProject p)
          MRU projects are kept in the preferences in the following form
 void removeMRUProject(String name)
          Removes project from Most Recently Used (MRU) list.
 void setPreference(UserPreferences.Pref pref, String val)
          Sets the value of given preference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserPreferences

public UserPreferences()
Method Detail

getInstance

public static UserPreferences getInstance()
Returns single, shared instance of UserPreferences.

Returns:
single, shared instance of UserPreferences

removeMRUProject

public void removeMRUProject(String name)
Removes project from Most Recently Used (MRU) list.

Parameters:
name - name of the project

getMostRecentlyUsedProjects

public List<MostRecentlyUsedProject> getMostRecentlyUsedProjects()
Returns a list of MRU projects.

Returns:
a list of MRU projects

changeMostRecentlyProjectName

public void changeMostRecentlyProjectName(org.eclipse.core.resources.IProject project,
                                          String newName)
Changes MRU project name. If project is bound to only one location then replaces old project with new one. If project is bound to more locations -> removes actual project location from 'old name project' bound, and adds new project name with actual location.

Parameters:
project - Project with old name.
newName - Future new name of project.

registerMostRecentlyUsedProject

public void registerMostRecentlyUsedProject(org.eclipse.core.resources.IProject p)
MRU projects are kept in the preferences in the following form
 MRU
 |_ order
    |_ 0 = project_name0
    |_ 1 = project_name1
    ...
    |_ n = project_namen
 |_ #project_name0
    |_ 0 = most_recent_location
    |_ 1 = older_location
    ...
    |_ n = oldest_location
 |_ #project_name1
    ...
 ...
 

Parameters:
p - project to set as most recently used

setPreference

public void setPreference(UserPreferences.Pref pref,
                          String val)
Sets the value of given preference.

Parameters:
pref - preference
val - the value

getPreference

public String getPreference(UserPreferences.Pref pref)
Returns the value of given preference.

Parameters:
pref - preference
Returns:
the value

initializeDefaults

public void initializeDefaults()
Initializes default preference values.



Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.