### Eclipse Workspace Patch 1.0 #P org.eclipse.team.ui Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.team.ui/META-INF/MANIFEST.MF,v retrieving revision 1.28 diff -u -r1.28 MANIFEST.MF --- META-INF/MANIFEST.MF 10 Jul 2009 13:25:27 -0000 1.28 +++ META-INF/MANIFEST.MF 30 Oct 2009 10:52:01 -0000 @@ -8,6 +8,7 @@ Bundle-Localization: plugin Export-Package: org.eclipse.team.internal.ui;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui", org.eclipse.team.internal.ui.actions;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui", + org.eclipse.team.internal.ui.commands;x-internal:=true, org.eclipse.team.internal.ui.dialogs;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui", org.eclipse.team.internal.ui.history;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui", org.eclipse.team.internal.ui.mapping;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui", Index: plugin.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.team.ui/plugin.properties,v retrieving revision 1.76 diff -u -r1.76 plugin.properties --- plugin.properties 27 Nov 2008 16:19:41 -0000 1.76 +++ plugin.properties 30 Oct 2009 10:52:01 -0000 @@ -78,3 +78,8 @@ CompareWithEachOtherAction.tooltip= Compare the Selected Resources ignoresTransferName= Team Ignored Resources Transfer + +Share_single_project_command.description = Share project using team provider +Share_single_project_command.name = Share using {0} +Share_single_project_command.parameter.name = Provider +Share_single_project_command.parameter.name.0 = Project Index: plugin.xml =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.team.ui/plugin.xml,v retrieving revision 1.202 diff -u -r1.202 plugin.xml --- plugin.xml 16 Oct 2009 10:29:25 -0000 1.202 +++ plugin.xml 30 Oct 2009 10:52:01 -0000 @@ -329,6 +329,24 @@ description="%Synchronizing.openPerspectiveDescription" categoryId="org.eclipse.ui.category.perspectives" id="org.eclipse.team.ui.TeamSynchronizingPerspective"/> + + + + + + + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.team.internal.ui.commands; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.commands.IParameterValues; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.team.core.RepositoryProvider; + +/** + * Provides list of accessible and non-shared projects' names for the Share + * Project command. + */ +public class ProjectNameParameterValues implements IParameterValues { + + public Map getParameterValues() { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IProject[] projects = root.getProjects(); + Map paramValues = new HashMap(); + for (int i = 0; i < projects.length; i++) { + IProject project = projects[i]; + final boolean notAlreadyShared = RepositoryProvider + .getProvider(project) == null; + if (project.isAccessible() && notAlreadyShared) + paramValues.put(project.getName(), project.getName()); + } + return paramValues; + } + +} Index: src/org/eclipse/team/internal/ui/commands/ShareSingleProjectCommand.java =================================================================== RCS file: src/org/eclipse/team/internal/ui/commands/ShareSingleProjectCommand.java diff -N src/org/eclipse/team/internal/ui/commands/ShareSingleProjectCommand.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/team/internal/ui/commands/ShareSingleProjectCommand.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (C) 2009, Mykola Nikishov + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.team.internal.ui.commands; + +import org.eclipse.core.commands.*; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.*; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard; +import org.eclipse.team.ui.IConfigurationWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * Provides a handler for the Share Project command. This can then be bound to + * whatever keybinding the user prefers. + */ +public class ShareSingleProjectCommand extends AbstractHandler { + + private static final String TEAM_WIZARD_NAME_PARAMETER = "org.eclipse.team.internal.ui.commands.TeamProviderNameParameter"; //$NON-NLS-1$ + + private static final String PROJECT_NAME_PARAMETER = "org.eclipse.team.internal.ui.commands.ProjectNameParameter"; //$NON-NLS-1$ + + static final String TEAM_UI_CONFIGURATION_WIZARD_EXTENSION = "org.eclipse.team.ui.configurationWizards"; //$NON-NLS-1$ + + /** + * Invokes a wizard dialog which associates a project with a given team + * provider. Wizard dialog must be declared in + * org.eclipse.team.ui.configurationWizards extension point and extend + * {@link IConfigurationWizard}. + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + final String projectName = event.getParameter(PROJECT_NAME_PARAMETER); + final IProject projectToShare = ResourcesPlugin.getWorkspace() + .getRoot().getProject(projectName); + IWorkbench workbench = HandlerUtil.getActiveWorkbenchWindow(event) + .getWorkbench(); + final IExtensionRegistry extensionRegistry = Platform + .getExtensionRegistry(); + final IExtensionPoint extension = extensionRegistry + .getExtensionPoint(ShareSingleProjectCommand.TEAM_UI_CONFIGURATION_WIZARD_EXTENSION); + IConfigurationElement[] configurationElements = extension + .getConfigurationElements(); + try { + IConfigurationWizard wizard = findAndInstantiateWizard(event, + configurationElements); + wizard.init(workbench, projectToShare); + final Shell shell = HandlerUtil.getActiveShell(event); + ConfigureProjectWizard.openWizard(shell, wizard); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + private IConfigurationWizard findAndInstantiateWizard(ExecutionEvent event, + IConfigurationElement[] configurationElements) throws CoreException { + for (int i = 0; i < configurationElements.length; i++) { + IConfigurationElement element = configurationElements[i]; + final String id = element.getAttribute("id"); //$NON-NLS-1$ + if (id != null + && id + .equals(event + .getParameter(TEAM_WIZARD_NAME_PARAMETER))) { + + return (IConfigurationWizard) element + .createExecutableExtension("class"); //$NON-NLS-1$ + } + } + return null; + } +} Index: src/org/eclipse/team/internal/ui/commands/TeamProviderNameParameterValues.java =================================================================== RCS file: src/org/eclipse/team/internal/ui/commands/TeamProviderNameParameterValues.java diff -N src/org/eclipse/team/internal/ui/commands/TeamProviderNameParameterValues.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/team/internal/ui/commands/TeamProviderNameParameterValues.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (C) 2009, Mykola Nikishov + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.team.internal.ui.commands; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.commands.IParameterValues; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; + +/** + * Provides list of available team providers' names for the Share Project + * command. + */ +public class TeamProviderNameParameterValues implements IParameterValues { + + public Map getParameterValues() { + IConfigurationElement[] configurationElements = Platform + .getExtensionRegistry() + .getConfigurationElementsFor( + ShareSingleProjectCommand.TEAM_UI_CONFIGURATION_WIZARD_EXTENSION); + Map paramValues = new HashMap(); + for (int i = 0; i < configurationElements.length; i++) { + IConfigurationElement teamWizard = configurationElements[i]; + paramValues.put(teamWizard.getAttribute("name"), teamWizard //$NON-NLS-1$ + .getAttribute("id")); //$NON-NLS-1$ + } + return paramValues; + } + +}