diff options
author | John Arthorne | 2009-02-27 18:33:11 +0000 |
---|---|---|
committer | John Arthorne | 2009-02-27 18:33:11 +0000 |
commit | 9d853fd8c5a3a233c08a1bde52a0a71dd77e5ef8 (patch) | |
tree | 34916c0a99d03a5580c7d4089e6b32a8642897e5 /bundles/org.eclipse.equinox.p2.touchpoint.eclipse | |
parent | 57ac5b7be570a32d2eb9c7534a05e83041b1abe5 (diff) | |
download | rt.equinox.p2-9d853fd8c5a3a233c08a1bde52a0a71dd77e5ef8.tar.gz rt.equinox.p2-9d853fd8c5a3a233c08a1bde52a0a71dd77e5ef8.tar.xz rt.equinox.p2-9d853fd8c5a3a233c08a1bde52a0a71dd77e5ef8.zip |
Bug 194224 [ui] User nicknames for repositories
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse')
4 files changed, 19 insertions, 10 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java index ad7ec6374..bf4d49b33 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java @@ -41,5 +41,6 @@ public class ActionConstants { public static final String PARM_REPOSITORY_LOCATION = "location"; //$NON-NLS-1$ public static final String PARM_REPOSITORY_TYPE = "type"; //$NON-NLS-1$ public static final String PARM_REPOSITORY_ENABLEMENT = "enabled"; //$NON-NLS-1$ + public static final String PARM_REPOSITORY_NICKNAME = "name"; //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java index bb8c6af1d..9dca39aad 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java @@ -26,7 +26,7 @@ public class AddRepositoryAction extends RepositoryAction { final RepositoryEvent event = createEvent(parameters); Profile profile = (Profile) parameters.get(ActionConstants.PARM_PROFILE); if (profile != null) - addRepositoryToProfile(profile, event.getRepositoryLocation(), event.getRepositoryType(), event.isRepositoryEnabled()); + addRepositoryToProfile(profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled()); //if provisioning into the current profile, broadcast an event to add this repository directly to the current repository managers. if (isSelfProfile(profile)) addToSelf(event); diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java index 9ab8cdefb..d1116fe98 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java @@ -41,7 +41,7 @@ public class RemoveRepositoryAction extends RepositoryAction { RepositoryEvent event = createEvent(parameters); Profile profile = (Profile) parameters.get(ActionConstants.PARM_PROFILE); if (profile != null) - addRepositoryToProfile(profile, event.getRepositoryLocation(), event.getRepositoryType(), event.isRepositoryEnabled()); + addRepositoryToProfile(profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled()); //if we are provisioning into the self profile, update the current set of repositories in this configuration if (isSelfProfile(profile)) addToSelf(event); diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java index 04071393a..1818e6088 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java @@ -43,6 +43,7 @@ abstract class RepositoryAction extends ProvisioningAction { private static final String REPOSITORY_COUNT = "count"; //$NON-NLS-1$ private static final String KEY_URI = "uri"; //$NON-NLS-1$ private static final String KEY_ENABLED = "enabled"; //$NON-NLS-1$ + private static final String KEY_NICKNAME = "nickname"; //$NON-NLS-1$ /** * Returns the repository manager of the given type, or <code>null</code> @@ -61,18 +62,20 @@ abstract class RepositoryAction extends ProvisioningAction { * Associates the repository described by the given event with the given profile. * Has no effect if the repository is already associated with this profile. */ - protected void addRepositoryToProfile(Profile profile, URI location, int type, boolean enabled) { + protected void addRepositoryToProfile(Profile profile, URI location, String nickname, int type, boolean enabled) { Preferences node = getRepositoryPreferenceNode(profile, location, type); int count = 0; if (repositoryExists(node)) { - count = getRepositoryCount(node);; - // If a user as added a repository we need to set the initial count manually + count = getRepositoryCount(node); + // If a user has added a repository we need to set the initial count manually if (count == 0) count = 1; } node.put(KEY_URI, location.toString()); node.put(KEY_ENABLED, Boolean.toString(enabled)); + if (nickname != null) + node.put(KEY_NICKNAME, nickname); count++; setRepositoryCount(node, count); try { @@ -87,23 +90,27 @@ abstract class RepositoryAction extends ProvisioningAction { */ protected void addToSelf(RepositoryEvent event) { IRepositoryManager manager = getRepositoryManager(event.getRepositoryType()); - Preferences node = getRepositoryPreferenceNode(null, event.getRepositoryLocation(), event.getRepositoryType()); + final URI location = event.getRepositoryLocation(); + Preferences node = getRepositoryPreferenceNode(null, location, event.getRepositoryType()); int count = getRepositoryCount(node); - if (manager.contains(event.getRepositoryLocation())) { + if (manager.contains(location)) { // If a user as added a repository we need to set the initial count manually if (count == 0) count = 1; } else { if (manager != null) - manager.addRepository(event.getRepositoryLocation()); + manager.addRepository(location); } // increment the counter & send to preferences count++; setRepositoryCount(node, count); if (!event.isRepositoryEnabled()) - manager.setEnabled(event.getRepositoryLocation(), false); + manager.setEnabled(location, false); + final String name = event.getRepositoryNickname(); + if (name != null) + manager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name); } protected RepositoryEvent createEvent(Map parameters) throws CoreException { @@ -125,10 +132,11 @@ abstract class RepositoryAction extends ProvisioningAction { } catch (NumberFormatException e) { throw new CoreException(Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_REPOSITORY_TYPE, getId()), e)); } + String name = (String) parameters.get(ActionConstants.PARM_REPOSITORY_NICKNAME); //default is to be enabled String enablement = (String) parameters.get(ActionConstants.PARM_REPOSITORY_ENABLEMENT); boolean enabled = enablement == null ? true : Boolean.valueOf(enablement).booleanValue(); - return new RepositoryEvent(location, type, RepositoryEvent.DISCOVERED, enabled); + return RepositoryEvent.newDiscoveryEvent(location, name, type, enabled); } /** |