diff options
author | Matthias Sohn | 2013-05-03 14:23:20 +0000 |
---|---|---|
committer | Robin Stocker | 2013-05-03 15:00:32 +0000 |
commit | 91861e58ca2cfddf11253a17dc574233b967cdaa (patch) | |
tree | 2afbde2f54082ec1e4723dd0d7bd2b8c7edc5f71 | |
parent | dadf0386a08feff68b62bf1a1b506611ec7fce6b (diff) | |
download | egit-91861e58ca2cfddf11253a17dc574233b967cdaa.tar.gz egit-91861e58ca2cfddf11253a17dc574233b967cdaa.tar.xz egit-91861e58ca2cfddf11253a17dc574233b967cdaa.zip |
Fix line endings
Change-Id: Id7f665b3f4cd7aa48c31593f8b7ce74ee417d5c3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Robin Stocker <robin@nibor.org>
10 files changed, 944 insertions, 945 deletions
diff --git a/org.eclipse.egit.doc/cheatsheets/clone.xml b/org.eclipse.egit.doc/cheatsheets/clone.xml index 6129329aee..cddd2be683 100644 --- a/org.eclipse.egit.doc/cheatsheets/clone.xml +++ b/org.eclipse.egit.doc/cheatsheets/clone.xml @@ -1,51 +1,51 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2010, Philipp Thun <philipp.thun@sap.com>
-
- 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
--->
-<cheatsheet title="Cloning a Git Repository">
- <intro>
- <description>
- With the Git Clone Wizard you can clone repositories using different transport protocols.
- </description>
- </intro>
- <item title="Start Clone Wizard" dialog="true">
- <description>
- The clone wizard can be started by clicking "Click to perform" below.<br /><br />
- Alternatively you can launch this wizard from the "Import Projects from Git" wizard using "Import... > Git > Projects from Git > Next > Clone..." or from the "Git Repositories View" using the "Clone a Git Repository" toolbar button.<br /><br />
- <b>To start this cheat sheet from a separately opened wizard, click the help icon and then select "Cloning a Git Repository".</b>
- </description>
- <command required="false" serialization="org.eclipse.egit.ui.RepositoriesViewClone" />
- </item>
- <item
- href="/org.eclipse.egit.doc/help/EGit/User_Guide/Tasks.html#Repository_Selection"
- title="Repository Selection" dialog="true">
- <description>
- <b>Enter the repository location.</b><br /><br />
- If you already have a <b>repository URI</b> in your clipboard, i.e. copied from a gitweb, github, wiki or any other page, it will be automatically entered into the URI field. The other fields (i.e. Host, Repository path, Protocol, Port) will then be automatically filled.<br /><br />
- In case cloning requires <b>authentication</b> (which is not the case for many repositories), enter your credentials into the User and Password fields.<br /><br />
- For a complete description of all fields as well as the supported protocols, see the referenced <b>documentation</b> (click on help icon on top of this section).<br /><br />
- <b>Click Next</b>
- </description>
- </item>
- <item title="Branch Selection" dialog="true">
- <description>
- <b>Choose branches to be cloned from the repository.</b><br /><br />
- By default all available branches are checked.<br /><br />
- <b>Click Next</b>
- </description>
- </item>
- <item title="Local Destination" dialog="true">
- <description>
- <b>Define local storage settings.</b><br /><br />
- Specify the <b>destination directory</b> of the cloned repository. If this directory does not yet exist, it will be created by the wizard.<br /><br />
- Optionally, you can change the <b>initial branch</b> that will be created and checked out locally. The default <b>remote name</b> is 'origin'. This can also be changed if necessary.<br /><br />
- <b>Click Finish to end the wizard.</b>
- </description>
- <onCompletion>You have now successfully cloned a Git repository.</onCompletion>
- </item>
-</cheatsheet>
+<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2010, Philipp Thun <philipp.thun@sap.com> + + 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 +--> +<cheatsheet title="Cloning a Git Repository"> + <intro> + <description> + With the Git Clone Wizard you can clone repositories using different transport protocols. + </description> + </intro> + <item title="Start Clone Wizard" dialog="true"> + <description> + The clone wizard can be started by clicking "Click to perform" below.<br /><br /> + Alternatively you can launch this wizard from the "Import Projects from Git" wizard using "Import... > Git > Projects from Git > Next > Clone..." or from the "Git Repositories View" using the "Clone a Git Repository" toolbar button.<br /><br /> + <b>To start this cheat sheet from a separately opened wizard, click the help icon and then select "Cloning a Git Repository".</b> + </description> + <command required="false" serialization="org.eclipse.egit.ui.RepositoriesViewClone" /> + </item> + <item + href="/org.eclipse.egit.doc/help/EGit/User_Guide/Tasks.html#Repository_Selection" + title="Repository Selection" dialog="true"> + <description> + <b>Enter the repository location.</b><br /><br /> + If you already have a <b>repository URI</b> in your clipboard, i.e. copied from a gitweb, github, wiki or any other page, it will be automatically entered into the URI field. The other fields (i.e. Host, Repository path, Protocol, Port) will then be automatically filled.<br /><br /> + In case cloning requires <b>authentication</b> (which is not the case for many repositories), enter your credentials into the User and Password fields.<br /><br /> + For a complete description of all fields as well as the supported protocols, see the referenced <b>documentation</b> (click on help icon on top of this section).<br /><br /> + <b>Click Next</b> + </description> + </item> + <item title="Branch Selection" dialog="true"> + <description> + <b>Choose branches to be cloned from the repository.</b><br /><br /> + By default all available branches are checked.<br /><br /> + <b>Click Next</b> + </description> + </item> + <item title="Local Destination" dialog="true"> + <description> + <b>Define local storage settings.</b><br /><br /> + Specify the <b>destination directory</b> of the cloned repository. If this directory does not yet exist, it will be created by the wizard.<br /><br /> + Optionally, you can change the <b>initial branch</b> that will be created and checked out locally. The default <b>remote name</b> is 'origin'. This can also be changed if necessary.<br /><br /> + <b>Click Finish to end the wizard.</b> + </description> + <onCompletion>You have now successfully cloned a Git repository.</onCompletion> + </item> +</cheatsheet> diff --git a/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/MylynCommitMessageProvider.java b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/MylynCommitMessageProvider.java index 939cb5a142..66c398ef6d 100644 --- a/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/MylynCommitMessageProvider.java +++ b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/MylynCommitMessageProvider.java @@ -1,60 +1,60 @@ -/*******************************************************************************
- * Copyright (c) 2011 Chris Aniszczyk 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Chris Aniszczyk <caniszczyk@gmail.com> - initial API and implementation
- * Manuel Doninger <manuel@doninger.net>
- * Benjamin Muskalla <benjamin.muskalla@tasktop.com>
- * Thorsten Kamann <thorsten@kamann.info>
- *******************************************************************************/
-package org.eclipse.egit.internal.mylyn.ui.commit;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.egit.ui.ICommitMessageProvider;
-import org.eclipse.mylyn.context.core.ContextCore;
-import org.eclipse.mylyn.context.core.IInteractionContext;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.mylyn.team.ui.TeamUiUtil;
-
-
-/**
- * Gets the active task and combines the description and title with
- * the commit message template defined in the preferences
- */
-public class MylynCommitMessageProvider implements ICommitMessageProvider {
-
- /**
- * @return the mylyn commit message template defined in the preferences
- */
- public String getMessage(IResource[] resources) {
- String message = ""; //$NON-NLS-1$
- if (resources == null)
- return message;
- ITask task = getCurrentTask();
- if (task == null)
- return message;
- boolean checkTaskRepository = true;
- message = TeamUiUtil.getComment(checkTaskRepository, task, resources);
- return message;
- }
-
- /**
- * @return the currently activated task or <code>null</code> if no task is
- * activated
- */
- protected ITask getCurrentTask() {
- return TasksUi.getTaskActivityManager().getActiveTask();
- }
-
- /**
- * @return the activecontext or <code>null</code> if no activecontext exists
- */
- protected IInteractionContext getActiveContext() {
- return ContextCore.getContextManager().getActiveContext();
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Chris Aniszczyk 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Chris Aniszczyk <caniszczyk@gmail.com> - initial API and implementation + * Manuel Doninger <manuel@doninger.net> + * Benjamin Muskalla <benjamin.muskalla@tasktop.com> + * Thorsten Kamann <thorsten@kamann.info> + *******************************************************************************/ +package org.eclipse.egit.internal.mylyn.ui.commit; + +import org.eclipse.core.resources.IResource; +import org.eclipse.egit.ui.ICommitMessageProvider; +import org.eclipse.mylyn.context.core.ContextCore; +import org.eclipse.mylyn.context.core.IInteractionContext; +import org.eclipse.mylyn.tasks.core.ITask; +import org.eclipse.mylyn.tasks.ui.TasksUi; +import org.eclipse.mylyn.team.ui.TeamUiUtil; + + +/** + * Gets the active task and combines the description and title with + * the commit message template defined in the preferences + */ +public class MylynCommitMessageProvider implements ICommitMessageProvider { + + /** + * @return the mylyn commit message template defined in the preferences + */ + public String getMessage(IResource[] resources) { + String message = ""; //$NON-NLS-1$ + if (resources == null) + return message; + ITask task = getCurrentTask(); + if (task == null) + return message; + boolean checkTaskRepository = true; + message = TeamUiUtil.getComment(checkTaskRepository, task, resources); + return message; + } + + /** + * @return the currently activated task or <code>null</code> if no task is + * activated + */ + protected ITask getCurrentTask() { + return TasksUi.getTaskActivityManager().getActiveTask(); + } + + /** + * @return the activecontext or <code>null</code> if no activecontext exists + */ + protected IInteractionContext getActiveContext() { + return ContextCore.getContextManager().getActiveContext(); + } +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LoginDialogTester.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LoginDialogTester.java index 3316ae19d5..b85334e4bc 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LoginDialogTester.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LoginDialogTester.java @@ -1,26 +1,26 @@ -/*******************************************************************************
- * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
- *
- * 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.common;
-
-import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-
-public class LoginDialogTester {
-
- private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
-
- public void login(String user, String password) {
- bot.textWithLabel(UIText.LoginDialog_user).setText(user);
- bot.textWithLabel(UIText.LoginDialog_password).setText(password);
- bot.checkBoxWithLabel(UIText.LoginDialog_storeInSecureStore).deselect();
- bot.button(IDialogConstants.OK_LABEL).click();
- }
-
-}
+/******************************************************************************* + * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com> + * + * 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.common; + +import org.eclipse.egit.ui.internal.UIText; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; + +public class LoginDialogTester { + + private final SWTWorkbenchBot bot = new SWTWorkbenchBot(); + + public void login(String user, String password) { + bot.textWithLabel(UIText.LoginDialog_user).setText(user); + bot.textWithLabel(UIText.LoginDialog_password).setText(password); + bot.checkBoxWithLabel(UIText.LoginDialog_storeInSecureStore).deselect(); + bot.button(IDialogConstants.OK_LABEL).click(); + } + +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushResultDialogTester.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushResultDialogTester.java index 49376751dd..610544b497 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushResultDialogTester.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushResultDialogTester.java @@ -1,26 +1,26 @@ -/*******************************************************************************
- * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
- *
- * 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.common;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-
-public class PushResultDialogTester {
-
- private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
-
- public void assertResultMessage(String expectedMessage) {
- bot.styledText(expectedMessage);
- }
-
- public void closeDialog() {
- bot.button(IDialogConstants.OK_LABEL).click();
- }
-
-}
+/******************************************************************************* + * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com> + * + * 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.common; + +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; + +public class PushResultDialogTester { + + private final SWTWorkbenchBot bot = new SWTWorkbenchBot(); + + public void assertResultMessage(String expectedMessage) { + bot.styledText(expectedMessage); + } + + public void closeDialog() { + bot.button(IDialogConstants.OK_LABEL).click(); + } + +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushWizardTester.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushWizardTester.java index eae0d81983..14e6877ec9 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushWizardTester.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushWizardTester.java @@ -1,54 +1,54 @@ -/*******************************************************************************
- * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
- *
- * 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.common;
-
-import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.egit.ui.internal.push.PushWizard;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.waits.Conditions;
-import org.eclipse.ui.PlatformUI;
-
-public class PushWizardTester {
-
- private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
-
- public RepoPropertiesPage openPushWizard(final Repository repository)
- throws Exception {
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- try {
- Shell shell = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell();
- PushWizard pushWizard = new PushWizard(repository);
- WizardDialog dlg = new WizardDialog(shell, pushWizard);
- dlg.setHelpAvailable(false);
- dlg.open();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- });
- bot.waitUntil(Conditions.shellIsActive(UIText.PushWizard_windowTitleDefault),
- 20000);
- return new RepoPropertiesPage();
- }
-
- public void nextPage() {
- bot.button(IDialogConstants.NEXT_LABEL).click();
- }
-
- public void finish() {
- bot.button(IDialogConstants.FINISH_LABEL).click();
- }
-
-}
+/******************************************************************************* + * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com> + * + * 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.common; + +import org.eclipse.egit.ui.internal.UIText; +import org.eclipse.egit.ui.internal.push.PushWizard; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.swt.finder.waits.Conditions; +import org.eclipse.ui.PlatformUI; + +public class PushWizardTester { + + private final SWTWorkbenchBot bot = new SWTWorkbenchBot(); + + public RepoPropertiesPage openPushWizard(final Repository repository) + throws Exception { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + try { + Shell shell = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell(); + PushWizard pushWizard = new PushWizard(repository); + WizardDialog dlg = new WizardDialog(shell, pushWizard); + dlg.setHelpAvailable(false); + dlg.open(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }); + bot.waitUntil(Conditions.shellIsActive(UIText.PushWizard_windowTitleDefault), + 20000); + return new RepoPropertiesPage(); + } + + public void nextPage() { + bot.button(IDialogConstants.NEXT_LABEL).click(); + } + + public void finish() { + bot.button(IDialogConstants.FINISH_LABEL).click(); + } + +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RefSpecPageTester.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RefSpecPageTester.java index 0415f6325b..8b57c30687 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RefSpecPageTester.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RefSpecPageTester.java @@ -1,21 +1,21 @@ -/*******************************************************************************
- * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
- *
- * 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.common;
-
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.waits.Conditions;
-
-public class RefSpecPageTester {
-
- private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
-
- public void waitUntilPageIsReady(int nrOfEcpectedTableEntries) {
- bot.waitUntil(Conditions.tableHasRows(bot.table(), nrOfEcpectedTableEntries), 20000);
- }
-}
+/******************************************************************************* + * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com> + * + * 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.common; + +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.swt.finder.waits.Conditions; + +public class RefSpecPageTester { + + private final SWTWorkbenchBot bot = new SWTWorkbenchBot(); + + public void waitUntilPageIsReady(int nrOfEcpectedTableEntries) { + bot.waitUntil(Conditions.tableHasRows(bot.table(), nrOfEcpectedTableEntries), 20000); + } +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java index 519f618fcd..e7c9a0bb0f 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java @@ -1,117 +1,117 @@ -/*******************************************************************************
- * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
- *
- * 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.httpauth;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.egit.core.Activator;
-import org.eclipse.egit.core.op.CloneOperation;
-import org.eclipse.egit.ui.common.EGitTestCase;
-import org.eclipse.egit.ui.common.LoginDialogTester;
-import org.eclipse.egit.ui.common.PushResultDialogTester;
-import org.eclipse.egit.ui.common.PushWizardTester;
-import org.eclipse.egit.ui.common.RefSpecPageTester;
-import org.eclipse.egit.ui.common.RepoPropertiesPage;
-import org.eclipse.egit.ui.test.TestUtil;
-import org.eclipse.egit.ui.wizards.clone.SampleTestRepository;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.lib.StoredConfig;
-import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
-import org.eclipse.jgit.util.FileUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class PushTest extends EGitTestCase {
-
- private static final int NUMBER_RANDOM_COMMITS = 5;
-
- private SampleTestRepository remoteRepository;
-
- private Repository localRepository;
-
- private File file;
-
- private File localRepoPath;
-
- @Before
- public void setup() throws Exception {
- TestUtil.disableProxy();
- remoteRepository = new SampleTestRepository(NUMBER_RANDOM_COMMITS, true);
- localRepoPath = new File(ResourcesPlugin.getWorkspace().getRoot()
- .getLocation().toFile(), "test" + System.nanoTime());
- String branch = Constants.R_HEADS + SampleTestRepository.FIX;
- CloneOperation cloneOperation = new CloneOperation(new URIish(
- remoteRepository.getUri()), true, null, localRepoPath, branch,
- "origin", 30);
- cloneOperation
- .setCredentialsProvider(new UsernamePasswordCredentialsProvider(
- "agitter", "letmein"));
- cloneOperation.run(null);
- file = new File(localRepoPath, SampleTestRepository.A_txt_name);
- assertTrue(file.exists());
- localRepository = Activator.getDefault().getRepositoryCache()
- .lookupRepository(new File(localRepoPath, ".git"));
- assertNotNull(localRepository);
- }
-
- @Test
- public void testPush() throws Exception {
- // change file
- TestUtil.appendFileContent(file, "additional content", true);
- // commit change
- Git git = new Git(localRepository);
- git.add().addFilepattern(SampleTestRepository.A_txt_name).call();
- git.commit().setMessage("Change").call();
- configurePush();
- // push change
- PushWizardTester wizardTester = new PushWizardTester();
- RepoPropertiesPage repoPropertiesPage = wizardTester.openPushWizard(localRepository);
- repoPropertiesPage.setPushDestination("push");
- wizardTester.nextPage();
- // now login dialog appears
- LoginDialogTester loginDialogTester = new LoginDialogTester();
- loginDialogTester.login("agitter", "letmein");
- RefSpecPageTester refSpecPageTester = new RefSpecPageTester();
- refSpecPageTester.waitUntilPageIsReady(1);
- wizardTester.finish();
- loginDialogTester.login("agitter", "letmein");
- PushResultDialogTester pushResultDialogTester = new PushResultDialogTester();
- String expectedMessage = "Repository " + remoteRepository.getUri();
- pushResultDialogTester.assertResultMessage(expectedMessage);
- pushResultDialogTester.closeDialog();
- }
-
- private void configurePush() throws Exception {
- StoredConfig config = localRepository.getConfig();
- config.setString("remote", "push", "pushurl", remoteRepository.getUri());
- config.setString("remote", "push", "push", "+refs/heads/*:refs/heads/*");
- config.save();
- }
-
- @After
- public void tearDown() throws Exception {
- if (remoteRepository != null)
- remoteRepository.shutDown();
- Activator.getDefault().getRepositoryCache().clear();
- if (localRepository != null)
- localRepository.close();
- if (localRepoPath != null)
- FileUtils.delete(localRepoPath, FileUtils.RECURSIVE
- | FileUtils.RETRY);
- }
-
-}
+/******************************************************************************* + * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com> + * + * 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.httpauth; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.egit.core.Activator; +import org.eclipse.egit.core.op.CloneOperation; +import org.eclipse.egit.ui.common.EGitTestCase; +import org.eclipse.egit.ui.common.LoginDialogTester; +import org.eclipse.egit.ui.common.PushResultDialogTester; +import org.eclipse.egit.ui.common.PushWizardTester; +import org.eclipse.egit.ui.common.RefSpecPageTester; +import org.eclipse.egit.ui.common.RepoPropertiesPage; +import org.eclipse.egit.ui.test.TestUtil; +import org.eclipse.egit.ui.wizards.clone.SampleTestRepository; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.lib.StoredConfig; +import org.eclipse.jgit.transport.URIish; +import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; +import org.eclipse.jgit.util.FileUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class PushTest extends EGitTestCase { + + private static final int NUMBER_RANDOM_COMMITS = 5; + + private SampleTestRepository remoteRepository; + + private Repository localRepository; + + private File file; + + private File localRepoPath; + + @Before + public void setup() throws Exception { + TestUtil.disableProxy(); + remoteRepository = new SampleTestRepository(NUMBER_RANDOM_COMMITS, true); + localRepoPath = new File(ResourcesPlugin.getWorkspace().getRoot() + .getLocation().toFile(), "test" + System.nanoTime()); + String branch = Constants.R_HEADS + SampleTestRepository.FIX; + CloneOperation cloneOperation = new CloneOperation(new URIish( + remoteRepository.getUri()), true, null, localRepoPath, branch, + "origin", 30); + cloneOperation + .setCredentialsProvider(new UsernamePasswordCredentialsProvider( + "agitter", "letmein")); + cloneOperation.run(null); + file = new File(localRepoPath, SampleTestRepository.A_txt_name); + assertTrue(file.exists()); + localRepository = Activator.getDefault().getRepositoryCache() + .lookupRepository(new File(localRepoPath, ".git")); + assertNotNull(localRepository); + } + + @Test + public void testPush() throws Exception { + // change file + TestUtil.appendFileContent(file, "additional content", true); + // commit change + Git git = new Git(localRepository); + git.add().addFilepattern(SampleTestRepository.A_txt_name).call(); + git.commit().setMessage("Change").call(); + configurePush(); + // push change + PushWizardTester wizardTester = new PushWizardTester(); + RepoPropertiesPage repoPropertiesPage = wizardTester.openPushWizard(localRepository); + repoPropertiesPage.setPushDestination("push"); + wizardTester.nextPage(); + // now login dialog appears + LoginDialogTester loginDialogTester = new LoginDialogTester(); + loginDialogTester.login("agitter", "letmein"); + RefSpecPageTester refSpecPageTester = new RefSpecPageTester(); + refSpecPageTester.waitUntilPageIsReady(1); + wizardTester.finish(); + loginDialogTester.login("agitter", "letmein"); + PushResultDialogTester pushResultDialogTester = new PushResultDialogTester(); + String expectedMessage = "Repository " + remoteRepository.getUri(); + pushResultDialogTester.assertResultMessage(expectedMessage); + pushResultDialogTester.closeDialog(); + } + + private void configurePush() throws Exception { + StoredConfig config = localRepository.getConfig(); + config.setString("remote", "push", "pushurl", remoteRepository.getUri()); + config.setString("remote", "push", "push", "+refs/heads/*:refs/heads/*"); + config.save(); + } + + @After + public void tearDown() throws Exception { + if (remoteRepository != null) + remoteRepository.shutDown(); + Activator.getDefault().getRepositoryCache().clear(); + if (localRepository != null) + localRepository.close(); + if (localRepoPath != null) + FileUtils.delete(localRepoPath, FileUtils.RECURSIVE + | FileUtils.RETRY); + } + +} diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/SampleTestRepository.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/SampleTestRepository.java index c5924a4494..47e7b19fab 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/SampleTestRepository.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/SampleTestRepository.java @@ -1,192 +1,191 @@ -/*******************************************************************************
- * Copyright (C) 2010, Matthias Sohn <matthias.sohn@sap.com>
- *
- * 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.wizards.clone;
-
-import static org.junit.Assert.assertFalse;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Random;
-
-import org.eclipse.jgit.junit.TestRepository;
-import org.eclipse.jgit.junit.http.SimpleHttpServer;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.revwalk.RevBlob;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.revwalk.RevTag;
-import org.eclipse.jgit.internal.storage.file.FileRepository;
-import org.eclipse.jgit.transport.Daemon;
-import org.eclipse.jgit.transport.DaemonClient;
-import org.eclipse.jgit.transport.resolver.FileResolver;
-import org.eclipse.jgit.util.FileUtils;
-
-/**
- * Creates an on disk sample repository with some generated content and starts a
- * git daemon on a free port.
- *
- * If the system property <code>test-repo-no-cleanup</code> is defined the
- * source repository data will not be deleted from disk to enable testing the
- * test.
- */
-public class SampleTestRepository {
- /**
- * Name of the test repository
- */
- public static final String REPO_NAME = "test";
-
- /**
- * Name of a branch in the sample repository
- */
- public static final String FIX = "fix";
-
- /**
- * Name of a tag in the sample repository
- */
- public static final String v1_0_name = "v1_0";
-
- /**
- * Name of a tag in the sample repository
- */
- public static final String v2_0_name = "v2_0";
-
- /**
- * Name of a file in the sample repository
- */
- public static final String A_txt_name = "A_txt";
-
- private static final File trash = new File("target/trash");
-
- private final TestRepository<FileRepository> src;
-
- private Daemon d;
-
- private SimpleHttpServer httpServer;
-
- private String uri;
-
- private RevBlob A_txt;
-
- private RevCommit A, B, C;
-
- private RevTag v1_0, v2_0;
-
- private final boolean serveHttp;
-
- public String getUri() {
- return uri;
- }
-
- /**
- * Create a bare repository, generate some sample data and start git daemon
- * on a free port
- *
- * @param n
- * hint how many random commits should be generated
- * @param
- * serveHttp
- *
- * @throws Exception
- */
- public SampleTestRepository(int n, boolean serveHttp) throws Exception {
- this.serveHttp = serveHttp;
- src = createRepository();
- generateSampleData(n);
- if (serveHttp)
- serveHttp();
- else
- serve();
- }
-
- private TestRepository<FileRepository> createRepository() throws Exception {
- String gitdirName = "test" + System.currentTimeMillis()
- + Constants.DOT_GIT;
- File gitdir = new File(trash, gitdirName).getCanonicalFile();
- FileRepository db = new FileRepository(gitdir);
- assertFalse(gitdir.exists());
- db.create();
- return new TestRepository<FileRepository>(db);
- }
-
- private void generateSampleData(int n) throws Exception {
- A_txt = src.blob("A");
- A = src.commit().add(A_txt_name, A_txt).create();
- src.update(Constants.R_HEADS + Constants.MASTER, A);
-
- // create some random commits
- RevCommit X = A;
- for (int i = 0; i < n; i++) {
- X = src.commit().parent(X)
- .add(randomAsciiString(), randomAsciiString()).create();
- }
-
- B = src.commit().parent(X).add(A_txt_name, "C").add("B", "B").create();
- src.update(Constants.R_HEADS + Constants.MASTER, B);
-
- v1_0 = src.tag(v1_0_name, B);
- src.update(Constants.R_TAGS + v1_0_name, v1_0);
-
- C = src.commit().parent(A).add(A_txt_name, "D").add("C", "C").create();
- src.update(Constants.R_HEADS + FIX, C);
-
- v2_0 = src.tag(v2_0_name, C);
- src.update(Constants.R_TAGS + v2_0_name, v2_0);
- }
-
- private String randomAsciiString() {
- StringBuilder randstring = new StringBuilder("");
- Random rand = new Random();
- int strlen = rand.nextInt(20) + 10;
- for (int i = 0, j = 0; i < strlen; i++) {
- if (rand.nextInt(2) == 1)
- j = 97;
- else
- j = 65;
- randstring.append((char) (rand.nextInt(26) + j));
- }
- return randstring.toString();
- }
-
- private void serve() throws IOException {
- d = new Daemon();
- FileResolver<DaemonClient> resolver = new FileResolver<DaemonClient>();
- resolver.exportRepository(REPO_NAME, src.getRepository());
- d.setRepositoryResolver(resolver);
- d.start();
- uri = "git://localhost:" + d.getAddress().getPort() + "/" + REPO_NAME
- + Constants.DOT_GIT_EXT;
- }
-
- private void serveHttp() throws Exception{
- httpServer = new SimpleHttpServer(src.getRepository());
- httpServer.start();
- uri = httpServer.getUri().toString();
- }
-
- /**
- * Stop the git daemon and delete test data from disk. If the system
- * property <code>test-repo-no-cleanup</code> is defined the test data will
- * be left on disk for analysis.
+/******************************************************************************* + * Copyright (C) 2010, Matthias Sohn <matthias.sohn@sap.com> + * + * 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.wizards.clone; + +import static org.junit.Assert.assertFalse; + +import java.io.File; +import java.io.IOException; +import java.util.Random; + +import org.eclipse.jgit.junit.TestRepository; +import org.eclipse.jgit.junit.http.SimpleHttpServer; +import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.revwalk.RevBlob; +import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.jgit.revwalk.RevTag; +import org.eclipse.jgit.internal.storage.file.FileRepository; +import org.eclipse.jgit.transport.Daemon; +import org.eclipse.jgit.transport.DaemonClient; +import org.eclipse.jgit.transport.resolver.FileResolver; +import org.eclipse.jgit.util.FileUtils; + +/** + * Creates an on disk sample repository with some generated content and starts a + * git daemon on a free port. + * + * If the system property <code>test-repo-no-cleanup</code> is defined the + * source repository data will not be deleted from disk to enable testing the + * test. + */ +public class SampleTestRepository { + /** + * Name of the test repository + */ + public static final String REPO_NAME = "test"; + + /** + * Name of a branch in the sample repository + */ + public static final String FIX = "fix"; + + /** + * Name of a tag in the sample repository + */ + public static final String v1_0_name = "v1_0"; + + /** + * Name of a tag in the sample repository + */ + public static final String v2_0_name = "v2_0"; + + /** + * Name of a file in the sample repository + */ + public static final String A_txt_name = "A_txt"; + + private static final File trash = new File("target/trash"); + + private final TestRepository<FileRepository> src; + + private Daemon d; + + private SimpleHttpServer httpServer; + + private String uri; + + private RevBlob A_txt; + + private RevCommit A, B, C; + + private RevTag v1_0, v2_0; + + private final boolean serveHttp; + + public String getUri() { + return uri; + } + + /** + * Create a bare repository, generate some sample data and start git daemon + * on a free port + * + * @param n + * hint how many random commits should be generated + * @param serveHttp + * + * @throws Exception + */ + public SampleTestRepository(int n, boolean serveHttp) throws Exception { + this.serveHttp = serveHttp; + src = createRepository(); + generateSampleData(n); + if (serveHttp) + serveHttp(); + else + serve(); + } + + private TestRepository<FileRepository> createRepository() throws Exception { + String gitdirName = "test" + System.currentTimeMillis() + + Constants.DOT_GIT; + File gitdir = new File(trash, gitdirName).getCanonicalFile(); + FileRepository db = new FileRepository(gitdir); + assertFalse(gitdir.exists()); + db.create(); + return new TestRepository<FileRepository>(db); + } + + private void generateSampleData(int n) throws Exception { + A_txt = src.blob("A"); + A = src.commit().add(A_txt_name, A_txt).create(); + src.update(Constants.R_HEADS + Constants.MASTER, A); + + // create some random commits + RevCommit X = A; + for (int i = 0; i < n; i++) { + X = src.commit().parent(X) + .add(randomAsciiString(), randomAsciiString()).create(); + } + + B = src.commit().parent(X).add(A_txt_name, "C").add("B", "B").create(); + src.update(Constants.R_HEADS + Constants.MASTER, B); + + v1_0 = src.tag(v1_0_name, B); + src.update(Constants.R_TAGS + v1_0_name, v1_0); + + C = src.commit().parent(A).add(A_txt_name, "D").add("C", "C").create(); + src.update(Constants.R_HEADS + FIX, C); + + v2_0 = src.tag(v2_0_name, C); + src.update(Constants.R_TAGS + v2_0_name, v2_0); + } + + private String randomAsciiString() { + StringBuilder randstring = new StringBuilder(""); + Random rand = new Random(); + int strlen = rand.nextInt(20) + 10; + for (int i = 0, j = 0; i < strlen; i++) { + if (rand.nextInt(2) == 1) + j = 97; + else + j = 65; + randstring.append((char) (rand.nextInt(26) + j)); + } + return randstring.toString(); + } + + private void serve() throws IOException { + d = new Daemon(); + FileResolver<DaemonClient> resolver = new FileResolver<DaemonClient>(); + resolver.exportRepository(REPO_NAME, src.getRepository()); + d.setRepositoryResolver(resolver); + d.start(); + uri = "git://localhost:" + d.getAddress().getPort() + "/" + REPO_NAME + + Constants.DOT_GIT_EXT; + } + + private void serveHttp() throws Exception{ + httpServer = new SimpleHttpServer(src.getRepository()); + httpServer.start(); + uri = httpServer.getUri().toString(); + } + + /** + * Stop the git daemon and delete test data from disk. If the system + * property <code>test-repo-no-cleanup</code> is defined the test data will + * be left on disk for analysis. * - * @throws Exception
- * deletion of test repository failed
- * @throws IOException
- * deletion of test repository failed
- */
- public void shutDown() throws Exception {
- src.getRepository().close();
- if (serveHttp)
- httpServer.stop();
- else
+ * @throws Exception + * deletion of test repository failed + * @throws IOException + * deletion of test repository failed + */ + public void shutDown() throws Exception { + src.getRepository().close(); + if (serveHttp) + httpServer.stop(); + else d.stop(); -
- if (!System.getProperties().contains("test-repo-no-cleanup"))
- FileUtils.delete(trash, FileUtils.RECURSIVE | FileUtils.RETRY);
- }
-
-}
+ + if (!System.getProperties().contains("test-repo-no-cleanup")) + FileUtils.delete(trash, FileUtils.RECURSIVE | FileUtils.RETRY); + } + +} diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CheckoutDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CheckoutDialog.java index bf23ad04d3..1ee44a8ea3 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CheckoutDialog.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CheckoutDialog.java @@ -1,257 +1,257 @@ -/*******************************************************************************
- * Copyright (c) 2011 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.dialogs;
-
-import static org.eclipse.jgit.lib.Constants.R_HEADS;
-import static org.eclipse.jgit.lib.Constants.R_REMOTES;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.internal.CommonUtils;
-import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.egit.ui.internal.ValidationUtils;
-import org.eclipse.egit.ui.internal.repository.CreateBranchWizard;
-import org.eclipse.egit.ui.internal.repository.tree.RefNode;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchCommandConstants;
-
-/**
- * Dialog for checking out a branch, tag, or Reference.
- *
- */
-public class CheckoutDialog extends AbstractBranchSelectionDialog {
-
- private String currentBranch;
-
- private Button deleteteButton;
-
- private Button renameButton;
-
- private Button newButton;
-
- /**
- * @param parentShell
- * @param repo
- */
- public CheckoutDialog(Shell parentShell, Repository repo) {
- super(parentShell, repo, SHOW_LOCAL_BRANCHES | SHOW_REMOTE_BRANCHES
- | SHOW_TAGS | SHOW_REFERENCES | EXPAND_LOCAL_BRANCHES_NODE
- | ALLOW_MULTISELECTION);
- try {
- currentBranch = repo.getFullBranch();
- } catch (IOException e) {
- currentBranch = null;
- }
- }
-
- @Override
- protected String getMessageText() {
- return UIText.CheckoutDialog_Message;
- }
-
- @Override
- protected String getTitle() {
- return UIText.CheckoutDialog_Title;
- }
-
- @Override
- protected String getWindowTitle() {
- return UIText.CheckoutDialog_WindowTitle;
- }
-
- @Override
- protected void refNameSelected(String refName) {
- boolean tagSelected = refName != null
- && refName.startsWith(Constants.R_TAGS);
-
- boolean branchSelected = refName != null
- && (refName.startsWith(Constants.R_HEADS) || refName
- .startsWith(Constants.R_REMOTES));
-
- // handle multiple selection
- if (((TreeSelection) branchTree.getSelection()).size() > 1) {
- TreeSelection selection = (TreeSelection) branchTree
- .getSelection();
- boolean onlyBranchesAreSelected = onlyBranchesAreSelected(selection);
-
- // enable/disable buttons
- deleteteButton.setEnabled(onlyBranchesAreSelected);
- renameButton.setEnabled(false);
- newButton.setEnabled(false);
- } else {
- getButton(Window.OK).setEnabled(branchSelected || tagSelected);
-
- // we don't support rename on tags
- renameButton.setEnabled(branchSelected && !tagSelected);
- deleteteButton.setEnabled(branchSelected && !tagSelected);
-
- // new button should be always enabled
- newButton.setEnabled(true);
- }
-
- getButton(Window.OK).setEnabled(
- refName != null && !refName.equals(currentBranch));
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- newButton = new Button(parent, SWT.PUSH);
- newButton.setFont(JFaceResources.getDialogFont());
- newButton.setText(UIText.CheckoutDialog_NewBranch);
- setButtonLayoutData(newButton);
- ((GridLayout) parent.getLayout()).numColumns++;
-
- renameButton = new Button(parent, SWT.PUSH);
- renameButton.setFont(JFaceResources.getDialogFont());
- renameButton.setText(UIText.CheckoutDialog_Rename);
- setButtonLayoutData(renameButton);
- ((GridLayout) parent.getLayout()).numColumns++;
-
- deleteteButton = new Button(parent, SWT.PUSH);
- deleteteButton.setFont(JFaceResources.getDialogFont());
- deleteteButton.setText(UIText.CheckoutDialog_Delete);
- setButtonLayoutData(deleteteButton);
- ((GridLayout) parent.getLayout()).numColumns++;
-
- renameButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
-
- String refName = refNameFromDialog();
- String refPrefix;
-
- if (refName.startsWith(Constants.R_HEADS))
- refPrefix = Constants.R_HEADS;
- else if (refName.startsWith(Constants.R_REMOTES))
- refPrefix = Constants.R_REMOTES;
- else if (refName.startsWith(Constants.R_TAGS))
- refPrefix = Constants.R_TAGS;
- else {
- // the button should be disabled anyway, but we check again
- return;
- }
-
- String branchName = refName.substring(refPrefix.length());
-
- InputDialog labelDialog = getRefNameInputDialog(NLS.bind(
- UIText.CheckoutDialog_QuestionNewBranchNameMessage,
- branchName, refPrefix), refPrefix, branchName);
- if (labelDialog.open() == Window.OK) {
- String newRefName = refPrefix + labelDialog.getValue();
- try {
- new Git(repo).branchRename().setOldName(refName)
- .setNewName(labelDialog.getValue()).call();
- branchTree.refresh();
- markRef(newRefName);
- } catch (Throwable e1) {
- reportError(e1,
- UIText.CheckoutDialog_ErrorCouldNotRenameRef,
- refName, newRefName, e1.getMessage());
- }
- }
- }
- });
- newButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CreateBranchWizard wiz = new CreateBranchWizard(repo,
- refNameFromDialog());
- if (new WizardDialog(getShell(), wiz).open() == Window.OK) {
- String newRefName = wiz.getNewBranchName();
- try {
- branchTree.refresh();
- markRef(Constants.R_HEADS + newRefName);
- if (repo.getBranch().equals(newRefName))
- // close branch selection dialog when new branch was
- // already checked out from new branch wizard
- CheckoutDialog.this.okPressed();
- } catch (Throwable e1) {
- reportError(
- e1,
- UIText.CheckoutDialog_ErrorCouldNotCreateNewRef,
- newRefName);
- }
- }
- }
- });
-
- deleteteButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent selectionEvent) {
- try {
- CommonUtils.runCommand(
- IWorkbenchCommandConstants.EDIT_DELETE,
- (IStructuredSelection) branchTree.getSelection());
- branchTree.refresh();
- } catch (Throwable e) {
- reportError(e,
- UIText.CheckoutDialog_ErrorCouldNotDeleteRef,
- refNameFromDialog());
- }
- }
- });
-
- super.createButtonsForButtonBar(parent);
-
- getButton(Window.OK).setText(UIText.CheckoutDialog_OkCheckout);
-
- // can't advance without a selection
- getButton(Window.OK).setEnabled(!branchTree.getSelection().isEmpty());
- }
-
- private InputDialog getRefNameInputDialog(String prompt,
- final String refPrefix, String initialValue) {
- InputDialog labelDialog = new InputDialog(getShell(),
- UIText.CheckoutDialog_QuestionNewBranchTitle, prompt,
- initialValue, ValidationUtils.getRefNameInputValidator(repo,
- refPrefix, true));
- labelDialog.setBlockOnOpen(true);
- return labelDialog;
- }
-
- private void reportError(Throwable e, String message, Object... args) {
- String msg = NLS.bind(message, args);
- Activator.handleError(msg, e, true);
- }
-
- private boolean onlyBranchesAreSelected(TreeSelection selection) {
- Iterator selIterator = selection.iterator();
- while (selIterator.hasNext()) {
- Object sel = selIterator.next();
- if (sel instanceof RefNode) {
- RefNode node = (RefNode) sel;
- String refName = node.getObject().getName();
- if (!refName.startsWith(R_HEADS)
- && !refName.startsWith(R_REMOTES))
- return false;
- } else
- return false;
- }
-
- return true;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 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.dialogs; + +import static org.eclipse.jgit.lib.Constants.R_HEADS; +import static org.eclipse.jgit.lib.Constants.R_REMOTES; + +import java.io.IOException; +import java.util.Iterator; + +import org.eclipse.egit.ui.Activator; +import org.eclipse.egit.ui.internal.CommonUtils; +import org.eclipse.egit.ui.internal.UIText; +import org.eclipse.egit.ui.internal.ValidationUtils; +import org.eclipse.egit.ui.internal.repository.CreateBranchWizard; +import org.eclipse.egit.ui.internal.repository.tree.RefNode; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchCommandConstants; + +/** + * Dialog for checking out a branch, tag, or Reference. + * + */ +public class CheckoutDialog extends AbstractBranchSelectionDialog { + + private String currentBranch; + + private Button deleteteButton; + + private Button renameButton; + + private Button newButton; + + /** + * @param parentShell + * @param repo + */ + public CheckoutDialog(Shell parentShell, Repository repo) { + super(parentShell, repo, SHOW_LOCAL_BRANCHES | SHOW_REMOTE_BRANCHES + | SHOW_TAGS | SHOW_REFERENCES | EXPAND_LOCAL_BRANCHES_NODE + | ALLOW_MULTISELECTION); + try { + currentBranch = repo.getFullBranch(); + } catch (IOException e) { + currentBranch = null; + } + } + + @Override + protected String getMessageText() { + return UIText.CheckoutDialog_Message; + } + + @Override + protected String getTitle() { + return UIText.CheckoutDialog_Title; + } + + @Override + protected String getWindowTitle() { + return UIText.CheckoutDialog_WindowTitle; + } + + @Override + protected void refNameSelected(String refName) { + boolean tagSelected = refName != null + && refName.startsWith(Constants.R_TAGS); + + boolean branchSelected = refName != null + && (refName.startsWith(Constants.R_HEADS) || refName + .startsWith(Constants.R_REMOTES)); + + // handle multiple selection + if (((TreeSelection) branchTree.getSelection()).size() > 1) { + TreeSelection selection = (TreeSelection) branchTree + .getSelection(); + boolean onlyBranchesAreSelected = onlyBranchesAreSelected(selection); + + // enable/disable buttons + deleteteButton.setEnabled(onlyBranchesAreSelected); + renameButton.setEnabled(false); + newButton.setEnabled(false); + } else { + getButton(Window.OK).setEnabled(branchSelected || tagSelected); + + // we don't support rename on tags + renameButton.setEnabled(branchSelected && !tagSelected); + deleteteButton.setEnabled(branchSelected && !tagSelected); + + // new button should be always enabled + newButton.setEnabled(true); + } + + getButton(Window.OK).setEnabled( + refName != null && !refName.equals(currentBranch)); + } + + @Override + protected void createButtonsForButtonBar(Composite parent) { + newButton = new Button(parent, SWT.PUSH); + newButton.setFont(JFaceResources.getDialogFont()); + newButton.setText(UIText.CheckoutDialog_NewBranch); + setButtonLayoutData(newButton); + ((GridLayout) parent.getLayout()).numColumns++; + + renameButton = new Button(parent, SWT.PUSH); + renameButton.setFont(JFaceResources.getDialogFont()); + renameButton.setText(UIText.CheckoutDialog_Rename); + setButtonLayoutData(renameButton); + ((GridLayout) parent.getLayout()).numColumns++; + + deleteteButton = new Button(parent, SWT.PUSH); + deleteteButton.setFont(JFaceResources.getDialogFont()); + deleteteButton.setText(UIText.CheckoutDialog_Delete); + setButtonLayoutData(deleteteButton); + ((GridLayout) parent.getLayout()).numColumns++; + + renameButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + + String refName = refNameFromDialog(); + String refPrefix; + + if (refName.startsWith(Constants.R_HEADS)) + refPrefix = Constants.R_HEADS; + else if (refName.startsWith(Constants.R_REMOTES)) + refPrefix = Constants.R_REMOTES; + else if (refName.startsWith(Constants.R_TAGS)) + refPrefix = Constants.R_TAGS; + else { + // the button should be disabled anyway, but we check again + return; + } + + String branchName = refName.substring(refPrefix.length()); + + InputDialog labelDialog = getRefNameInputDialog(NLS.bind( + UIText.CheckoutDialog_QuestionNewBranchNameMessage, + branchName, refPrefix), refPrefix, branchName); + if (labelDialog.open() == Window.OK) { + String newRefName = refPrefix + labelDialog.getValue(); + try { + new Git(repo).branchRename().setOldName(refName) + .setNewName(labelDialog.getValue()).call(); + branchTree.refresh(); + markRef(newRefName); + } catch (Throwable e1) { + reportError(e1, + UIText.CheckoutDialog_ErrorCouldNotRenameRef, + refName, newRefName, e1.getMessage()); + } + } + } + }); + newButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + CreateBranchWizard wiz = new CreateBranchWizard(repo, + refNameFromDialog()); + if (new WizardDialog(getShell(), wiz).open() == Window.OK) { + String newRefName = wiz.getNewBranchName(); + try { + branchTree.refresh(); + markRef(Constants.R_HEADS + newRefName); + if (repo.getBranch().equals(newRefName)) + // close branch selection dialog when new branch was + // already checked out from new branch wizard + CheckoutDialog.this.okPressed(); + } catch (Throwable e1) { + reportError( + e1, + UIText.CheckoutDialog_ErrorCouldNotCreateNewRef, + newRefName); + } + } + } + }); + + deleteteButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent selectionEvent) { + try { + CommonUtils.runCommand( + IWorkbenchCommandConstants.EDIT_DELETE, + (IStructuredSelection) branchTree.getSelection()); + branchTree.refresh(); + } catch (Throwable e) { + reportError(e, + UIText.CheckoutDialog_ErrorCouldNotDeleteRef, + refNameFromDialog()); + } + } + }); + + super.createButtonsForButtonBar(parent); + + getButton(Window.OK).setText(UIText.CheckoutDialog_OkCheckout); + + // can't advance without a selection + getButton(Window.OK).setEnabled(!branchTree.getSelection().isEmpty()); + } + + private InputDialog getRefNameInputDialog(String prompt, + final String refPrefix, String initialValue) { + InputDialog labelDialog = new InputDialog(getShell(), + UIText.CheckoutDialog_QuestionNewBranchTitle, prompt, + initialValue, ValidationUtils.getRefNameInputValidator(repo, + refPrefix, true)); + labelDialog.setBlockOnOpen(true); + return labelDialog; + } + + private void reportError(Throwable e, String message, Object... args) { + String msg = NLS.bind(message, args); + Activator.handleError(msg, e, true); + } + + private boolean onlyBranchesAreSelected(TreeSelection selection) { + Iterator selIterator = selection.iterator(); + while (selIterator.hasNext()) { + Object sel = selIterator.next(); + if (sel instanceof RefNode) { + RefNode node = (RefNode) sel; + String refName = node.getObject().getName(); + if (!refName.startsWith(R_HEADS) + && !refName.startsWith(R_REMOTES)) + return false; + } else + return false; + } + + return true; + } + +} diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/DeleteBranchDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/DeleteBranchDialog.java index 7e46473cb9..33bea310bd 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/DeleteBranchDialog.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/DeleteBranchDialog.java @@ -1,143 +1,143 @@ -/*******************************************************************************
- * Copyright (c) 2011 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.dialogs;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.egit.core.op.DeleteBranchOperation;
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.egit.ui.internal.repository.tree.RefNode;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Dialog for deleting a branch
- *
- */
-public class DeleteBranchDialog extends AbstractBranchSelectionDialog {
-
- private final Set<Ref> selectedRefs = new HashSet<Ref>();
- private String currentBranch;
-
- /**
- * @param parentShell
- * @param repo
- */
- public DeleteBranchDialog(Shell parentShell, Repository repo) {
- super(parentShell, repo, SHOW_LOCAL_BRANCHES
- | EXPAND_LOCAL_BRANCHES_NODE | SHOW_REMOTE_BRANCHES
- | ALLOW_MULTISELECTION);
- try {
- currentBranch = repo.getFullBranch();
- } catch (IOException e) {
- // just ignore here
- }
- }
-
- @Override
- protected String getMessageText() {
- return UIText.DeleteBranchDialog_DialogMessage;
- }
-
- @Override
- protected String getTitle() {
- return UIText.DeleteBranchDialog_DialogTitle;
- }
-
- @Override
- protected String getWindowTitle() {
- return UIText.DeleteBranchDialog_WindowTitle;
- }
-
- @Override
- protected String refNameFromDialog() {
- selectedRefs.clear();
- Set<String> selected = new HashSet<String>();
- IStructuredSelection selection = (IStructuredSelection) branchTree.getSelection();
- for (Object sel : selection.toArray()) {
- if (!(sel instanceof RefNode))
- continue;
-
- RefNode node = (RefNode) sel;
- Ref ref = node.getObject();
- selectedRefs.add(ref);
- selected.add(ref.getName());
- }
-
- boolean enabled = !selected.isEmpty()
- && !selected.contains(currentBranch);
- getButton(Window.OK).setEnabled(enabled);
-
- return null;
- }
-
- @Override
- protected void refNameSelected(String refName) {
- // unused
- }
-
- @Override
- protected void buttonPressed(int buttonId) {
- if (buttonId == Window.OK) {
- try {
- int result = deleteBranch(selectedRefs, false);
- if (result == DeleteBranchOperation.REJECTED_UNMERGED) {
- List<RefNode> nodes = extractSelectedRefNodes();
-
- MessageDialog messageDialog = new UnmergedBranchDialog<RefNode>(
- getShell(), nodes);
-
- if (messageDialog.open() == Window.OK)
- deleteBranch(selectedRefs, true);
- else
- return;
- } else if (result == DeleteBranchOperation.REJECTED_CURRENT)
- Activator
- .handleError(
- UIText.DeleteBranchCommand_CannotDeleteCheckedOutBranch,
- null, true);
- } catch (CoreException e) {
- Activator.handleError(e.getMessage(), e, true);
- }
- }
-
- super.buttonPressed(buttonId);
- }
-
- private int deleteBranch(final Set<Ref> ref, boolean force) throws CoreException {
- DeleteBranchOperation dbop = new DeleteBranchOperation(repo, ref, force);
- dbop.execute(null);
- return dbop.getStatus();
- }
-
- private List<RefNode> extractSelectedRefNodes() {
- List<RefNode> nodes = new ArrayList<RefNode>();
- Object[] array = ((IStructuredSelection) super.branchTree
- .getSelection()).toArray();
-
- for (Object selected : array)
- if (selected instanceof RefNode)
- nodes.add((RefNode) selected);
-
- return nodes;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 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.dialogs; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.egit.core.op.DeleteBranchOperation; +import org.eclipse.egit.ui.Activator; +import org.eclipse.egit.ui.internal.UIText; +import org.eclipse.egit.ui.internal.repository.tree.RefNode; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.jgit.lib.Ref; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.swt.widgets.Shell; + +/** + * Dialog for deleting a branch + * + */ +public class DeleteBranchDialog extends AbstractBranchSelectionDialog { + + private final Set<Ref> selectedRefs = new HashSet<Ref>(); + private String currentBranch; + + /** + * @param parentShell + * @param repo + */ + public DeleteBranchDialog(Shell parentShell, Repository repo) { + super(parentShell, repo, SHOW_LOCAL_BRANCHES + | EXPAND_LOCAL_BRANCHES_NODE | SHOW_REMOTE_BRANCHES + | ALLOW_MULTISELECTION); + try { + currentBranch = repo.getFullBranch(); + } catch (IOException e) { + // just ignore here + } + } + + @Override + protected String getMessageText() { + return UIText.DeleteBranchDialog_DialogMessage; + } + + @Override + protected String getTitle() { + return UIText.DeleteBranchDialog_DialogTitle; + } + + @Override + protected String getWindowTitle() { + return UIText.DeleteBranchDialog_WindowTitle; + } + + @Override + protected String refNameFromDialog() { + selectedRefs.clear(); + Set<String> selected = new HashSet<String>(); + IStructuredSelection selection = (IStructuredSelection) branchTree.getSelection(); + for (Object sel : selection.toArray()) { + if (!(sel instanceof RefNode)) + continue; + + RefNode node = (RefNode) sel; + Ref ref = node.getObject(); + selectedRefs.add(ref); + selected.add(ref.getName()); + } + + boolean enabled = !selected.isEmpty() + && !selected.contains(currentBranch); + getButton(Window.OK).setEnabled(enabled); + + return null; + } + + @Override + protected void refNameSelected(String refName) { + // unused + } + + @Override + protected void buttonPressed(int buttonId) { + if (buttonId == Window.OK) { + try { + int result = deleteBranch(selectedRefs, false); + if (result == DeleteBranchOperation.REJECTED_UNMERGED) { + List<RefNode> nodes = extractSelectedRefNodes(); + + MessageDialog messageDialog = new UnmergedBranchDialog<RefNode>( + getShell(), nodes); + + if (messageDialog.open() == Window.OK) + deleteBranch(selectedRefs, true); + else + return; + } else if (result == DeleteBranchOperation.REJECTED_CURRENT) + Activator + .handleError( + UIText.DeleteBranchCommand_CannotDeleteCheckedOutBranch, + null, true); + } catch (CoreException e) { + Activator.handleError(e.getMessage(), e, true); + } + } + + super.buttonPressed(buttonId); + } + + private int deleteBranch(final Set<Ref> ref, boolean force) throws CoreException { + DeleteBranchOperation dbop = new DeleteBranchOperation(repo, ref, force); + dbop.execute(null); + return dbop.getStatus(); + } + + private List<RefNode> extractSelectedRefNodes() { + List<RefNode> nodes = new ArrayList<RefNode>(); + Object[] array = ((IStructuredSelection) super.branchTree + .getSelection()).toArray(); + + for (Object selected : array) + if (selected instanceof RefNode) + nodes.add((RefNode) selected); + + return nodes; + } + +} |