package osa.attribute.atgrammar.gui.tables.attributes_table;

import java.util.*;

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import javax.swing.JTable;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class AttributesTable
  extends JTable
  {
  ArrayList list_selection_listeners;

  public AttributesTable()
    {
    super();
    setDefaultEditor(Object.class,new AttributesTCE());
    setDefaultRenderer(Object.class,new AttributesTCR());
    setRowHeight(20);
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }


  public void addListSelectionListener(ListSelectionListener l)
    {
    list_selection_listeners.add(l);
    }

  public void removeListSelectionListener(ListSelectionListener l)
    {
    list_selection_listeners.remove(l);
    }

  public void valueChanged(ListSelectionEvent e)
    {

    super.valueChanged(e);

    if(list_selection_listeners==null)
      {
      list_selection_listeners=new ArrayList();
      }

    int size=list_selection_listeners.size();
    System.err.println("listeners size="+size);
    for(int i=0;i<size;i++)
       {
       System.err.println("invoke listeners!!!");
       ((ListSelectionListener)list_selection_listeners.get(i)).valueChanged(e);
       }
    }


  }