View Javadoc

1   package com.atlassian.theplugin.idea.crucible.tree;
2   
3   import com.atlassian.theplugin.commons.crucible.api.model.CustomFilter;
4   import com.atlassian.theplugin.crucible.model.CrucibleReviewListModel;
5   import com.atlassian.theplugin.idea.ui.tree.paneltree.AbstractTreeNode;
6   import com.atlassian.theplugin.idea.ui.tree.paneltree.SelectableLabel;
7   
8   import javax.swing.*;
9   
10  /**
11   * User: pmaruszak
12   */
13  public class CrucibleCustomFilterTreeNode extends AbstractTreeNode {
14  	private CustomFilter filter;
15  	private final CrucibleReviewListModel reviewListModel;
16  
17  	private static final String NAME = "Custom Filter";
18  
19  	public CrucibleCustomFilterTreeNode(CustomFilter filter, CrucibleReviewListModel reviewListModel) {
20  		super(NAME, null, null);
21  		this.filter = filter;
22  		this.reviewListModel = reviewListModel;
23  	}
24  
25  	public String toString() {
26  		int cnt = reviewListModel.getReviewCount(filter);
27  		String txt = NAME;
28  		if (cnt > -1) {
29  			txt += " (" + cnt + ")";
30  		}
31  		return txt;
32  	}
33  
34  	public JComponent getRenderer(JComponent c, boolean selected, boolean expanded, boolean hasFocus) {
35  		return new SelectableLabel(selected, c.isEnabled(), c.getFont(), "<html>" + toString(), ICON_HEIGHT);
36  	}
37  
38  	public CustomFilter getFilter() {
39  		return filter;
40  	}
41  }