1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.theplugin.idea.crucible.table.column;
18
19 import com.atlassian.theplugin.idea.TableColumnInfo;
20 import com.atlassian.theplugin.idea.crucible.ReviewDataInfoAdapter;
21 import com.atlassian.theplugin.commons.crucible.api.model.User;
22 import com.atlassian.theplugin.commons.crucible.api.model.Reviewer;
23
24 import java.util.Comparator;
25 import java.util.Iterator;
26
27
28 public class ReviewReviewersColumn extends TableColumnInfo {
29 private static final int COL_WIDTH = 200;
30
31 public String getColumnName() {
32 return "Reviewers";
33 }
34
35 public Object valueOf(Object o) {
36 String reviewers = "<html>";
37 reviewers += getReviewersAsText(o);
38 reviewers += "</html>";
39 return reviewers;
40 }
41
42 private String getReviewersAsText(Object o) {
43 StringBuffer sb = new StringBuffer();
44 if (((ReviewDataInfoAdapter) o).getReviewers() != null) {
45 for (Iterator<Reviewer> iterator = ((ReviewDataInfoAdapter) o).getReviewers().iterator(); iterator.hasNext();) {
46 sb.append(iterator.next().getUserName());
47 if (iterator.hasNext()) {
48 sb.append(", ");
49 }
50 }
51 }
52 return sb.toString();
53 }
54
55 public Class getColumnClass() {
56 return String.class;
57 }
58
59 public Comparator getComparator() {
60 return new Comparator() {
61 public int compare(Object o, Object o1) {
62 String r = getReviewersAsText(o);
63 String r1 = getReviewersAsText(o1);
64 return r.compareTo(r1);
65 }
66 };
67 }
68
69 public int getPrefferedWidth() {
70 return COL_WIDTH;
71 }
72
73
74 }