View Javadoc

1   /**
2    * Copyright (C) 2008 Atlassian
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.atlassian.theplugin.idea.crucible.tree;
17  
18  import com.atlassian.theplugin.crucible.model.CrucibleReviewListModel;
19  import com.atlassian.theplugin.idea.ui.tree.paneltree.AbstractTreeNode;
20  import com.atlassian.theplugin.idea.ui.tree.paneltree.SelectableLabel;
21  
22  import javax.swing.*;
23  
24  /**
25   * @author Jacek Jaroczynski
26   */
27  public class CrucibleMyReviewsTreeNode extends AbstractTreeNode {
28  	private static final String NAME = "All My Reviews";
29  	private final CrucibleReviewListModel reviewListModel;
30  
31  	public CrucibleMyReviewsTreeNode(CrucibleReviewListModel reviewListModel) {
32  		super(NAME, null, null);
33  		this.reviewListModel = reviewListModel;
34  	}
35  
36  	public String toString() {
37  		int cnt = reviewListModel.getPredefinedFiltersReviewCount();
38  		String txt = NAME;
39  		if (cnt > -1) {
40  			txt += " (" + cnt + ")";
41  		}
42  		return txt;
43  	}
44  
45  	public JComponent getRenderer(JComponent c, boolean selected, boolean expanded, boolean hasFocus) {
46  		String txt = selected ? "<html>" + toString() : NAME;
47  		return new SelectableLabel(selected, c.isEnabled(), c.getFont(), txt, ICON_HEIGHT);
48  	}
49  
50  	public void onSelect() {
51  	}
52  }