KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > instrument > client > InstrumentManagerTreeCellRenderer


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package org.apache.excalibur.instrument.client;
21
22 import java.awt.Component JavaDoc;
23
24 import javax.swing.JTree JavaDoc;
25 import javax.swing.tree.DefaultMutableTreeNode JavaDoc;
26 import javax.swing.tree.DefaultTreeCellRenderer JavaDoc;
27
28 /**
29  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
30  */

31 class InstrumentManagerTreeCellRenderer
32     extends DefaultTreeCellRenderer JavaDoc
33 {
34     /*---------------------------------------------------------------
35      * Constructors
36      *-------------------------------------------------------------*/

37     InstrumentManagerTreeCellRenderer()
38     {
39     }
40     
41     /*---------------------------------------------------------------
42      * DefaultTreeCellRenderer Methods
43      *-------------------------------------------------------------*/

44     public Component JavaDoc getTreeCellRendererComponent( JTree JavaDoc tree,
45                                                    Object JavaDoc value,
46                                                    boolean sel,
47                                                    boolean expanded,
48                                                    boolean leaf,
49                                                    int row,
50                                                    boolean hasFocus)
51     {
52         super.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, hasFocus );
53         
54         /*
55         System.out.println("InstrumentManagerTreeCellRenderer.getTreeCellRendererComponent(tree, " +
56                             "value=" + value + ", sel=" + sel + ", expanded=" + expanded + ", leaf=" +
57                             leaf + ", row=" + row + ", focus=" + hasFocus + ") " +
58                             value.getClass().getName() );
59         */

60         if ( value instanceof DefaultMutableTreeNode JavaDoc )
61         {
62             DefaultMutableTreeNode JavaDoc treeNode = (DefaultMutableTreeNode JavaDoc)value;
63             Object JavaDoc userObject = treeNode.getUserObject();
64             
65             if ( userObject instanceof NodeData )
66             {
67                 NodeData nodeData = (NodeData)userObject;
68                 setIcon( nodeData.getIcon() );
69                 setToolTipText( nodeData.getToolTipText() );
70             }
71         }
72         
73         return this;
74     }
75     
76     /*---------------------------------------------------------------
77      * Methods
78      *-------------------------------------------------------------*/

79 }
80
Popular Tags