001: /*
002: * PropsTreeCellRenderer.java
003: *
004: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package org.executequery.components.table;
023:
024: import java.awt.Component;
025: import java.awt.Color;
026: import java.awt.Font;
027:
028: import javax.swing.ImageIcon;
029: import javax.swing.JLabel;
030: import javax.swing.JTree;
031: import javax.swing.UIManager;
032: import javax.swing.tree.TreeCellRenderer;
033:
034: import org.executequery.Constants;
035: import org.executequery.GUIUtilities;
036:
037: /* ----------------------------------------------------------
038: * CVS NOTE: Changes to the CVS repository prior to the
039: * release of version 3.0.0beta1 has meant a
040: * resetting of CVS revision numbers.
041: * ----------------------------------------------------------
042: */
043:
044: /**
045: * Properties frame tree renderer.
046: * <P>
047: * @author Takis Diakoumis
048: * @version $Revision: 1.6 $
049: * @date $Date: 2006/09/06 09:30:58 $
050: */
051: public class PropsTreeCellRenderer extends JLabel implements
052: TreeCellRenderer {
053:
054: private Color textBackground;
055: private Color textForeground;
056: private Color selectionBackground;
057:
058: private Font font;
059:
060: private ImageIcon emptyImage;
061:
062: public PropsTreeCellRenderer() {
063: textBackground = UIManager.getColor("Tree.textBackground");
064: textForeground = UIManager.getColor("Tree.textForeground");
065: selectionBackground = UIManager
066: .getColor("Tree.selectionBackground");
067:
068: // smaller font
069: //font = new Font("Dialog", Font.PLAIN, 11);
070:
071: emptyImage = GUIUtilities.loadIcon("BlankTreeNode.gif", true);
072: setOpaque(true);
073: }
074:
075: public Component getTreeCellRendererComponent(JTree tree,
076: Object value, boolean bSelected, boolean bExpanded,
077: boolean bLeaf, int iRow, boolean bHasFocus) {
078:
079: String labelText = value.toString();
080:
081: setIcon(emptyImage);
082:
083: if (!bSelected) {
084: setBackground(textBackground);
085: setForeground(textForeground);
086: } else {
087: setBackground(selectionBackground);
088:
089: if (GUIUtilities.getLookAndFeel() == Constants.WIN_LAF) {
090: setForeground(Color.WHITE);
091: } else {
092: setForeground(textForeground);
093: }
094:
095: }
096:
097: // reset the font
098: //setFont(font);
099:
100: // Add the text to the cell
101: setText(labelText);
102: setIconTextGap(0);
103:
104: return this;
105: }
106:
107: }
|