Fetch GUI
[egit/zawir.git] / org.spearce.egit.ui / src / org / spearce / egit / ui / internal / actions / FetchAction.java
blob582cb4680853fea18f81cccc244e7e7f65328e25
1 /*******************************************************************************
2 * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * See LICENSE for the full license text, also available.
7 *******************************************************************************/
8 package org.spearce.egit.ui.internal.actions;
10 import java.net.URISyntaxException;
12 import org.eclipse.core.runtime.IStatus;
13 import org.eclipse.core.runtime.Status;
14 import org.eclipse.jface.action.IAction;
15 import org.eclipse.jface.dialogs.ErrorDialog;
16 import org.eclipse.jface.wizard.WizardDialog;
17 import org.spearce.egit.ui.Activator;
18 import org.spearce.egit.ui.UIText;
19 import org.spearce.egit.ui.internal.fetch.FetchWizard;
20 import org.spearce.jgit.lib.Repository;
22 /**
23 * Action for displaying fetch wizard - allowing selection of specifications for
24 * fetch, and fetching objects/refs from another repository.
26 public class FetchAction extends RepositoryAction {
27 @Override
28 public void run(IAction action) {
29 final Repository repository = getRepository(true);
30 if (repository == null)
31 return;
33 final FetchWizard fetchWizard;
34 try {
35 fetchWizard = new FetchWizard(repository);
36 } catch (URISyntaxException x) {
37 ErrorDialog.openError(getShell(), UIText.FetchAction_wrongURITitle,
38 UIText.FetchAction_wrongURIMessage, new Status(
39 IStatus.ERROR, Activator.getPluginId(), x
40 .getMessage(), x));
41 return;
43 final WizardDialog dialog = new WizardDialog(getShell(), fetchWizard);
44 dialog.open();
47 @Override
48 public boolean isEnabled() {
49 return getRepository(false) != null;