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

package com.togethersoft.modules.xmleditor.xmlcomponent;

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

public class ElementButton extends JButton
{
  private DTDElementDef m_dtdElementDef;

  //--------------------------------------------------------------------
  public ElementButton (DTDElementDef elementDef)
  {
    super (elementDef.getFullName());
    m_dtdElementDef = elementDef;
  }

  //--------------------------------------------------------------------
  public DTDElementDef getElementDef()
  {
    return m_dtdElementDef;
  }

  //--------------------------------------------------------------------
  public void setButtonState (int elementAllowance)
  {
    switch (elementAllowance)
    {
      case ElementInst.NEA_REQUIRED:

        setEnabled (true);
        setForeground (Color.red);
        break;

      case ElementInst.NEA_ALLOWED:

        setEnabled (true);
        setForeground (Color.black);
        break;

      case ElementInst.NEA_PROHIBITED:

        setEnabled (false);
        break;
    }
  }
}
