01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * See the License for the specific language governing rights and
10: * limitations under the License.
11: *
12: * The Initial Developer of the Original Code is Simulacra Media Ltd.
13: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14: *
15: * All Rights Reserved.
16: *
17: * Contributor(s):
18: */
19: package org.openharmonise.him.serverconfig.permissions.tree;
20:
21: import java.awt.Component;
22:
23: import javax.swing.JLabel;
24: import javax.swing.JTree;
25: import javax.swing.tree.DefaultTreeCellRenderer;
26:
27: import org.openharmonise.vfs.gui.*;
28:
29: /**
30: * Tree node cell renderer for the permissions tree.
31: *
32: * @author Matthew Large
33: * @version $Revision: 1.1 $
34: *
35: */
36: public class PermissionsTreeCellRenderer extends
37: DefaultTreeCellRenderer {
38:
39: /**
40: * Constructs a new permissions tree cell renderer.
41: */
42: public PermissionsTreeCellRenderer() {
43: super ();
44: setOpenIcon(IconManager.getInstance().getIcon(
45: "16-section-open.gif"));
46: setClosedIcon(IconManager.getInstance().getIcon(
47: "16-section.gif"));
48: setLeafIcon(IconManager.getInstance()
49: .getIcon("16-document.gif"));
50: }
51:
52: /* (non-Javadoc)
53: * @see javax.swing.tree.TreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
54: */
55: public Component getTreeCellRendererComponent(JTree tree,
56: Object value, boolean selected, boolean expanded,
57: boolean leaf, int row, boolean hasFocus) {
58: Component rtnLabel = (JLabel) super
59: .getTreeCellRendererComponent(tree, value, selected,
60: expanded, leaf, row, hasFocus);
61:
62: if (value instanceof PermissionsTreeNode) {
63: if (((PermissionsTreeNode) value).isLeaf()) {
64: PermissionsTreeCell cell = new PermissionsTreeCell(
65: ((PermissionsTreeNode) value),
66: ((PermissionsTreeNode) value)
67: .getDisplayIcon(expanded),
68: ((PermissionsTreeNode) value).getDisplayName());
69: return cell;
70: } else {
71: PermissionsTreeCell cell = new PermissionsTreeCell(
72: ((PermissionsTreeNode) value),
73: ((PermissionsTreeNode) value)
74: .getDisplayIcon(expanded),
75: ((PermissionsTreeNode) value).getDisplayName());
76: return cell;
77: }
78: }
79:
80: return rtnLabel;
81: }
82:
83: }
|