package com.vci.client.portal.NewNewUI.Export;
|
|
import java.awt.Component;
|
|
import javax.swing.Icon;
|
import javax.swing.JTree;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
|
import com.vci.client.portal.NewNewUI.Export.BaseExportNode;
|
|
|
public class ExportTreeCellRenderer extends DefaultTreeCellRenderer {
|
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
|
// 设置节点样式
|
public ExportTreeCellRenderer() {
|
super();
|
}
|
|
@Override
|
public Component getTreeCellRendererComponent(JTree tree, Object value,
|
boolean sel, boolean expanded, boolean leaf, int row,
|
boolean hasFocus) {
|
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
|
row, hasFocus);
|
//设置节点icon
|
Icon closeIcon = this.getDefaultClosedIcon();
|
Icon leafIcon = this.getDefaultLeafIcon();
|
Icon openIcon = this.getDefaultOpenIcon();
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
|
if ( node.getUserObject() instanceof BaseExportNode) {
|
BaseExportNode baseExportNode = (BaseExportNode) node.getUserObject();
|
if (baseExportNode.getLeaf() == BaseExportNode.IS_NOT_LEAF) {
|
if(expanded){
|
this.setIcon(openIcon);
|
}else{
|
this.setIcon(closeIcon);
|
}
|
|
|
}else{
|
if (baseExportNode.getLeaf() == BaseExportNode.IS_LEAF) {
|
this.setIcon(leafIcon);
|
}
|
}
|
this.setForeground(baseExportNode.getFontColor());
|
if (baseExportNode.getLeaf() == BaseExportNode.IS_A_Message) {
|
this.setIcon(null);
|
}
|
}
|
|
|
|
return this;
|
}
|
|
}
|