View | Details | Raw Unified | Return to bug 293453 | Differences between
and this patch

Collapse All | Expand All

(-)a/plugin.properties (+5 lines)
Lines 78-80 CompareWithEachOtherAction.label= &Each Other Link Here
78
CompareWithEachOtherAction.tooltip= Compare the Selected Resources
78
CompareWithEachOtherAction.tooltip= Compare the Selected Resources
79
79
80
ignoresTransferName= Team Ignored Resources Transfer
80
ignoresTransferName= Team Ignored Resources Transfer
81
82
Share_single_project_command.description = Share project using team provider
83
Share_single_project_command.name = Share using {0}
84
Share_single_project_command.parameter.name = Provider
85
Share_single_project_command.parameter.name.0 = Project
(-)a/plugin.xml (+18 lines)
Lines 323-328 Link Here
323
        	description="%Synchronizing.openPerspectiveDescription"
323
        	description="%Synchronizing.openPerspectiveDescription"
324
        	categoryId="org.eclipse.ui.category.perspectives"
324
        	categoryId="org.eclipse.ui.category.perspectives"
325
        	id="org.eclipse.team.ui.TeamSynchronizingPerspective"/>
325
        	id="org.eclipse.team.ui.TeamSynchronizingPerspective"/>
326
      <command
327
            defaultHandler="org.eclipse.team.internal.ui.commands.ShareSingleProjectCommand"
328
            description="%Share_single_project_command.description"
329
            id="org.eclipse.team.ui.ShareSingleProjectWithProvider"
330
            name="%Share_single_project_command.name">
331
         <commandParameter
332
               id="org.eclipse.team.internal.ui.commands.TeamProviderNameParameter"
333
               name="%Share_single_project_command.parameter.name"
334
               optional="false"
335
               values="org.eclipse.team.internal.ui.commands.TeamProviderNameParameterValues">
336
         </commandParameter>
337
         <commandParameter
338
               id="org.eclipse.team.internal.ui.commands.ProjectNameParameter"
339
               name="%Share_single_project_command.parameter.name.0"
340
               optional="false"
341
               values="org.eclipse.team.internal.ui.commands.ProjectNameParameterValues">
342
         </commandParameter>
343
      </command>
326
   </extension>
344
   </extension>
327
   
345
   
328
   <extension
346
   <extension
(-)a/src/org/eclipse/team/internal/ui/commands/ProjectNameParameterValues.java (+40 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (C) 2009, Mykola Nikishov <mn@mn.com.ua>
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *******************************************************************************/
9
package org.eclipse.team.internal.ui.commands;
10
11
import java.util.HashMap;
12
import java.util.Map;
13
14
import org.eclipse.core.commands.IParameterValues;
15
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IWorkspaceRoot;
17
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.team.core.RepositoryProvider;
19
20
/**
21
 * Provides list of accessible and non-shared projects' names for the Share
22
 * Project command.
23
 */
24
public class ProjectNameParameterValues implements IParameterValues {
25
26
	public Map getParameterValues() {
27
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
28
		IProject[] projects = root.getProjects();
29
		Map paramValues = new HashMap();
30
		for (int i = 0; i < projects.length; i++) {
31
			IProject project = projects[i];
32
			final boolean notAlreadyShared = RepositoryProvider
33
					.getProvider(project) == null;
34
			if (project.isAccessible() && notAlreadyShared)
35
				paramValues.put(project.getName(), project.getName());
36
		}
37
		return paramValues;
38
	}
39
40
}
(-)a/src/org/eclipse/team/internal/ui/commands/ShareSingleProjectCommand.java (+88 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (C) 2009, Mykola Nikishov <mn@mn.com.ua>
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *******************************************************************************/
9
package org.eclipse.team.internal.ui.commands;
10
11
import org.eclipse.core.commands.AbstractHandler;
12
import org.eclipse.core.commands.ExecutionEvent;
13
import org.eclipse.core.commands.ExecutionException;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.resources.ResourcesPlugin;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IConfigurationElement;
18
import org.eclipse.core.runtime.IExtensionPoint;
19
import org.eclipse.core.runtime.IExtensionRegistry;
20
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.swt.widgets.Shell;
22
import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;
23
import org.eclipse.team.ui.IConfigurationWizard;
24
import org.eclipse.ui.IWorkbench;
25
import org.eclipse.ui.handlers.HandlerUtil;
26
27
/**
28
 * Provides a handler for the Share Project command. This can then be bound to
29
 * whatever keybinding the user prefers.
30
 */
31
public class ShareSingleProjectCommand extends AbstractHandler {
32
33
	private static final String TEAM_WIZARD_NAME_PARAMETER = "org.eclipse.team.internal.ui.commands.TeamProviderNameParameter"; //$NON-NLS-1$
34
35
	private static final String PROJECT_NAME_PARAMETER = "org.eclipse.team.internal.ui.commands.ProjectNameParameter"; //$NON-NLS-1$
36
37
	static final String TEAM_UI_CONFIGURATION_WIZARD_EXTENSION = "org.eclipse.team.ui.configurationWizards"; //$NON-NLS-1$
38
39
	/**
40
	 * Invokes a wizard dialog which associates a project with a given team
41
	 * provider. Wizard dialog must be declared in
42
	 * org.eclipse.team.ui.configurationWizards extension point and extend
43
	 * {@link IConfigurationWizard}.
44
	 *
45
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
46
	 */
47
	public Object execute(ExecutionEvent event) throws ExecutionException {
48
		final String projectName = event.getParameter(PROJECT_NAME_PARAMETER);
49
		final IProject projectToShare = ResourcesPlugin.getWorkspace()
50
				.getRoot().getProject(projectName);
51
		IWorkbench workbench = HandlerUtil.getActiveWorkbenchWindow(event)
52
				.getWorkbench();
53
		final IExtensionRegistry extensionRegistry = Platform
54
				.getExtensionRegistry();
55
		final IExtensionPoint extension = extensionRegistry
56
				.getExtensionPoint(ShareSingleProjectCommand.TEAM_UI_CONFIGURATION_WIZARD_EXTENSION);
57
		IConfigurationElement[] configurationElements = extension
58
				.getConfigurationElements();
59
		try {
60
			IConfigurationWizard wizard = findAndInstantiateWizard(event,
61
					configurationElements);
62
			wizard.init(workbench, projectToShare);
63
			final Shell shell = HandlerUtil.getActiveShell(event);
64
			ConfigureProjectWizard.openWizard(shell, wizard);
65
		} catch (CoreException e) {
66
			// TODO Auto-generated catch block
67
			e.printStackTrace();
68
		}
69
		return null;
70
	}
71
72
	private IConfigurationWizard findAndInstantiateWizard(ExecutionEvent event,
73
			IConfigurationElement[] configurationElements) throws CoreException {
74
		for (int i = 0; i < configurationElements.length; i++) {
75
			IConfigurationElement element = configurationElements[i];
76
			final String id = element.getAttribute("id");
77
			if (id != null
78
					&& id
79
							.equals(event
80
									.getParameter(TEAM_WIZARD_NAME_PARAMETER))) {
81
82
				return (IConfigurationWizard) element
83
						.createExecutableExtension("class"); //$NON-NLS-1$
84
			}
85
		}
86
		return null;
87
	}
88
}
(-)a/src/org/eclipse/team/internal/ui/commands/TeamProviderNameParameterValues.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (C) 2009, Mykola Nikishov <mn@mn.com.ua>
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *******************************************************************************/
9
package org.eclipse.team.internal.ui.commands;
10
11
import java.util.HashMap;
12
import java.util.Map;
13
14
import org.eclipse.core.commands.IParameterValues;
15
import org.eclipse.core.runtime.IConfigurationElement;
16
import org.eclipse.core.runtime.Platform;
17
18
/**
19
 * Provides list of available team providers' names for the Share Project
20
 * command.
21
 */
22
public class TeamProviderNameParameterValues implements IParameterValues {
23
24
	public Map getParameterValues() {
25
		IConfigurationElement[] configurationElements = Platform
26
				.getExtensionRegistry()
27
				.getConfigurationElementsFor(
28
						ShareSingleProjectCommand.TEAM_UI_CONFIGURATION_WIZARD_EXTENSION);
29
		Map paramValues = new HashMap();
30
		for (int i = 0; i < configurationElements.length; i++) {
31
			IConfigurationElement teamWizard = configurationElements[i];
32
			paramValues.put(teamWizard.getAttribute("name"), teamWizard //$NON-NLS-1$
33
					.getAttribute("id")); //$NON-NLS-1$
34
		}
35
		return paramValues;
36
	}
37
38
}

Return to bug 293453