package comeon.ui.pictures;

import java.awt.BorderLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;

import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.beanutils.DynaProperty;

final class MetadataTable extends JPanel {
  private static final long serialVersionUID = 1L;
  
  public MetadataTable(final String directoryName, final DynaBean directoryContent) {
    super(new BorderLayout());
    final JLabel title = new JLabel(directoryName);
    this.add(title, BorderLayout.NORTH);
    final JTable table = new JTable(new Model(directoryContent));
    table.setCellSelectionEnabled(false);
    table.setColumnSelectionAllowed(false);
    this.add(table, BorderLayout.CENTER);
  }

  private static final class Model extends AbstractTableModel {
    private static final long serialVersionUID = 1L;

    private final DynaProperty[] properties;
    
    private final DynaBean content;
    
    private Model(final DynaBean directoryContent) {
      this.properties = directoryContent.getDynaClass().getDynaProperties();
      this.content = directoryContent;
    }

    @Override
    public int getRowCount() {
      return properties.length;
    }

    @Override
    public int getColumnCount() {
      return 2;
    }

    @Override
    public Object getValueAt(final int rowIndex, final int columnIndex) {
      final Object value;
      final DynaProperty property = this.properties[rowIndex];
      switch (columnIndex) {
      case 0:
        value = property.getName();
        break;
      case 1:
        value = content.get(property.getName());
        break;
      default:
         throw new IndexOutOfBoundsException("No such column: " + columnIndex); 
      }
      return value;
    }
    
  }
}

@@ -51,16 +51,43 @@
 rLayout;
+%0Aimport java.awt.Component;
 %0A%0Aimport
@@ -205,16 +205,67 @@
 leModel;
+%0Aimport javax.swing.table.DefaultTableCellRenderer;
 %0A%0Aimport
@@ -702,16 +702,21 @@
 ble(new 
+Table
 Model(di
@@ -828,79 +828,755 @@
    t
-his.add(table, BorderLayout.CENTER);%0A  %7D%0A%0A  private static final class 
+able.getColumnModel().getColumn(0).setCellRenderer(new TooltipCellRenderer());%0A    table.getColumnModel().getColumn(1).setCellRenderer(new TooltipCellRenderer());%0A    this.add(table, BorderLayout.CENTER);%0A  %7D%0A%0A  private static final class TooltipCellRenderer extends DefaultTableCellRenderer %7B%0A    private static final long serialVersionUID = 1L;%0A%0A    @Override%0A    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,%0A        int row, int column) %7B%0A      final JLabel comp = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);%0A      comp.setToolTipText(String.valueOf(value));%0A      return comp;%0A    %7D%0A  %7D%0A  %0A  private static final class Table
 Mode
@@ -1763,16 +1763,21 @@
 private 
+Table
 Model(fi

Add tooltip to metadata table