Class ProfileManager
java.lang.Object
java.util.Observable
org.eclipse.m2m.atl.adt.ui.preferences.ProfileManager
- Direct Known Subclasses:
AtlCodeFormatterProfileManager
The model for the set of profiles which are available in the workbench.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Represents a built-in profile.static class
Represents a user-defined profile.static final class
static class
Represents a profile with a unique ID, a name and a map containing the code formatter settings.final class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
A prefix which is prepended to every ID of a user-defined profile, in order to differentiate it from a built-in profile.static final int
static final int
static final int
static final int
The possible events for observers listening to this class.static final int
-
Constructor Summary
ConstructorDescriptionProfileManager
(List<ProfileManager.Profile> profiles, org.eclipse.core.runtime.preferences.IScopeContext context, PreferencesAccess preferencesAccess, ProfileManager.KeySet[] keySets, String profileKey) Create and initialize a new profile manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
(String name) Check whether a user-defined profile in this profile manager already has this name.boolean
boolean
Delete the currently selected profile from this profile manager.abstract ProfileManager.Profile
getProfile
(String ID) Get the profile for this profile id.Get the currently selected profile.protected String
getSelectedProfileId
(org.eclipse.core.runtime.preferences.IScopeContext instanceScope) String[]
Get the names of all profiles stored in this profile manager, sorted alphabetically.Get an immutable list as view on all profiles, sorted alphabetically.boolean
hasProjectSpecificSettings
(org.eclipse.core.runtime.preferences.IScopeContext context) static boolean
hasProjectSpecificSettings
(org.eclipse.core.runtime.preferences.IScopeContext context, ProfileManager.KeySet[] keySets) protected void
notifyObservers
(int message) Notify observers with a message.void
void
profileRenamed
(ProfileManager.CustomProfile profile, String oldID) void
profileReplaced
(ProfileManager.CustomProfile oldProfile, ProfileManager.CustomProfile newProfile) void
setSelected
(ProfileManager.Profile profile) Set the selected profile.protected void
updateProfilesWithName
(String oldName, ProfileManager.Profile newProfile, boolean applySettings) Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
-
Field Details
-
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:
-
SELECTION_CHANGED_EVENT
public static final int SELECTION_CHANGED_EVENTThe possible events for observers listening to this class.- See Also:
-
PROFILE_DELETED_EVENT
public static final int PROFILE_DELETED_EVENT- See Also:
-
PROFILE_RENAMED_EVENT
public static final int PROFILE_RENAMED_EVENT- See Also:
-
PROFILE_CREATED_EVENT
public static final int PROFILE_CREATED_EVENT- See Also:
-
SETTINGS_CHANGED_EVENT
public static final int SETTINGS_CHANGED_EVENT- See Also:
-
-
Constructor Details
-
ProfileManager
public ProfileManager(List<ProfileManager.Profile> profiles, org.eclipse.core.runtime.preferences.IScopeContext context, PreferencesAccess preferencesAccess, ProfileManager.KeySet[] keySets, String profileKey) Create and initialize a new profile manager.- Parameters:
profiles
- Initial custom profiles (List of typeCustomProfile
)
-
-
Method Details
-
getSelectedProfileId
protected String getSelectedProfileId(org.eclipse.core.runtime.preferences.IScopeContext instanceScope) -
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:
-
hasProjectSpecificSettings
public static boolean hasProjectSpecificSettings(org.eclipse.core.runtime.preferences.IScopeContext context, ProfileManager.KeySet[] keySets) -
hasProjectSpecificSettings
public boolean hasProjectSpecificSettings(org.eclipse.core.runtime.preferences.IScopeContext context) -
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 bygetSortedNames
.- Returns:
- a list of elements of type
Profile
- See Also:
-
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 bygetSortedProfiles
.- Returns:
- All names, sorted alphabetically
- See Also:
-
getProfile
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. -
clearAllSettings
public void clearAllSettings(org.eclipse.core.runtime.preferences.IScopeContext context) -
getSelected
Get the currently selected profile.- Returns:
- The currently selected profile.
-
setSelected
Set the selected profile. The profile must already be contained in this profile manager.- Parameters:
profile
- The profile to select
-
containsName
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
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
-
profileRenamed
-
profileReplaced
public void profileReplaced(ProfileManager.CustomProfile oldProfile, ProfileManager.CustomProfile newProfile) -
profileChanged
-
updateProfilesWithName
protected void updateProfilesWithName(String oldName, ProfileManager.Profile newProfile, boolean applySettings) -
getDefaultProfile
-