1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.theplugin.idea.action.crucible;
18
19 import com.atlassian.theplugin.commons.crucible.CrucibleServerFacadeImpl;
20 import com.atlassian.theplugin.commons.crucible.api.model.PermId;
21 import com.atlassian.theplugin.idea.IdeaHelper;
22 import com.atlassian.theplugin.idea.crucible.CrucibleRevisionAddWorker;
23 import com.atlassian.theplugin.idea.crucible.ReviewData;
24 import com.intellij.openapi.actionSystem.AnActionEvent;
25 import com.intellij.openapi.actionSystem.DataKeys;
26 import com.intellij.openapi.application.ApplicationManager;
27 import com.intellij.openapi.application.ModalityState;
28 import com.intellij.openapi.vcs.changes.ChangeList;
29 import com.intellij.openapi.project.Project;
30
31 public class AddRevisionToReviewAction extends Crucible16RepositoryAction {
32 public void actionPerformed(AnActionEvent event) {
33 final ChangeList[] changes = DataKeys.CHANGE_LISTS.getData(event.getDataContext());
34 final PermId permId = IdeaHelper.getCrucibleToolWindowPanel(event).getSelectedReviewId();
35 final Project project = event.getData(DataKeys.PROJECT);
36
37 new Thread(new Runnable() {
38 public void run() {
39 ApplicationManager.getApplication().invokeAndWait(
40 new CrucibleRevisionAddWorker(project, CrucibleServerFacadeImpl.getInstance(), permId, changes),
41 ModalityState.defaultModalityState());
42 }
43 }).start();
44 }
45
46 public void update(AnActionEvent event) {
47 super.update(event);
48 if (IdeaHelper.getCrucibleToolWindowPanel(event) != null) {
49 if (event.getPresentation().isEnabled()) {
50 if (IdeaHelper.getCrucibleToolWindowPanel(event).getSelectedReview() == null) {
51 event.getPresentation().setEnabled(false);
52 } else {
53 ReviewData rd = IdeaHelper.getCrucibleToolWindowPanel(event).getSelectedReview();
54 event.getPresentation().setEnabled(
55 rd.getCreator().getUserName().equals(rd.getServer().getUsername()));
56 }
57 }
58 } else {
59 event.getPresentation().setEnabled(false);
60 }
61 }
62 }