/*------------------------------------------------------------------------------------
Copyright (c)2000 TogetherSoft Corporation. Patents pending. All rights reserved. 
------------------------------------------------------------------------------------*/ 

package com.togethersoft.modules.xmleditor.xmlcomponent;

import javax.swing.*;
import javax.swing.tree.*;
import java.awt.*;
import java.util.*;
import com.togethersoft.modules.xmleditor.xmltree.*;


public class XMLTreeCellRenderer extends DefaultTreeCellRenderer
{
  //--------------------------------------------------------------------
  public Component getTreeCellRendererComponent (JTree tree, Object value,
                                                 boolean sel, boolean expanded,
                                                 boolean leaf, int row, boolean hasFocus)
  {
    Component comp = super.getTreeCellRendererComponent (tree, value, sel, expanded, leaf, row, hasFocus);

    NodeManager nodeManager = (NodeManager) ((DefaultMutableTreeNode) value).getUserObject();
    ElementInst elementInst = nodeManager.getElementInst();

    ((JComponent)comp).setToolTipText (elementInst.getDisplayName());

    if (! elementInst.isComplete())
      comp.setForeground (Color.red);

    return comp;
  }
}
