package kg.apc.jmeter.vizualizers;

import kg.apc.jmeter.charting.AbstractGraphRow;
import java.awt.Color;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableCellRenderer;
import org.apache.jorphan.gui.ObjectTableModel;
import org.apache.jorphan.reflect.Functor;

/**
 *
 * @author apc
 */
public class ChartRowsTable
     extends JTable
{
   TableCellRenderer colorRenderer = new ColorRenderer(false);

   /**
    *
    */
   public ChartRowsTable()
   {
      super();
      initializeTableModel();
      setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      getTableHeader().setDefaultRenderer(new HeaderAsTextRenderer());
      getTableHeader().addMouseListener(new HeaderClickCheckAllListener());
      getTableHeader().setReorderingAllowed(false);
      getTableHeader().setResizingAllowed(false);
      getColumnModel().getColumn(0).setPreferredWidth(100);
      getColumnModel().getColumn(1).setPreferredWidth(100);
      getColumnModel().getColumn(2).setPreferredWidth(500);

   }

   private void initializeTableModel()
   {
      ObjectTableModel model = new ObjectTableModel(new String[]
           {
              "(Un)Check All",
              "Legend Color",
              "Row Name"
           }, AbstractGraphRow.class, new Functor[]
           {
              new Functor("isDrawOnChart"),
              new Functor("getColor"),
              new Functor("getLabel")
           }, new Functor[]
           {
              new Functor("setDrawOnChart"),
              null,
              null
           }, new Class[]
           {
              Boolean.class,
              Color.class,
              String.class
           });
      setModel(model);
   }

   /**
    *
    * @param row
    */
   public void addRow(AbstractGraphRow row)
   {
      ((ObjectTableModel) dataModel).addRow(row);
   }

   @Override
   public TableCellRenderer getCellRenderer(int row, int column)
   {
      if ((column == 1))
      {
         return colorRenderer;
      }
      return super.getCellRenderer(row, column);
   }

   /**
    * 
    */
   public void clear()
   {
      initializeTableModel();
   }
}

@@ -840,32 +840,100 @@
 gAllowed(false);
+%0A%0A      setCollumnsSize();%0A   %7D%0A%0A   private void setCollumnsSize() %7B
 %0A      getColumn
@@ -1097,17 +1097,16 @@
 h(500);%0A
-%0A
    %7D%0A%0A  
@@ -2215,19 +2215,44 @@
 bleModel();%0A
+      setCollumnsSize();%0A
    %7D%0A%7D%0A

Fix Clear all and collumn width reset