1 13 package com.tonbeller.wcf.tree; 14 15 import org.w3c.dom.Document ; 16 import org.w3c.dom.Element ; 17 18 import com.tonbeller.wcf.controller.RequestContext; 19 20 24 public class DefaultNodeRenderer implements NodeRenderer { 25 protected String nodeElementName = DEFAULT_NODE_ELEMENT_NAME; 26 private LabelProvider labelProvider; 27 28 public DefaultNodeRenderer() { 29 labelProvider = new DefaultLabelProvider(); 30 } 31 32 public DefaultNodeRenderer(LabelProvider labelProvider) { 33 this.labelProvider = labelProvider; 34 } 35 36 public Element renderNode(RequestContext context, Document factory, Object node) { 37 Element nodeElem = factory.createElement(nodeElementName); 38 nodeElem.setAttribute("label", labelProvider.getLabel(node)); 39 return nodeElem; 40 } 41 42 46 public String getNodeElementName() { 47 return nodeElementName; 48 } 49 50 54 public void setNodeElementName(String nodeElementName) { 55 this.nodeElementName = nodeElementName; 56 } 57 58 61 public LabelProvider getLabelProvider() { 62 return labelProvider; 63 } 64 67 public void setLabelProvider(LabelProvider labelProvider) { 68 this.labelProvider = labelProvider; 69 } 70 } 71 | Popular Tags |