1 19 package org.openharmonise.him.window.swing; 20 21 import java.awt.*; 22 23 import javax.swing.*; 24 25 import org.openharmonise.swing.FontManager; 26 import org.openharmonise.vfs.*; 27 28 29 35 public class ResourcePathCellRenderer extends JLabel implements ListCellRenderer { 36 37 AbstractVirtualFileSystem m_vfs = null; 38 39 private Color m_selectedColor = new Color(173,169,143); 40 41 42 45 public ResourcePathCellRenderer(AbstractVirtualFileSystem vfs) { 46 super(); 47 this.m_vfs = vfs; 48 } 49 50 53 public Component getListCellRendererComponent( 54 JList arg0, 55 Object arg1, 56 int nIndex, 57 boolean isSelected, 58 boolean hasFocus) { 59 60 if(arg1 instanceof SelfRenderListCell) { 61 Component comp = ((SelfRenderListCell)arg1).getRenderComponent(isSelected, hasFocus); 62 comp.setFont( FontManager.getInstance().getFont(FontManager.FONT_RESOURCE_TITLE) ); 63 return comp; 64 } else { 65 String sPath = (String )arg1; 66 VirtualFileSystemView vfsView = this.m_vfs.getVirtualFileSystemView(); 67 68 VirtualFile vfFile = this.m_vfs.getVirtualFile(sPath).getResource(); 69 75 this.setFont( FontManager.getInstance().getFont(FontManager.FONT_RESOURCE_TITLE) ); 76 77 this.setIcon( vfsView.getIcon(vfFile) ); 78 this.setText(vfsView.getDisplayName(vfFile)); 79 this.setToolTipText(vfFile.getFullPath()); 80 81 this.setOpaque(true); 82 this.setBackground(Color.WHITE); 83 this.setBorder(BorderFactory.createLineBorder(Color.WHITE)); 84 this.setBorder(BorderFactory.createLineBorder(Color.WHITE)); 85 86 if(isSelected) { 87 this.setBackground(m_selectedColor); 88 this.setBorder(BorderFactory.createLineBorder(Color.BLACK)); 89 } 90 91 if(hasFocus) { 92 this.setBorder(BorderFactory.createLineBorder(Color.BLACK)); 93 } 94 95 return this; 96 } 97 } 98 99 } 100 | Popular Tags |