1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.theplugin.idea.ui.tree.comment;
18
19 import com.atlassian.theplugin.idea.ui.tree.AtlassianClickAction;
20 import com.atlassian.theplugin.idea.ui.tree.AtlassianTreeNode;
21 import com.atlassian.theplugin.idea.crucible.ReviewData;
22 import com.intellij.ui.SimpleColoredComponent;
23 import com.intellij.ui.SimpleTextAttributes;
24 import com.jgoodies.forms.layout.CellConstraints;
25 import com.jgoodies.forms.layout.FormLayout;
26
27 import javax.swing.*;
28 import javax.swing.tree.TreeCellRenderer;
29 import java.awt.*;
30
31
32
33
34
35
36
37
38 public class GeneralSectionNode extends AtlassianTreeNode {
39 private static final String GENERAL_COMMENTS_SECTION = "General comments";
40
41 private static final TreeCellRenderer MY_RENDERER = new MyRenderer();
42 private ReviewData review;
43
44 public GeneralSectionNode(ReviewData review, AtlassianClickAction action) {
45 super(action);
46 this.review = review;
47 }
48
49 public GeneralSectionNode(GeneralSectionNode node) {
50 super(node.getAtlassianClickAction());
51 this.review = node.review;
52 }
53
54 @Override
55 public TreeCellRenderer getTreeCellRenderer() {
56 return MY_RENDERER;
57 }
58
59 public ReviewData getReview() {
60 return review;
61 }
62
63 public AtlassianTreeNode getClone() {
64 return new GeneralSectionNode(this);
65 }
66
67 private static class MyRenderer implements TreeCellRenderer {
68 public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected, boolean expanded,
69 boolean leaf, int row, boolean hasFocus) {
70 GeneralSectionNode node = (GeneralSectionNode) value;
71 JPanel panel = new JPanel(new FormLayout("4dlu, left:pref:grow, 4dlu", "4dlu, pref:grow, 4dlu"));
72 SimpleColoredComponent component = new SimpleColoredComponent();
73 component.append(GENERAL_COMMENTS_SECTION, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
74 panel.add(component, new CellConstraints(2, 2));
75
76 panel.setBorder(isSelected ? UIManager.getBorder("List.focusCellHighlightBorder")
77 : BorderFactory.createEmptyBorder(1, 1, 1, 1));
78
79 return panel;
80 }
81 }
82 }