summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMykola Nikishov2009-10-03 19:02:45 (EDT)
committer Mykola Nikishov2009-10-16 03:30:00 (EDT)
commit3c3dcd9eb7e00f6c36897c0e77a8ab699b5240f3 (patch)
treeeca236fd39d7a998cd1d8430f9ad47732c195809
parent07081c040d92b9129b718bd7ccd97baa71c460cb (diff)
downloadegit-3c3dcd9eb7e00f6c36897c0e77a8ab699b5240f3.zip
egit-3c3dcd9eb7e00f6c36897c0e77a8ab699b5240f3.tar.gz
egit-3c3dcd9eb7e00f6c36897c0e77a8ab699b5240f3.tar.bz2
Share a single project using Quick Accessrefs/changes/60/60/3
Implements sharing a single project using Quick Access with a keyboard from the almost any place of the workspace: - activate Quick Access (which is bound to Ctrl+3 by default) - typing SWG (which means 'share with Git') will provide user with a list of all currently open projects not connected to any team provider - 'Configure Git Repository' dialog with a selected project would be presented to user Bug: https://bugs.eclipse.org/291283 Signed-off-by: Mykola Nikishov <mn@mn.com.ua> Change-Id: I13a286001c27739b1b6aebfe564c115de4ab368e
-rw-r--r--org.eclipse.egit.ui/plugin.properties3
-rw-r--r--org.eclipse.egit.ui/plugin.xml15
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/ProjectNameParameterValues.java41
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/ShareSingleProjectCommand.java51
4 files changed, 110 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui/plugin.properties b/org.eclipse.egit.ui/plugin.properties
index 989dbb9..2fdbb24 100644
--- a/org.eclipse.egit.ui/plugin.properties
+++ b/org.eclipse.egit.ui/plugin.properties
@@ -77,3 +77,6 @@ GitPreferences_name=Git
GitPreferences_HistoryPreferencePage_name=History
GitPreferences_WindowCachePreferencePage_name=Window Cache
GitPreferences_DecoratorPreferencePage_name=Label Decorations
+
+ShareProjectCommand_name=Share with Git
+ShareProjectCommand_desc=Share the project using Git
diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml
index ae9f083..f3099cd 100644
--- a/org.eclipse.egit.ui/plugin.xml
+++ b/org.eclipse.egit.ui/plugin.xml
@@ -385,4 +385,19 @@
</action>
</actionSet>
</extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.egit.ui.internal.commands.ShareSingleProjectCommand"
+ description="%ShareProjectCommand_desc"
+ id="org.eclipse.egit.ui.command.shareProject"
+ name="%ShareProjectCommand_name">
+ <commandParameter
+ id="org.eclipse.egit.ui.command.projectNameParameter"
+ name="Project"
+ optional="false"
+ values="org.eclipse.egit.ui.internal.commands.ProjectNameParameterValues">
+ </commandParameter>
+ </command>
+ </extension>
</plugin>
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/ProjectNameParameterValues.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/ProjectNameParameterValues.java
new file mode 100644
index 0000000..ae0e6b9
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/ProjectNameParameterValues.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (C) 2009, Mykola Nikishov <mn@mn.com.ua>
+ *
+ * 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.egit.ui.internal.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.
+ *
+ * @since 0.6.0
+ */
+public class ProjectNameParameterValues implements IParameterValues {
+
+ public Map getParameterValues() {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject[] projects = root.getProjects();
+ Map<String, String> paramValues = new HashMap<String, String>();
+ for (IProject project : projects) {
+ final boolean notAlreadyShared = RepositoryProvider
+ .getProvider(project) == null;
+ if (project.isAccessible() && notAlreadyShared)
+ paramValues.put(project.getName(), project.getName());
+ }
+ return paramValues;
+ }
+
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/ShareSingleProjectCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/ShareSingleProjectCommand.java
new file mode 100644
index 0000000..5dbdf85
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/ShareSingleProjectCommand.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (C) 2009, Mykola Nikishov <mn@mn.com.ua>
+ *
+ * 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.egit.ui.internal.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.egit.ui.internal.sharing.SharingWizard;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;
+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.
+ *
+ * @since 0.6.0
+ */
+public class ShareSingleProjectCommand extends AbstractHandler {
+
+ private static final String PROJECT_NAME_PARAMETER = "org.eclipse.egit.ui.command.projectNameParameter"; //$NON-NLS-1$
+
+ /**
+ * Invokes 'Configure Git Repository' dialog to share given project.
+ *
+ * @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 SharingWizard wizard = new SharingWizard();
+ wizard.init(workbench, projectToShare);
+ final Shell shell = HandlerUtil.getActiveShell(event);
+ ConfigureProjectWizard.openWizard(shell, wizard);
+ return null;
+ }
+
+}