Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: bc096fd313962603f27190d490102f3582f3d914 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/******************************************************************************
 *  Copyright (c) 2011 GitHub Inc.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License 2.0
 *  which accompanies this distribution, and is available at
 *  https://www.eclipse.org/legal/epl-2.0/
 *
 *  SPDX-License-Identifier: EPL-2.0
 *
 *  Contributors:
 *    Kevin Sawicki (GitHub Inc.) - initial API and implementation
 *****************************************************************************/
package org.eclipse.mylyn.internal.github.ui.pr;

import java.text.MessageFormat;

import org.eclipse.egit.github.core.PullRequest;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylyn.internal.github.core.pr.PullRequestConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
import org.eclipse.mylyn.tasks.ui.wizards.NewTaskWizard;
import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard;
import org.eclipse.ui.PlatformUI;

/**
 * Pull request connector UI
 */
public class PullRequestConnectorUi extends AbstractRepositoryConnectorUi {

	/**
	 * Show informational dialog for when a pull request cannot be resolved to a
	 * Git repository.
	 *
	 * @param request
	 *            must be non-null
	 */
	public static void showNoRepositoryDialog(PullRequest request) {
		Repository remoteRepo = request.getBase().getRepo();
		String id = remoteRepo.getOwner().getLogin() + '/'
				+ remoteRepo.getName();
		final String message = MessageFormat.format(
				Messages.PullRequestConnectorUi_MessageRepositoryNotFound, id);
		PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

			public void run() {
				MessageDialog
						.openInformation(
								PlatformUI.getWorkbench().getDisplay()
										.getActiveShell(),
								Messages.PullRequestConnectorUi_TitleRepositoryNotFound,
								message);
			}
		});
	}

	public String getConnectorKind() {
		return PullRequestConnector.KIND;
	}

	public ITaskRepositoryPage getSettingsPage(TaskRepository taskRepository) {
		return new PullRequestRepositorySettingsPage(taskRepository);
	}

	public IWizard getQueryWizard(TaskRepository taskRepository,
			IRepositoryQuery queryToEdit) {
		RepositoryQueryWizard wizard = new RepositoryQueryWizard(taskRepository);
		PullRequestRepositoryQueryPage queryPage = new PullRequestRepositoryQueryPage(
				taskRepository, queryToEdit);
		wizard.addPage(queryPage);
		return wizard;
	}

	public IWizard getNewTaskWizard(TaskRepository taskRepository,
			ITaskMapping selection) {
		return new NewTaskWizard(taskRepository, selection);
	}

	public boolean hasSearchPage() {
		return true;
	}

	@Override
	public String getTaskKindLabel(ITask task) {
		return Messages.PullRequestConnectorUi_LabelKind;
	}
}

Back to the top