1 /*******************************************************************************
2 * Copyright (C) 2008, Roger C. Soares <rogersoares@intelinet.com.br>
3 * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
4 * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
5 * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
6 * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
7 * Copyright (C) 2010, Benjamin Muskalla <bmuskalla@eclipsesource.com>
9 * All rights reserved. This program and the acco mpanying materials
10 * are made available under the terms of the Eclipse Public License 2.0
11 * which accompanies this distribution, and is available at
12 * https://www.eclipse.org/legal/epl-2.0/
14 * SPDX-License-Identifier: EPL-2.0
15 *******************************************************************************/
16 package org
.eclipse
.egit
.ui
.internal
.clone
;
19 import java
.io
.IOException
;
20 import java
.net
.URISyntaxException
;
22 import org
.eclipse
.egit
.ui
.Activator
;
23 import org
.eclipse
.egit
.ui
.internal
.UIIcons
;
24 import org
.eclipse
.egit
.ui
.internal
.UIText
;
25 import org
.eclipse
.egit
.ui
.internal
.components
.RepositorySelectionPage
;
26 import org
.eclipse
.egit
.ui
.internal
.provisional
.wizards
.IRepositorySearchResult
;
27 import org
.eclipse
.egit
.ui
.internal
.provisional
.wizards
.NoRepositoryInfoException
;
28 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
29 import org
.eclipse
.jgit
.util
.FileUtils
;
32 * Import Git Repository Wizard. A front end to a git clone operation.
34 public class GitCloneWizard
extends AbstractGitCloneWizard
{
36 private static final String HELP_CONTEXT
= "org.eclipse.egit.ui.GitCloneWizard"; //$NON-NLS-1$
39 * Construct the clone wizard with a repository location page that allows
40 * the repository info to be provided by different search providers.
42 public GitCloneWizard() {
47 * Construct the clone wizard with a preset URI. The wizard skips the
48 * repository location page in this case. Instead, it starts with the Custom
49 * URI repository selection page.
52 * the clone URI to prepopulate the URI field of the clone wizard
55 public GitCloneWizard(String presetUri
) {
56 super(new RepositorySelectionPage(true, presetUri
));
61 * Construct the clone wizard based on given repository search result. The
62 * wizard skips the repository location page in this case.
65 * the search result to initialize the clone wizard with.
67 public GitCloneWizard(IRepositorySearchResult searchResult
) {
72 private void initialize() {
73 setWindowTitle(UIText
.GitCloneWizard_title
);
74 setDefaultPageImageDescriptor(UIIcons
.WIZBAN_IMPORT_REPO
);
75 setNeedsProgressMonitor(true);
76 validSource
.setHelpContext(HELP_CONTEXT
);
77 cloneDestination
.setHelpContext(HELP_CONTEXT
);
81 * Set whether to show project import options on the destination page
86 public AbstractGitCloneWizard
setShowProjectImport(boolean show
) {
87 cloneDestination
.setShowProjectImport(show
);
92 public boolean performCancel() {
93 if (alreadyClonedInto
!= null) {
94 File test
= new File(alreadyClonedInto
);
96 && MessageDialog
.openQuestion(getShell(),
97 UIText
.GitCloneWizard_abortingCloneTitle
,
98 UIText
.GitCloneWizard_abortingCloneMsg
)) {
100 FileUtils
.delete(test
, FileUtils
.RECURSIVE
| FileUtils
.RETRY
);
101 } catch (IOException e
) {
102 throw new RuntimeException(e
);
110 protected void addPreClonePages() {
115 protected void addPostClonePages() {
120 public boolean canFinish() {
121 return cloneDestination
.isPageComplete();
125 public boolean performFinish() {
127 return performClone(currentSearchResult
.getGitRepositoryInfo());
128 } catch (URISyntaxException e
) {
129 Activator
.error(UIText
.GitImportWizard_errorParsingURI
, e
);
130 } catch (NoRepositoryInfoException e
) {
131 Activator
.error(UIText
.GitImportWizard_noRepositoryInfo
, e
);
132 } catch (Exception e
) {
133 Activator
.error(e
.getMessage(), e
);
135 setWindowTitle(UIText
.GitCloneWizard_title
);