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.intellij.openapi.actionSystem.AnAction;
20 import com.intellij.openapi.actionSystem.AnActionEvent;
21 import com.intellij.openapi.actionSystem.DataKeys;
22 import com.intellij.openapi.vcs.changes.ChangeList;
23 import com.intellij.openapi.project.Project;
24 import com.atlassian.theplugin.idea.crucible.CruciblePatchSubmitCommitSession;
25 import com.atlassian.theplugin.commons.crucible.CrucibleServerFacadeImpl;
26
27 public class PreCommitReview extends AnAction {
28
29 public void actionPerformed(AnActionEvent event) {
30 final ChangeList[] changes = DataKeys.CHANGE_LISTS.getData(event.getDataContext());
31 final Project project = DataKeys.PROJECT.getData(event.getDataContext());
32
33 new Thread(new Runnable() {
34 public void run() {
35 new CruciblePatchSubmitCommitSession(project, CrucibleServerFacadeImpl.getInstance()).execute(
36 changes[0].getChanges(), changes[0].getName());
37 }
38 }).start();
39 }
40
41 public void update(AnActionEvent event) {
42 super.update(event);
43 final ChangeList[] changes = DataKeys.CHANGE_LISTS.getData(event.getDataContext());
44 if (changes != null && changes.length == 1) {
45 event.getPresentation().setEnabled(true);
46 } else {
47 event.getPresentation().setEnabled(false);
48 }
49 }
50 }
51