01: /*
02: *
03: * (c) Copyright 2004 - 2007 osbl development team.
04: *
05: * This file is part of the osbl (http://osbl.wilken.de).
06: *
07: * the osbl is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.osbl.client.wings.navigation;
15:
16: import org.wings.SComponent;
17: import org.wings.STree;
18: import org.wings.tree.SDefaultTreeCellRenderer;
19:
20: import javax.swing.*;
21: import javax.swing.tree.DefaultMutableTreeNode;
22:
23: /**
24: * @author hengels
25: * @version $Revision: 1.1 $
26: */
27: public class NavigationTreeCellRenderer extends
28: SDefaultTreeCellRenderer {
29: public SComponent getTreeCellRendererComponent(STree tree,
30: Object value, boolean selected, boolean expanded,
31: boolean leaf, int row, boolean hasFocus) {
32: super .getTreeCellRendererComponent(tree, value, selected,
33: expanded, leaf, row, hasFocus);
34:
35: if (value instanceof DefaultMutableTreeNode) {
36: DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value;
37: Object userObject = treeNode.getUserObject();
38: if (userObject instanceof Action) {
39: Action action = (Action) userObject;
40: if (action.getValue(Action.NAME) == null)
41: action.putValue(Action.NAME, action
42: .getValue(Action.ACTION_COMMAND_KEY));
43:
44: setText((String) action.getValue(Action.NAME));
45: setToolTipText((String) action
46: .getValue(Action.SHORT_DESCRIPTION));
47: }
48: }
49: setIcon(null);
50:
51: if (tree.getPathForRow(row).getPathCount() == 2) {
52: String text = getText();
53: if (text.startsWith("<html>"))
54: text = "<html><b>" + text.substring("<html>".length())
55: + "</b>";
56: else
57: text = "<html><b>" + text + "</b>";
58: setText(text);
59: }
60:
61: return this;
62: }
63: }
|