Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java8
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java12
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java17
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java15
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreateBranchOnCommitHandler.java40
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java135
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchWizard.java84
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateBranchCommand.java53
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties5
9 files changed, 220 insertions, 149 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
index 0f56eb382..ef526cce6 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
@@ -263,9 +263,11 @@ public class HistoryViewTest extends LocalRepositoryTestCase {
ContextMenuHelper.clickContextMenu(table, util
.getPluginLocalizedValue("CreateBranch.label"));
SWTBotShell dialog = bot
- .shell(UIText.BranchSelectionDialog_QuestionNewBranchTitle);
- dialog.bot().text().setText("NewBranch");
- dialog.bot().button(IDialogConstants.OK_LABEL).click();
+ .shell(UIText.CreateBranchWizard_NewBranchTitle);
+ dialog.bot().textWithId("BranchName").setText("NewBranch");
+ // for some reason, checkboxwithlabel doesn't seem to work
+ dialog.bot().checkBox().deselect();
+ dialog.bot().button(IDialogConstants.FINISH_LABEL).click();
waitInUI();
assertNotNull(repo.resolve(Constants.R_HEADS + "NewBranch"));
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java
index 0a0edf1fc..5c9d9986a 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java
@@ -97,10 +97,10 @@ public class GitRepositoriesViewBranchHandlingTest extends
.getPluginLocalizedValue("CreateBranchCommand"));
SWTBotShell createPage = bot
- .shell(UIText.RepositoriesView_NewBranchTitle);
+ .shell(UIText.CreateBranchWizard_NewBranchTitle);
createPage.activate();
// getting text with label doesn't work
- createPage.bot().text(1).setText("newLocal");
+ createPage.bot().textWithId("BranchName").setText("newLocal");
createPage.bot().checkBox(UIText.CreateBranchPage_CheckoutButton)
.deselect();
createPage.bot().button(IDialogConstants.FINISH_LABEL).click();
@@ -171,9 +171,9 @@ public class GitRepositoriesViewBranchHandlingTest extends
item.getNode("origin/stable").select();
ContextMenuHelper.clickContextMenu(tree, myUtil
.getPluginLocalizedValue("CreateBranchCommand"));
- SWTBotShell shell = bot.shell(UIText.RepositoriesView_NewBranchTitle);
+ SWTBotShell shell = bot.shell(UIText.CreateBranchWizard_NewBranchTitle);
shell.activate();
- assertEquals("stable", shell.bot().text(1).getText());
+ assertEquals("stable", shell.bot().textWithId("BranchName").getText());
shell.bot().button(IDialogConstants.FINISH_LABEL).click();
refreshAndWait();
item = myRepoViewUtil.getLocalBranchesItem(tree, clonedRepositoryFile)
@@ -257,10 +257,10 @@ public class GitRepositoriesViewBranchHandlingTest extends
.getPluginLocalizedValue("CreateBranchCommand"));
SWTBotShell createPage = bot
- .shell(UIText.RepositoriesView_NewBranchTitle);
+ .shell(UIText.CreateBranchWizard_NewBranchTitle);
createPage.activate();
assertEquals("Wrong suggested branch name", "stable", createPage
- .bot().text(1).getText());
+ .bot().textWithId("BranchName").getText());
createPage.close();
} finally {
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
index 2791ecb47..9974f58bd 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
@@ -149,7 +149,8 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
public void testExpandWorkDir() throws Exception {
SWTBotTree tree = getOrOpenView().bot().tree();
Repository myRepository = lookupRepository(repositoryFile);
- List<String> children = Arrays.asList(myRepository.getWorkTree().list());
+ List<String> children = Arrays
+ .asList(myRepository.getWorkTree().list());
List<String> treeChildren = myRepoViewUtil.getWorkdirItem(tree,
repositoryFile).expand().getNodes();
assertTrue(children.containsAll(treeChildren)
@@ -584,8 +585,9 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
SWTBotTreeItem masterNode = localBranchesItem.getNode("master");
masterNode.select();
ContextMenuHelper.clickContextMenu(tree, "Create Branch...");
- SWTBotShell createBranchShell = bot.shell("Create Branch");
- createBranchShell.bot().text("").setText("abc");
+ SWTBotShell createBranchShell = bot
+ .shell(UIText.CreateBranchWizard_NewBranchTitle);
+ createBranchShell.bot().textWithId("BranchName").setText("abc");
createBranchShell.bot().checkBox().deselect();
createBranchShell.bot().button(IDialogConstants.FINISH_LABEL).click();
refreshAndWait();
@@ -616,14 +618,15 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
// create first branch (abc)
masterNode.select();
ContextMenuHelper.clickContextMenu(tree, "Create Branch...");
- SWTBotShell createBranchShell = bot.shell("Create Branch");
- createBranchShell.bot().text("").setText("abc");
+ SWTBotShell createBranchShell = bot
+ .shell(UIText.CreateBranchWizard_NewBranchTitle);
+ createBranchShell.bot().textWithId("BranchName").setText("abc");
createBranchShell.bot().checkBox().deselect();
createBranchShell.bot().button(IDialogConstants.FINISH_LABEL).click();
// create second branch (123)
ContextMenuHelper.clickContextMenu(tree, "Create Branch...");
- createBranchShell = bot.shell("Create Branch");
- createBranchShell.bot().text("").setText("123");
+ createBranchShell = bot.shell(UIText.CreateBranchWizard_NewBranchTitle);
+ createBranchShell.bot().textWithId("BranchName").setText("123");
createBranchShell.bot().checkBox().deselect();
createBranchShell.bot().button(IDialogConstants.FINISH_LABEL).click();
refreshAndWait();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index b776cbafb..19b4810ef 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -1243,9 +1243,6 @@ public class UIText extends NLS {
public static String ConfirmationPage_title;
/** */
- public static String CreateBranchHandler_CreatePromptMessage;
-
- /** */
public static String CreateBranchPage_BranchAlreadyExistsMessage;
/** */
@@ -1279,9 +1276,21 @@ public class UIText extends NLS {
public static String CreateBranchPage_SourceBranchTooltip;
/** */
+ public static String CreateBranchPage_SourceCommitLabel;
+
+ /** */
+ public static String CreateBranchPage_SourceCommitTooltip;
+
+ /** */
public static String CreateBranchPage_Title;
/** */
+ public static String CreateBranchWizard_CreationFailed;
+
+ /** */
+ public static String CreateBranchWizard_NewBranchTitle;
+
+ /** */
public static String PushResultTable_columnStatusRepo;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreateBranchOnCommitHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreateBranchOnCommitHandler.java
index f888d7d0f..e6768a853 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreateBranchOnCommitHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreateBranchOnCommitHandler.java
@@ -8,23 +8,15 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.history.command;
-import java.io.IOException;
-
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.egit.ui.UIText;
-import org.eclipse.egit.ui.internal.ValidationUtils;
import org.eclipse.egit.ui.internal.history.GitHistoryPage;
-import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.egit.ui.internal.repository.CreateBranchWizard;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.ObjectId;
-import org.eclipse.jgit.lib.RefUpdate;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revplot.PlotCommit;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.handlers.HandlerUtil;
/**
@@ -32,31 +24,11 @@ import org.eclipse.ui.handlers.HandlerUtil;
*/
public class CreateBranchOnCommitHandler extends AbstractHistoryCommanndHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
- try {
- PlotCommit commit = (PlotCommit) getSelection(event)
- .getFirstElement();
- ObjectId startAt = commit.getId();
- Repository repo = getRepository(event);
- String prompt = NLS.bind(
- UIText.CreateBranchHandler_CreatePromptMessage, startAt
- .name(), Constants.R_HEADS);
+ PlotCommit commit = (PlotCommit) getSelection(event).getFirstElement();
+ Repository repo = getRepository(event);
- InputDialog dlg = new InputDialog(HandlerUtil
- .getActiveShellChecked(event),
- UIText.BranchSelectionDialog_QuestionNewBranchTitle,
- prompt, "", ValidationUtils //$NON-NLS-1$
- .getRefNameInputValidator(repo, Constants.R_HEADS));
- if (dlg.open() != Window.OK)
- return null;
- RefUpdate updateRef = repo.updateRef(Constants.R_HEADS
- + dlg.getValue());
- updateRef.setNewObjectId(startAt);
- updateRef.setRefLogMessage(
- "branch: Created from " + startAt.name(), false); //$NON-NLS-1$
- updateRef.update();
- } catch (IOException e) {
- throw new ExecutionException(e.getMessage(), e);
- }
+ new WizardDialog(HandlerUtil.getActiveShellChecked(event),
+ new CreateBranchWizard(repo, commit)).open();
return null;
}
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 4df5bcdd6..4ea2a302d 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
@@ -25,6 +25,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -40,15 +41,20 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
- * Allows to create a new local branch based on another branch. The source
- * branch can be selected using a drop down.
+ * Allows to create a new local branch based on another branch or commit.
+ * <p>
+ * If the base is a branch, the source branch can be selected using a drop down.
*/
-public class CreateBranchPage extends WizardPage {
+class CreateBranchPage extends WizardPage {
+
+ private final boolean commitMode;
private final Repository myRepository;
private final Ref myBaseBranch;
+ private final RevCommit myBaseCommit;
+
private Text nameText;
private Button checkout;
@@ -67,9 +73,32 @@ public class CreateBranchPage extends WizardPage {
*/
public CreateBranchPage(Repository repo, Ref baseBranch) {
super(CreateBranchPage.class.getName());
+ commitMode = false;
this.myRepository = repo;
this.myBaseBranch = baseBranch;
+ this.myBaseCommit = null;
setTitle(UIText.CreateBranchPage_Title);
+ setMessage(UIText.CreateBranchPage_ChooseBranchAndNameMessage);
+ }
+
+ /**
+ * Constructs this page.
+ * <p>
+ * If a base branch is provided, the drop down will be selected accordingly
+ *
+ * @param repo
+ * the repository
+ * @param baseCommit
+ * the commit to base the new branch on, must not be null
+ */
+ public CreateBranchPage(Repository repo, RevCommit baseCommit) {
+ super(CreateBranchPage.class.getName());
+ commitMode = true;
+ this.myRepository = repo;
+ this.myBaseBranch = null;
+ this.myBaseCommit = baseCommit;
+ setTitle(UIText.CreateBranchPage_Title);
+ setMessage(UIText.CreateBranchPage_ChooseNameMessage);
}
public void createControl(Composite parent) {
@@ -77,43 +106,60 @@ public class CreateBranchPage extends WizardPage {
main.setLayout(new GridLayout(3, false));
Label sourceLabel = new Label(main, SWT.NONE);
- sourceLabel.setText(UIText.CreateBranchPage_SourceBranchLabel);
- sourceLabel.setToolTipText(UIText.CreateBranchPage_SourceBranchTooltip);
- this.branchCombo = new Combo(main, SWT.READ_ONLY | SWT.DROP_DOWN);
+ if (commitMode) {
+ sourceLabel.setText(UIText.CreateBranchPage_SourceCommitLabel);
+ sourceLabel
+ .setToolTipText(UIText.CreateBranchPage_SourceCommitTooltip);
+
+ } else {
+ sourceLabel.setText(UIText.CreateBranchPage_SourceBranchLabel);
+ sourceLabel
+ .setToolTipText(UIText.CreateBranchPage_SourceBranchTooltip);
+ }
+ if (commitMode)
+ this.branchCombo = new Combo(main, SWT.READ_ONLY | SWT.SINGLE);
+ else
+ this.branchCombo = new Combo(main, SWT.READ_ONLY | SWT.DROP_DOWN);
GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(
this.branchCombo);
- try {
- for (Entry<String, Ref> ref : myRepository.getRefDatabase()
- .getRefs(Constants.R_HEADS).entrySet()) {
- if (!ref.getValue().isSymbolic())
- this.branchCombo.add(ref.getValue().getName());
- }
- for (Entry<String, Ref> ref : myRepository.getRefDatabase()
- .getRefs(Constants.R_REMOTES).entrySet()) {
- if (!ref.getValue().isSymbolic())
- this.branchCombo.add(ref.getValue().getName());
- }
- for (Entry<String, Ref> ref : myRepository.getRefDatabase()
- .getRefs(Constants.R_TAGS).entrySet()) {
- if (!ref.getValue().isSymbolic())
- this.branchCombo.add(ref.getValue().getName());
+ if (commitMode) {
+ this.branchCombo.add(myBaseCommit.name());
+ this.branchCombo.setText(myBaseCommit.name());
+ this.branchCombo.setEnabled(false);
+ } else {
+ try {
+ for (Entry<String, Ref> ref : myRepository.getRefDatabase()
+ .getRefs(Constants.R_HEADS).entrySet()) {
+ if (!ref.getValue().isSymbolic())
+ this.branchCombo.add(ref.getValue().getName());
+ }
+ for (Entry<String, Ref> ref : myRepository.getRefDatabase()
+ .getRefs(Constants.R_REMOTES).entrySet()) {
+ if (!ref.getValue().isSymbolic())
+ this.branchCombo.add(ref.getValue().getName());
+ }
+ for (Entry<String, Ref> ref : myRepository.getRefDatabase()
+ .getRefs(Constants.R_TAGS).entrySet()) {
+ if (!ref.getValue().isSymbolic())
+ this.branchCombo.add(ref.getValue().getName());
+ }
+
+ } catch (IOException e1) {
+ // ignore here
}
- } catch (IOException e1) {
- // ignore here
- }
-
- this.branchCombo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- checkPage();
+ this.branchCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ checkPage();
+ }
+ });
+ // select the current branch in the drop down
+ if (myBaseBranch != null) {
+ this.branchCombo.setText(myBaseBranch.getName());
}
- });
- // select the current branch in the drop down
- if (myBaseBranch != null) {
- this.branchCombo.setText(myBaseBranch.getName());
}
Label nameLabel = new Label(main, SWT.NONE);
@@ -125,6 +171,8 @@ public class CreateBranchPage extends WizardPage {
prefix.setEnabled(false);
nameText = new Text(main, SWT.BORDER);
+ // enable testing with SWTBot
+ nameText.setData("org.eclipse.swtbot.widget.key", "BranchName"); //$NON-NLS-1$ //$NON-NLS-2$
GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText);
nameText.addModifyListener(new ModifyListener() {
@@ -133,8 +181,7 @@ public class CreateBranchPage extends WizardPage {
}
});
- boolean isBare = myRepository.getConfig().getBoolean(
- "core", "bare", false); //$NON-NLS-1$ //$NON-NLS-2$
+ boolean isBare = myRepository.isBare();
checkout = new Button(main, SWT.CHECK);
checkout.setText(UIText.CreateBranchPage_CheckoutButton);
// most of the time, we probably will check this out
@@ -146,12 +193,10 @@ public class CreateBranchPage extends WizardPage {
GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(
checkout);
checkout.addSelectionListener(new SelectionAdapter() {
-
@Override
public void widgetSelected(SelectionEvent e) {
checkPage();
}
-
});
Dialog.applyDialogFont(main);
@@ -169,11 +214,6 @@ public class CreateBranchPage extends WizardPage {
// in any case, we will have to enter the name
setPageComplete(false);
}
-
- if (this.myBaseBranch != null && this.nameText.getText().length() == 0)
- setMessage(UIText.CreateBranchPage_ChooseNameMessage);
- else
- setMessage(UIText.CreateBranchPage_ChooseBranchAndNameMessage);
}
private void checkPage() {
@@ -210,6 +250,8 @@ public class CreateBranchPage extends WizardPage {
}
private String getSourceBranchName() {
+ if (commitMode)
+ return myBaseCommit.name();
if (myBaseBranch != null)
return myBaseBranch.getName();
else if (this.branchCombo != null)
@@ -225,15 +267,18 @@ public class CreateBranchPage extends WizardPage {
*/
public void createBranch(IProgressMonitor monitor) throws CoreException,
IOException {
-
monitor.beginTask(UIText.CreateBranchPage_CreatingBranchMessage,
IProgressMonitor.UNKNOWN);
String newRefName = getBranchName();
RefUpdate updateRef = myRepository.updateRef(newRefName);
- ObjectId startAt = new RevWalk(myRepository).parseCommit(myRepository
- .resolve(getSourceBranchName()));
+ ObjectId startAt;
+ if (commitMode)
+ startAt = myBaseCommit.getId();
+ else
+ startAt = new RevWalk(myRepository).parseCommit(myRepository
+ .resolve(getSourceBranchName()));
updateRef.setNewObjectId(startAt);
updateRef.setRefLogMessage(
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchWizard.java
new file mode 100644
index 000000000..afbb1c864
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchWizard.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2010 SAP AG.
+ * 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
+ *
+ * Contributors:
+ * Mathias Kinzler (SAP AG) - initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.repository;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIText;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+/**
+ * Creates a branch based on another branch or on a commit.
+ */
+public class CreateBranchWizard extends Wizard {
+ /**
+ * @param repository
+ * the repository
+ * @param baseBranch
+ * the base branch, may be null
+ */
+ public CreateBranchWizard(Repository repository, Ref baseBranch) {
+ myPage = new CreateBranchPage(repository, baseBranch);
+ setWindowTitle(UIText.CreateBranchWizard_NewBranchTitle);
+ }
+
+ /**
+ * @param repository
+ * the repository
+ * @param baseCommit
+ * the base commit, must not be null
+ */
+ public CreateBranchWizard(Repository repository, RevCommit baseCommit) {
+ myPage = new CreateBranchPage(repository, baseCommit);
+ setWindowTitle(UIText.CreateBranchWizard_NewBranchTitle);
+ }
+
+ private CreateBranchPage myPage;
+
+ @Override
+ public void addPages() {
+ addPage(myPage);
+ }
+
+ @Override
+ public boolean performFinish() {
+ try {
+ getContainer().run(false, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ CreateBranchPage cp = (CreateBranchPage) getPages()[0];
+ try {
+ cp.createBranch(monitor);
+ } catch (CoreException ce) {
+ throw new InvocationTargetException(ce);
+ } catch (IOException ioe) {
+ throw new InvocationTargetException(ioe);
+ }
+ }
+ });
+ } catch (InvocationTargetException ite) {
+ Activator.handleError(UIText.CreateBranchWizard_CreationFailed, ite
+ .getCause(), true);
+ return false;
+ } catch (InterruptedException ie) {
+ // ignore here
+ }
+ return true;
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateBranchCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateBranchCommand.java
index 6bb610865..c04848b82 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateBranchCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateBranchCommand.java
@@ -11,18 +11,12 @@
package org.eclipse.egit.ui.internal.repository.tree.command;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.UIText;
-import org.eclipse.egit.ui.internal.repository.CreateBranchPage;
+import org.eclipse.egit.ui.internal.repository.CreateBranchWizard;
import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
@@ -74,49 +68,8 @@ public class CreateBranchCommand extends
}
baseBranch = branch;
}
-
- Wizard wiz = new Wizard() {
-
- @Override
- public void addPages() {
- addPage(new CreateBranchPage(node.getRepository(), baseBranch));
- setWindowTitle(UIText.RepositoriesView_NewBranchTitle);
- }
-
- @Override
- public boolean performFinish() {
- try {
- getContainer().run(false, true,
- new IRunnableWithProgress() {
-
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
- CreateBranchPage cp = (CreateBranchPage) getPages()[0];
- try {
- cp.createBranch(monitor);
- } catch (CoreException ce) {
- throw new InvocationTargetException(ce);
- } catch (IOException ioe) {
- throw new InvocationTargetException(ioe);
- }
-
- }
- });
- } catch (InvocationTargetException ite) {
- Activator
- .handleError(
- UIText.RepositoriesView_BranchCreationFailureMessage,
- ite.getCause(), true);
- return false;
- } catch (InterruptedException ie) {
- // ignore here
- }
- return true;
- }
- };
- new WizardDialog(getShell(event), wiz).open();
-
+ new WizardDialog(getShell(event), new CreateBranchWizard(node
+ .getRepository(), baseBranch)).open();
return null;
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index 51f6b97d8..6cb5ad6fe 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -442,7 +442,6 @@ ConfirmationPage_errorUnexpected=Unexpected error occurred: {0}
ConfirmationPage_requireUnchangedButton=Push only if remote refs don't change in the mean time
ConfirmationPage_showOnlyIfChanged=Show final report dialog only when it differs from this confirmation report
ConfirmationPage_title=Push Confirmation
-CreateBranchHandler_CreatePromptMessage=Please enter a name for the new branch. The new branch will be based on commit {0} and the name will be prepended with {1}
CreateBranchPage_BranchAlreadyExistsMessage=Branch {0} already exists
CreateBranchPage_BranchNameLabel=Branch name
CreateBranchPage_CheckingOutMessage=Checking out new branch...
@@ -454,7 +453,11 @@ CreateBranchPage_MissingNameMessage=Please enter a name for the new branch
CreateBranchPage_MissingSourceMessage=Please select a source branch
CreateBranchPage_SourceBranchLabel=Source branch
CreateBranchPage_SourceBranchTooltip=The new branch will be created from this branch
+CreateBranchPage_SourceCommitLabel=Source commit
+CreateBranchPage_SourceCommitTooltip=The branch will be created from this commit
CreateBranchPage_Title=Create a new branch
+CreateBranchWizard_CreationFailed=Branch could not be created
+CreateBranchWizard_NewBranchTitle=New Branch
PushResultTable_columnStatusRepo=Status: Repo #{0}
PushResultTable_columnDst=Destination Ref
PushResultTable_columnSrc=Source Ref

Back to the top