Search in sources :

Example 1 with ObjectTableModel

use of org.apache.jorphan.gui.ObjectTableModel in project jmeter by apache.

the class TableEditor method initializeModel.

void initializeModel() {
    Object hdrs = descriptor.getValue(HEADERS);
    if (!(hdrs instanceof String[])) {
        throw new RuntimeException("attribute HEADERS must be a String array");
    }
    if (clazz == String.class) {
        model = new ObjectTableModel((String[]) hdrs, new Functor[0], new Functor[0], new Class[] { String.class });
    } else {
        Object value = descriptor.getValue(OBJECT_PROPERTIES);
        if (!(value instanceof String[])) {
            throw new RuntimeException("attribute OBJECT_PROPERTIES must be a String array");
        }
        String[] props = (String[]) value;
        Functor[] writers = new Functor[props.length];
        Functor[] readers = new Functor[props.length];
        Class<?>[] editors = new Class[props.length];
        int count = 0;
        for (String propName : props) {
            propName = propName.substring(0, 1).toUpperCase(Locale.ENGLISH) + propName.substring(1);
            writers[count] = createWriter(clazz, propName);
            readers[count] = createReader(clazz, propName);
            editors[count] = getArgForWriter(clazz, propName);
            count++;
        }
        model = new ObjectTableModel((String[]) hdrs, readers, writers, editors);
    }
    model.addTableModelListener(this);
    table = new JTable(model);
    JMeterUtils.applyHiDPI(table);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.addFocusListener(this);
}
Also used : JTable(javax.swing.JTable) ObjectTableModel(org.apache.jorphan.gui.ObjectTableModel) Functor(org.apache.jorphan.reflect.Functor)

Aggregations

JTable (javax.swing.JTable)1 ObjectTableModel (org.apache.jorphan.gui.ObjectTableModel)1 Functor (org.apache.jorphan.reflect.Functor)1