com.aptana.ide.ui.editors.preferences.formatter
Class ProfileManager

java.lang.Object
  extended by java.util.Observable
      extended by com.aptana.ide.ui.editors.preferences.formatter.ProfileManager
Direct Known Subclasses:
FormatterProfileManager

public abstract class ProfileManager
extends java.util.Observable

The model for the set of profiles which are available in the workbench.


Nested Class Summary
static class ProfileManager.BuiltInProfile
          Represents a built-in profile.
static class ProfileManager.CustomProfile
          Represents a user-defined profile.
static class ProfileManager.KeySet
           
static class ProfileManager.Profile
          Represents a profile with a unique ID, a name and a map containing the code formatter settings.
 class ProfileManager.SharedProfile
           
 
Field Summary
static java.lang.String ID_PREFIX
          A prefix which is prepended to every ID of a user-defined profile, in order to differentiate it from a built-in profile.
protected  java.lang.String pluginId
           
static int PROFILE_CREATED_EVENT
           
static int PROFILE_DELETED_EVENT
           
static int PROFILE_RENAMED_EVENT
           
static int SELECTION_CHANGED_EVENT
          The possible events for observers listening to this class.
static int SETTINGS_CHANGED_EVENT
           
 
Constructor Summary
ProfileManager(java.util.List profiles, org.eclipse.core.runtime.preferences.IScopeContext context, PreferencesAccess preferencesAccess, ProfileManager.KeySet[] keySets, java.lang.String profileKey, java.lang.String profileVersionKey, java.lang.String pluginId)
          Create and initialize a new profile manager.
 
Method Summary
 void addProfile(ProfileManager.CustomProfile profile)
          Add a new custom profile to this profile manager.
 void clearAllSettings(org.eclipse.core.runtime.preferences.IScopeContext context)
           
 void commitChanges(org.eclipse.core.runtime.preferences.IScopeContext scopeContext)
          Activate the selected profile, update all necessary options in preferences and save profiles to disk.
 boolean containsName(java.lang.String name)
          Check whether a user-defined profile in this profile manager already has this name.
 boolean deleteProfile(ProfileManager.CustomProfile profile)
           
 boolean deleteSelected()
          Delete the currently selected profile from this profile manager.
abstract  ProfileManager.Profile getDefaultProfile()
           
 ProfileManager.Profile getProfile(java.lang.String ID)
          Get the profile for this profile id.
 ProfileManager.Profile getSelected()
          Get the currently selected profile.
protected  java.lang.String getSelectedProfileId(org.eclipse.core.runtime.preferences.IScopeContext instanceScope)
           
 java.lang.String[] getSortedDisplayNames()
          Get the names of all profiles stored in this profile manager, sorted alphabetically.
 java.util.List getSortedProfiles()
          Get an immutable list as view on all profiles, sorted alphabetically.
 boolean hasProjectSpecificSettings(org.eclipse.core.runtime.preferences.IScopeContext context)
           
 boolean hasProjectSpecificSettings(org.eclipse.core.runtime.preferences.IScopeContext context, ProfileManager.KeySet[] keySets)
           
protected  void notifyObservers(int message)
          Notify observers with a message.
 void profileChanged(ProfileManager.CustomProfile profile)
           
 void profileRenamed(ProfileManager.CustomProfile profile, java.lang.String oldID)
           
 void profileReplaced(ProfileManager.CustomProfile oldProfile, ProfileManager.CustomProfile newProfile)
           
 void setSelected(ProfileManager.Profile profile)
          Set the selected profile.
protected  void updateProfilesWithName(java.lang.String oldName, ProfileManager.Profile newProfile, boolean applySettings)
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_PREFIX

public static final java.lang.String ID_PREFIX
A prefix which is prepended to every ID of a user-defined profile, in order to differentiate it from a built-in profile.

See Also:
Constant Field Values

SELECTION_CHANGED_EVENT

public static final int SELECTION_CHANGED_EVENT
The possible events for observers listening to this class.

See Also:
Constant Field Values

PROFILE_DELETED_EVENT

public static final int PROFILE_DELETED_EVENT
See Also:
Constant Field Values

PROFILE_RENAMED_EVENT

public static final int PROFILE_RENAMED_EVENT
See Also:
Constant Field Values

PROFILE_CREATED_EVENT

public static final int PROFILE_CREATED_EVENT
See Also:
Constant Field Values

SETTINGS_CHANGED_EVENT

public static final int SETTINGS_CHANGED_EVENT
See Also:
Constant Field Values

pluginId

protected java.lang.String pluginId
Constructor Detail

ProfileManager

public ProfileManager(java.util.List profiles,
                      org.eclipse.core.runtime.preferences.IScopeContext context,
                      PreferencesAccess preferencesAccess,
                      ProfileManager.KeySet[] keySets,
                      java.lang.String profileKey,
                      java.lang.String profileVersionKey,
                      java.lang.String pluginId)
Create and initialize a new profile manager.

Parameters:
profiles - Initial custom profiles (List of type CustomProfile)
context -
preferencesAccess -
keySets -
profileKey -
profileVersionKey -
pluginId -
Method Detail

getSelectedProfileId

protected java.lang.String getSelectedProfileId(org.eclipse.core.runtime.preferences.IScopeContext instanceScope)
Parameters:
instanceScope -
Returns:
String

notifyObservers

protected void notifyObservers(int message)
Notify observers with a message. The message must be one of the following:

Parameters:
message - Message to send out
See Also:
SELECTION_CHANGED_EVENT, PROFILE_DELETED_EVENT, PROFILE_RENAMED_EVENT, PROFILE_CREATED_EVENT, SETTINGS_CHANGED_EVENT

hasProjectSpecificSettings

public boolean hasProjectSpecificSettings(org.eclipse.core.runtime.preferences.IScopeContext context,
                                          ProfileManager.KeySet[] keySets)
Parameters:
context -
keySets -
Returns:
value

hasProjectSpecificSettings

public boolean hasProjectSpecificSettings(org.eclipse.core.runtime.preferences.IScopeContext context)
Parameters:
context -
Returns:
value

getSortedProfiles

public java.util.List getSortedProfiles()
Get an immutable list as view on all profiles, sorted alphabetically. Unless the set of profiles has been modified between the two calls, the sequence is guaranteed to correspond to the one returned by getSortedNames.

Returns:
a list of elements of type Profile
See Also:
getSortedDisplayNames()

getSortedDisplayNames

public java.lang.String[] getSortedDisplayNames()
Get the names of all profiles stored in this profile manager, sorted alphabetically. Unless the set of profiles has been modified between the two calls, the sequence is guaranteed to correspond to the one returned by getSortedProfiles.

Returns:
All names, sorted alphabetically
See Also:
getSortedProfiles()

getProfile

public ProfileManager.Profile getProfile(java.lang.String ID)
Get the profile for this profile id.

Parameters:
ID - The profile ID
Returns:
The profile with the given ID or null

commitChanges

public void commitChanges(org.eclipse.core.runtime.preferences.IScopeContext scopeContext)
Activate the selected profile, update all necessary options in preferences and save profiles to disk.

Parameters:
scopeContext -

clearAllSettings

public void clearAllSettings(org.eclipse.core.runtime.preferences.IScopeContext context)
Parameters:
context -

getSelected

public ProfileManager.Profile getSelected()
Get the currently selected profile.

Returns:
The currently selected profile.

setSelected

public void setSelected(ProfileManager.Profile profile)
Set the selected profile. The profile must already be contained in this profile manager.

Parameters:
profile - The profile to select

containsName

public boolean containsName(java.lang.String name)
Check whether a user-defined profile in this profile manager already has this name.

Parameters:
name - The name to test for
Returns:
Returns true if a profile with the given name exists

addProfile

public void addProfile(ProfileManager.CustomProfile profile)
Add a new custom profile to this profile manager.

Parameters:
profile - The profile to add

deleteSelected

public boolean deleteSelected()
Delete the currently selected profile from this profile manager. The next profile in the list is selected.

Returns:
true if the profile has been successfully removed, false otherwise.

deleteProfile

public boolean deleteProfile(ProfileManager.CustomProfile profile)
Parameters:
profile -
Returns:
value

profileRenamed

public void profileRenamed(ProfileManager.CustomProfile profile,
                           java.lang.String oldID)
Parameters:
profile -
oldID -

profileReplaced

public void profileReplaced(ProfileManager.CustomProfile oldProfile,
                            ProfileManager.CustomProfile newProfile)
Parameters:
oldProfile -
newProfile -

profileChanged

public void profileChanged(ProfileManager.CustomProfile profile)
Parameters:
profile -

updateProfilesWithName

protected void updateProfilesWithName(java.lang.String oldName,
                                      ProfileManager.Profile newProfile,
                                      boolean applySettings)
Parameters:
oldName -
newProfile -
applySettings -

getDefaultProfile

public abstract ProfileManager.Profile getDefaultProfile()
Returns:
default Profile