1 19 20 package org.netbeans.modules.xml.xam.ui.column; 21 22 import java.awt.Component ; 23 import javax.swing.JComponent ; 24 import javax.swing.JList ; 25 import org.netbeans.modules.xml.xam.ui.cookies.CountChildrenCookie; 26 import org.openide.awt.HtmlRenderer; 27 import org.openide.explorer.view.NodeRenderer; 28 import org.openide.explorer.view.Visualizer; 29 import org.openide.nodes.Node; 30 31 36 public class ColumnListCellRenderer extends NodeRenderer { 37 private static final long serialVersionUID = 1L; 38 39 public ColumnListCellRenderer() { 40 super(); 41 } 42 43 public Component getListCellRendererComponent(JList list, 44 Object value, int index, boolean selected, boolean focused) { 45 Component c = super.getListCellRendererComponent( 46 list, value, index, selected, focused); 47 if (c instanceof JComponent ) { 48 Node node = Visualizer.findNode(value); 52 boolean hasChildren = true; 53 CountChildrenCookie ccc = (CountChildrenCookie) node.getCookie( 54 CountChildrenCookie.class); 55 if (ccc != null) { 56 hasChildren = ccc.getChildCount() > 0; 57 } 58 ArrowBorder border = new ArrowBorder(hasChildren); 59 JComponent jc = (JComponent ) c; 60 jc.setBorder(border); 61 } 62 if (c instanceof HtmlRenderer.Renderer) { 63 HtmlRenderer.Renderer hr = (HtmlRenderer.Renderer) c; 65 hr.setRenderStyle(HtmlRenderer.STYLE_TRUNCATE); 66 } 67 return c; 68 } 69 } 70 | Popular Tags |