001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.window.swing;
020:
021: import java.awt.*;
022:
023: import javax.swing.*;
024:
025: import org.openharmonise.swing.FontManager;
026: import org.openharmonise.vfs.*;
027:
028: /**
029: *
030: * @author Matthew Large
031: * @version $Revision: 1.2 $
032: *
033: */
034: public class ResourcePathCellRenderer extends JLabel implements
035: ListCellRenderer {
036:
037: AbstractVirtualFileSystem m_vfs = null;
038:
039: private Color m_selectedColor = new Color(173, 169, 143);
040:
041: /**
042: *
043: */
044: public ResourcePathCellRenderer(AbstractVirtualFileSystem vfs) {
045: super ();
046: this .m_vfs = vfs;
047: }
048:
049: /* (non-Javadoc)
050: * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
051: */
052: public Component getListCellRendererComponent(JList arg0,
053: Object arg1, int nIndex, boolean isSelected,
054: boolean hasFocus) {
055:
056: if (arg1 instanceof SelfRenderListCell) {
057: Component comp = ((SelfRenderListCell) arg1)
058: .getRenderComponent(isSelected, hasFocus);
059: comp.setFont(FontManager.getInstance().getFont(
060: FontManager.FONT_RESOURCE_TITLE));
061: return comp;
062: } else {
063: String sPath = (String) arg1;
064: VirtualFileSystemView vfsView = this .m_vfs
065: .getVirtualFileSystemView();
066:
067: VirtualFile vfFile = this .m_vfs.getVirtualFile(sPath)
068: .getResource();
069: //
070: // String fontName = "Dialog";
071: // int fontSize = 11;
072: // Font font = new Font(fontName, Font.PLAIN, fontSize);
073: // this.setFont(font);
074:
075: this .setFont(FontManager.getInstance().getFont(
076: FontManager.FONT_RESOURCE_TITLE));
077:
078: this .setIcon(vfsView.getIcon(vfFile));
079: this .setText(vfsView.getDisplayName(vfFile));
080: this .setToolTipText(vfFile.getFullPath());
081:
082: this .setOpaque(true);
083: this.setBackground(Color.WHITE);
084: this.setBorder(BorderFactory.createLineBorder(Color.WHITE));
085: this.setBorder(BorderFactory.createLineBorder(Color.WHITE));
086:
087: if (isSelected) {
088: this.setBackground(m_selectedColor);
089: this.setBorder(BorderFactory
090: .createLineBorder(Color.BLACK));
091: }
092:
093: if (hasFocus) {
094: this.setBorder(BorderFactory
095: .createLineBorder(Color.BLACK));
096: }
097:
098: return this;
099: }
100: }
101:
102: }
|