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

Collapse All | Expand All

(-)a/org.eclipse.egit.ui/plugin.properties (+3 lines)
Lines 77-79 GitPreferences_name=Git Link Here
77
GitPreferences_HistoryPreferencePage_name=History
77
GitPreferences_HistoryPreferencePage_name=History
78
GitPreferences_WindowCachePreferencePage_name=Window Cache
78
GitPreferences_WindowCachePreferencePage_name=Window Cache
79
GitPreferences_DecoratorPreferencePage_name=Label Decorations
79
GitPreferences_DecoratorPreferencePage_name=Label Decorations
80
81
ShareProjectCommand_name=Share with Git
82
ShareProjectCommand_desc=Share the project using Git
(-)a/org.eclipse.egit.ui/plugin.xml (+15 lines)
Lines 385-388 Link Here
385
		</action>
385
		</action>
386
      </actionSet>
386
      </actionSet>
387
   </extension>
387
   </extension>
388
   <extension
389
         point="org.eclipse.ui.commands">
390
      <command
391
            defaultHandler="org.eclipse.egit.ui.internal.commands.ShareSingleProjectCommand"
392
            description="%ShareProjectCommand_desc"
393
            id="org.eclipse.egit.ui.command.shareProject"
394
            name="%ShareProjectCommand_name">
395
         <commandParameter
396
               id="org.eclipse.egit.ui.command.projectNameParameter"
397
               name="Project"
398
               optional="false"
399
               values="org.eclipse.egit.ui.internal.commands.ProjectNameParameterValues">
400
         </commandParameter>
401
      </command>
402
   </extension>
388
</plugin>
403
</plugin>
(-)a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/ProjectNameParameterValues.java (+41 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.egit.ui.internal.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
 * @since 0.6.0
25
 */
26
public class ProjectNameParameterValues implements IParameterValues {
27
28
	public Map getParameterValues() {
29
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
30
		IProject[] projects = root.getProjects();
31
		Map<String, String> paramValues = new HashMap<String, String>();
32
		for (IProject project : projects) {
33
			final boolean notAlreadyShared = RepositoryProvider
34
					.getProvider(project) == null;
35
			if (project.isAccessible() && notAlreadyShared)
36
				paramValues.put(project.getName(), project.getName());
37
		}
38
		return paramValues;
39
	}
40
41
}
(-)a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/ShareSingleProjectCommand.java (-1 / +51 lines)
Added Link Here
0
- 
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.egit.ui.internal.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.egit.ui.internal.sharing.SharingWizard;
17
import org.eclipse.swt.widgets.Shell;
18
import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;
19
import org.eclipse.ui.IWorkbench;
20
import org.eclipse.ui.handlers.HandlerUtil;
21
22
/**
23
 * Provides a handler for the Share Project command. This can then be bound to
24
 * whatever keybinding the user prefers.
25
 *
26
 * @since 0.6.0
27
 */
28
public class ShareSingleProjectCommand extends AbstractHandler {
29
30
	private static final String PROJECT_NAME_PARAMETER = "org.eclipse.egit.ui.command.projectNameParameter"; //$NON-NLS-1$
31
32
	/**
33
	 * Invokes 'Configure Git Repository' dialog to share given project.
34
	 *
35
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
36
	 */
37
	public Object execute(ExecutionEvent event) throws ExecutionException {
38
		final String projectName = event.getParameter(PROJECT_NAME_PARAMETER);
39
		final IProject projectToShare = ResourcesPlugin.getWorkspace()
40
				.getRoot().getProject(projectName);
41
		IWorkbench workbench = HandlerUtil.getActiveWorkbenchWindow(event)
42
				.getWorkbench();
43
44
		final SharingWizard wizard = new SharingWizard();
45
		wizard.init(workbench, projectToShare);
46
		final Shell shell = HandlerUtil.getActiveShell(event);
47
		ConfigureProjectWizard.openWizard(shell, wizard);
48
		return null;
49
	}
50
51
}

Return to bug 291283