package org.helioviewer.jhv.data.guielements.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import org.helioviewer.jhv.data.datatype.event.JHVEventParameter;

/**
 * The model for parameter table panel.
 *
 * @author Bram Bourgoignie (Bram.Bourgoignie@oma.be)
 *
 */
@SuppressWarnings({ "serial" })
public class ParameterTableModel extends AbstractTableModel {

    /** The parameters in this model */
    private final List<JHVEventParameter> parameters;

    /**
     * Creates a parameter model for the given parameters.
     *
     * @param parameters
     *            the parameters
     */
    public ParameterTableModel(Collection<JHVEventParameter> parameters) {
        super();
        this.parameters = new ArrayList<JHVEventParameter>();
        this.parameters.addAll(parameters);
    }

    @Override
    public int getRowCount() {
        return parameters.size();
    }

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

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        if (columnIndex == 1) {
            return String.class;
        } else {
            return super.getColumnClass(columnIndex);
        }
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        if (rowIndex < parameters.size()) {
            if (columnIndex == 0) {
                return parameters.get(rowIndex).getParameterDisplayName();
            } else if (columnIndex == 1) {
                String result = parameters.get(rowIndex).getDisplayParameterValue();
                if (result.length() > 100) {
                    return result.substring(0, 100) + "...";
                } else {
                    return result;
                }
            } else {
                return null;
            }
        } else {
            return null;
        }
    }

    @Override
    public String getColumnName(int column) {
        if (column == 0) {
            return "Parameter Name";
        } else if (column == 1) {
            return "Value";
        } else {
            return super.getColumnName(column);
        }
    }

}

@@ -370,18 +370,16 @@
 ngs(
-%7B 
 %22serial%22
  %7D)%0A
@@ -374,18 +374,16 @@
 %22serial%22
- %7D
 )%0Apublic
@@ -534,16 +534,67 @@
 eters;%0A%0A
+    private static final int STRING_CUTOFF = 256;%0A%0A
     /**%0A
@@ -1707,19 +1707,29 @@
 gth() %3E 
-100
+STRING_CUTOFF
 ) %7B%0A    
@@ -1775,11 +1775,21 @@
 (0, 
-100
+STRING_CUTOFF
 ) + 

Allow longer strings (for URLs)