Search in sources :

Example 1 with SimpleTableModel

use of com.github.bordertech.wcomponents.SimpleTableModel in project wcomponents by BorderTech.

the class WTableRenderer_Test method createTableModelSortable.

/**
 * @return a test table model for sorting.
 */
private TableModel createTableModelSortable() {
    String[][] data = new String[][] { new String[] { "Joe2", "Bloggs2", "01/02/1971" }, new String[] { "Jane2", "Bloggs2", "04/05/1972" }, new String[] { "Abel2", "Bloggs2", "31/12/2000" } };
    SimpleTableModel model = new SimpleTableModel(data);
    // col 1 and 3 sortable
    model.setComparator(0, new StringComparator());
    // model.setComparator(1, new StringComparator());
    model.setComparator(2, new StringComparator());
    // sort on column1, descending - XTreeTableDataModel only
    model.sort(0, false);
    model.setEditable(true);
    return new AdapterBasicTableModel(model);
}
Also used : SimpleTableModel(com.github.bordertech.wcomponents.SimpleTableModel) AdapterBasicTableModel(com.github.bordertech.wcomponents.AdapterBasicTableModel)

Example 2 with SimpleTableModel

use of com.github.bordertech.wcomponents.SimpleTableModel in project wcomponents by BorderTech.

the class WTableRenderer_Test method createTableModel.

/**
 * @return a test table model.
 */
private TableModel createTableModel() {
    String[][] data = new String[][] { new String[] { "Joe", "Bloggs", "01/02/1973" }, new String[] { "Jane", "Bloggs", "04/05/1976" }, new String[] { "Kid", "Bloggs", "31/12/1999" } };
    SimpleTableModel model = new SimpleTableModel(data);
    model.setEditable(true);
    return new AdapterBasicTableModel(model);
}
Also used : SimpleTableModel(com.github.bordertech.wcomponents.SimpleTableModel) AdapterBasicTableModel(com.github.bordertech.wcomponents.AdapterBasicTableModel)

Example 3 with SimpleTableModel

use of com.github.bordertech.wcomponents.SimpleTableModel in project wcomponents by BorderTech.

the class TableContentExample method createTableModel.

/**
 * Creates a simple table data model containing some dummy data.
 *
 * @return a new data model.
 */
private TableModel createTableModel() {
    // String[][] data = new String[][]{};//{new String[]{"Row 1", "Row 1"}, new String[]{"Row 2", "Row 2"}, new String[]{"Row 3", "Row 3"}};
    int capcity = 100;
    List<String[]> list = new ArrayList<>();
    int i = 1;
    do {
        list.add(new String[] { "Row " + String.valueOf(i), "Row " + String.valueOf(i) });
    } while (++i <= capcity);
    String[][] data = list.toArray(new String[capcity][2]);
    return new AdapterBasicTableModel(new SimpleTableModel(data));
}
Also used : SimpleTableModel(com.github.bordertech.wcomponents.SimpleTableModel) AdapterBasicTableModel(com.github.bordertech.wcomponents.AdapterBasicTableModel) ArrayList(java.util.ArrayList)

Aggregations

AdapterBasicTableModel (com.github.bordertech.wcomponents.AdapterBasicTableModel)3 SimpleTableModel (com.github.bordertech.wcomponents.SimpleTableModel)3 ArrayList (java.util.ArrayList)1