Skip to main content
summaryrefslogtreecommitdiffstats
blob: ea7a416a5e2b8f5ba8dd388826c3f5040db5cf1d (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
/*******************************************************************************
 * 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.actions;

import com.atlassian.connector.eclipse.internal.crucible.ui.CrucibleImages;
import com.atlassian.connector.eclipse.internal.crucible.ui.ActiveReviewManager.IReviewActivationListener;
import com.atlassian.connector.eclipse.internal.crucible.ui.wizards.ReviewWizard;
import com.atlassian.connector.eclipse.internal.crucible.ui.wizards.ReviewWizard.Type;
import com.atlassian.theplugin.commons.crucible.api.model.CrucibleAction;
import com.atlassian.theplugin.commons.crucible.api.model.Review;
import com.atlassian.theplugin.commons.crucible.api.model.notification.CrucibleNotification;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.swt.widgets.Display;
import java.util.Collection;
import java.util.Set;

public class AddChangesetToActiveReviewAction extends Action implements IReviewActivationListener {

	private Review activeReview;

	public AddChangesetToActiveReviewAction() {
		setText("Add changesets...");
		setToolTipText("Add changesets to the Review.");
		setImageDescriptor(CrucibleImages.ADD_CHANGESET);
	}

	public void run() {
		ReviewWizard wizard = new ReviewWizard(activeReview, Type.ADD_CHANGESET);
		wizard.setWindowTitle("Add Changeset");
		WizardDialog wd = new WizardDialog(WorkbenchUtil.getShell(), wizard);
		wd.setBlockOnOpen(true);
		wd.open();
	};

	public void reviewActivated(final ITask task, final Review review) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				activeReview = review;

				Set<CrucibleAction> actions = activeReview.getActions();

				setEnabled(activeReview != null && actions != null && actions.contains(CrucibleAction.MODIFY_FILES));
			}
		});
	}

	public void reviewDeactivated(ITask task, Review review) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				activeReview = null;
				setEnabled(false);
			}
		});
	}

	public void reviewUpdated(ITask task, Review review, Collection<CrucibleNotification> differences) {
		reviewActivated(task, review);
	}

}

Back to the top