1 /*******************************************************************************
2 * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
3 * Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * See LICENSE for the full license text, also available.
8 *******************************************************************************/
9 package org
.spearce
.egit
.ui
.internal
.sharing
;
11 import java
.lang
.reflect
.InvocationTargetException
;
13 import org
.eclipse
.core
.resources
.IProject
;
14 import org
.eclipse
.core
.runtime
.CoreException
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
17 import org
.eclipse
.core
.runtime
.Status
;
18 import org
.eclipse
.jface
.dialogs
.ErrorDialog
;
19 import org
.eclipse
.jface
.operation
.IRunnableWithProgress
;
20 import org
.eclipse
.jface
.wizard
.Wizard
;
21 import org
.eclipse
.team
.ui
.IConfigurationWizard
;
22 import org
.eclipse
.team
.ui
.IConfigurationWizardExtension
;
23 import org
.eclipse
.ui
.IWorkbench
;
24 import org
.spearce
.egit
.core
.op
.ConnectProviderOperation
;
25 import org
.spearce
.egit
.ui
.Activator
;
26 import org
.spearce
.egit
.ui
.UIText
;
29 * The dialog used for activating Team>Share, i.e. to create a new
30 * Git repository or associate projects with one.
32 public class SharingWizard
extends Wizard
implements IConfigurationWizard
,
33 IConfigurationWizardExtension
{
36 private ExistingOrNewPage existingPage
;
39 * Construct the Git Sharing Wizard for connecting Git project to Eclipse
41 public SharingWizard() {
42 setWindowTitle(UIText
.SharingWizard_windowTitle
);
43 setNeedsProgressMonitor(true);
46 public void init(IWorkbench workbench
, IProject
[] p
) {
47 this.projects
= new IProject
[p
.length
];
48 System
.arraycopy(p
, 0, this.projects
, 0, p
.length
);
51 public void init(final IWorkbench workbench
, final IProject p
) {
52 projects
= new IProject
[] { p
};
55 public void addPages() {
56 existingPage
= new ExistingOrNewPage(this);
57 addPage(existingPage
);
60 public boolean performFinish() {
61 final ConnectProviderOperation op
= new ConnectProviderOperation(
62 existingPage
.getProjects());
64 getContainer().run(true, false, new IRunnableWithProgress() {
65 public void run(final IProgressMonitor monitor
)
66 throws InvocationTargetException
{
69 } catch (CoreException ce
) {
70 throw new InvocationTargetException(ce
);
75 } catch (Throwable e
) {
76 if (e
instanceof InvocationTargetException
) {
80 if (e
instanceof CoreException
) {
81 status
= ((CoreException
) e
).getStatus();
82 e
= status
.getException();
84 status
= new Status(IStatus
.ERROR
, Activator
.getPluginId(), 1,
85 UIText
.SharingWizard_failed
, e
);
87 Activator
.logError(UIText
.SharingWizard_failed
, e
);
88 ErrorDialog
.openError(getContainer().getShell(), getWindowTitle(),
89 UIText
.SharingWizard_failed
, status
, status
.getSeverity());
95 public boolean canFinish() {
96 return existingPage
.isPageComplete();