Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Zanker2013-12-28 13:33:01 +0000
committerMatthias Sohn2014-04-02 13:01:43 +0000
commita466e17eee26dd5c1e107ca68639eee836f26a30 (patch)
tree8343d7e51da3e07ba39cbd0b9b5745061556e1c2 /org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal
parent8bf175abbb5f5a7b8faf62b1958b3894dc6f67e7 (diff)
downloadegit-a466e17eee26dd5c1e107ca68639eee836f26a30.tar.gz
egit-a466e17eee26dd5c1e107ca68639eee836f26a30.tar.xz
egit-a466e17eee26dd5c1e107ca68639eee836f26a30.zip
Provide extensibility for suggesting branch names
* Add new extension point for branch name suggestions * Add new extension to provide branch name suggestion from Mylyn task This change is needed to enable the automatic creation and checkout of branches based on the active task. Bug: 309578 Change-Id: I9e26d668617481026c81a05b6ea08b97e28f620b AlsoBy: Steffen Pingel <steffen.pingel@tasktop.com> AlsoBy: Manuel Doninger <manuel.doninger@googlemail.com> Signed-off-by: Steffen Pingel <steffen.pingel@tasktop.com> Signed-off-by: Gerd Zanker <gerd.zanker@web.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java48
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties1
3 files changed, 50 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
index a7a0335827..7736c4ec3c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
@@ -2482,6 +2482,9 @@ public class UIText extends NLS {
public static String CreateBranchPage_ChooseNameMessage;
/** */
+ public static String CreateBranchPage_CreateBranchNameProviderFailed;
+
+ /** */
public static String CreateBranchPage_CreatingBranchMessage;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java
index d330d81f5b..c7f86915fd 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 SAP AG.
+ * Copyright (c) 2010, 2014 SAP AG and others.
* 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
@@ -13,11 +13,18 @@
package org.eclipse.egit.ui.internal.repository;
import java.io.IOException;
+import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.op.CreateLocalBranchOperation;
import org.eclipse.egit.core.op.CreateLocalBranchOperation.UpstreamConfig;
+import org.eclipse.egit.ui.IBranchNameProvider;
import org.eclipse.egit.ui.UIUtils;
import org.eclipse.egit.ui.internal.UIIcons;
import org.eclipse.egit.ui.internal.UIText;
@@ -32,6 +39,7 @@ import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jgit.lib.Constants;
@@ -64,6 +72,8 @@ import org.eclipse.swt.widgets.Text;
*/
class CreateBranchPage extends WizardPage {
+ private static final String BRANCH_NAME_PROVIDER_ID = "org.eclipse.egit.ui.branchNameProvider"; //$NON-NLS-1$
+
/**
* Get proposed target branch name for given source branch name
*
@@ -401,7 +411,10 @@ class CreateBranchPage extends WizardPage {
private void suggestBranchName(String ref) {
if (nameText.getText().length() == 0 || nameIsSuggestion) {
- String branchNameSuggestion = getProposedTargetName(ref);
+ String branchNameSuggestion = getBranchNameSuggestionFromProvider();
+ if (branchNameSuggestion == null)
+ branchNameSuggestion = getProposedTargetName(ref);
+
if (branchNameSuggestion != null) {
nameText.setText(branchNameSuggestion);
nameText.selectAll();
@@ -410,6 +423,37 @@ class CreateBranchPage extends WizardPage {
}
}
+ private IBranchNameProvider getBranchNameProvider() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] config = registry
+ .getConfigurationElementsFor(BRANCH_NAME_PROVIDER_ID);
+ if (config.length > 0) {
+ Object provider;
+ try {
+ provider = config[0].createExecutableExtension("class"); //$NON-NLS-1$
+ if (provider instanceof IBranchNameProvider)
+ return (IBranchNameProvider) provider;
+ } catch (Throwable e) {
+ Activator.logError(
+ UIText.CreateBranchPage_CreateBranchNameProviderFailed,
+ e);
+ }
+ }
+ return null;
+ }
+
+ private String getBranchNameSuggestionFromProvider() {
+ final AtomicReference<String> ref = new AtomicReference<String>();
+ final IBranchNameProvider branchNameProvider = getBranchNameProvider();
+ if (branchNameProvider != null)
+ SafeRunner.run(new SafeRunnable() {
+ public void run() throws Exception {
+ ref.set(branchNameProvider.getBranchNameSuggestion());
+ }
+ });
+ return ref.get();
+ }
+
private static class SourceSelectionDialog extends
AbstractBranchSelectionDialog {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index fcb0c421e4..3f57b516ed 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -821,6 +821,7 @@ CreateBranchPage_CheckingOutMessage=Checking out new branch...
CreateBranchPage_CheckoutButton=&Checkout new branch
CreateBranchPage_ChooseBranchAndNameMessage=Please choose a source branch and a name for the new branch
CreateBranchPage_ChooseNameMessage=Please choose a name for the new branch
+CreateBranchPage_CreateBranchNameProviderFailed=Failed to create branch name provider
CreateBranchPage_CreatingBranchMessage=Creating branch...
CreateBranchPage_LocalBranchWarningMessage=Local branch as upstream is not recommended, use remote branch
CreateBranchPage_MissingSourceMessage=Please select a source branch

Back to the top