01: //$Header$
02: /*
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: */
19:
20: package org.apache.jmeter.report.gui.tree;
21:
22: import java.awt.Component;
23:
24: import javax.swing.ImageIcon;
25: import javax.swing.JTree;
26: import javax.swing.tree.DefaultTreeCellRenderer;
27:
28: /**
29: * @author Peter Lin
30: * @version $Revision: 493793 $
31: */
32: public class ReportCellRenderer extends DefaultTreeCellRenderer {
33: public ReportCellRenderer() {
34: }
35:
36: public Component getTreeCellRendererComponent(JTree tree,
37: Object value, boolean sel, boolean expanded, boolean leaf,
38: int row, boolean p_hasFocus) {
39: super .getTreeCellRendererComponent(tree,
40: ((ReportTreeNode) value).getName(), sel, expanded,
41: leaf, row, p_hasFocus);
42: boolean enabled = ((ReportTreeNode) value).isEnabled();
43: ImageIcon ic = ((ReportTreeNode) value).getIcon(enabled);
44: if (ic != null) {
45: if (enabled) {
46: setIcon(ic);
47: } else {
48: setDisabledIcon(ic);
49: }
50: } else {
51: if (!enabled)// i.e. no disabled icon found
52: {
53: // Must therefore set the enabled icon so there is at least some
54: // icon
55: ic = ((ReportTreeNode) value).getIcon();
56: if (ic != null)
57: setIcon(ic);
58: }
59: }
60: this.setEnabled(enabled);
61: return this;
62: }
63: }
|