Skip to main content
summaryrefslogtreecommitdiffstats
blob: d8b5143d681cdc455062cb665dde9dac637a96f5 (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
/*******************************************************************************
 * Copyright (c) 2009 Atlassian 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:
 *     Atlassian - initial API and implementation
 ******************************************************************************/

package com.atlassian.connector.eclipse.internal.crucible.ui.dialogs;

import com.atlassian.connector.eclipse.internal.crucible.ui.CrucibleUiUtil;
import com.atlassian.connector.eclipse.internal.crucible.ui.editor.parts.ReviewersSelectionTreePart;
import com.atlassian.theplugin.commons.crucible.api.model.Review;
import com.atlassian.theplugin.commons.crucible.api.model.User;
import com.atlassian.theplugin.commons.util.MiscUtil;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

import java.util.Collection;
import java.util.Set;

/**
 * Dialog for selecting reviewers
 * 
 * @author Thomas Ehrnhoefer
 */
public class ReviewerSelectionDialog extends Dialog {

	private final Set<User> selectedReviewers;

	private final Set<User> allReviewers;

	private ReviewersSelectionTreePart reviewersSelectionTreePart;

	public ReviewerSelectionDialog(Shell shell, Review review, Collection<User> users) {
		super(shell);
		setShellStyle(getShellStyle() | SWT.RESIZE);
		selectedReviewers = CrucibleUiUtil.toUsers(review.getReviewers());
		allReviewers = MiscUtil.buildHashSet(users);
	}

	@Override
	protected Control createDialogArea(Composite parent) {
		getShell().setText("Select Reviewer(s)");
		reviewersSelectionTreePart = new ReviewersSelectionTreePart(selectedReviewers, allReviewers);
		final Composite composite = reviewersSelectionTreePart.createControl(parent);
		applyDialogFont(composite);
		return composite;
	}

	public Set<User> getSelectedReviewers() {
		return reviewersSelectionTreePart.getSelectedReviewers();
	}
}

Back to the top