@Test public void testTableComparatorChooser() { EventList<Color> colors = GlazedLists.eventList(rgb); SortedList<Color> sortedColors = new SortedList<>(colors, null); TableFormat<Color> greenBlueTableFormat = GlazedLists.tableFormat(new String[] { "green", "blue" }, new String[] { "Green", "Blue" }); EventTableModel<Color> tableModel = new EventTableModel<>(colors, greenBlueTableFormat); JTable table = new JTable(tableModel); TableComparatorChooser<Color> tableComparatorChooser = TableComparatorChooser.install(table, sortedColors, TableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD); TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer(); clickColumnHeader(table, 0); assertEquals(rbg, sortedColors); clickColumnHeader(table, 1); assertEquals(rgb, sortedColors); headerRenderer.getTableCellRendererComponent(table, tableModel.getColumnName(0), false, false, 0, 0); final Component rendered = headerRenderer.getTableCellRendererComponent(table, tableModel.getColumnName(0), false, false, -1, -1); if (rendered instanceof JLabel) { assertNull(((JLabel) rendered).getIcon()); } tableComparatorChooser.dispose(); headerRenderer = table.getTableHeader().getDefaultRenderer(); clickColumnHeader(table, 0); assertEquals(rgb, sortedColors); clickColumnHeader(table, 1); assertEquals(rgb, sortedColors); headerRenderer.getTableCellRendererComponent(table, tableModel.getColumnName(0), false, false, 0, 0); headerRenderer.getTableCellRendererComponent(table, tableModel.getColumnName(0), false, false, 0, 1); TableFormat<Color> redGreenBlueTableFormat = GlazedLists.tableFormat(new String[] { "red", "green", "blue" }, new String[] { "Red", "Green", "Blue" }); tableModel.setTableFormat(redGreenBlueTableFormat); headerRenderer.getTableCellRendererComponent(table, tableModel.getColumnName(0), false, false, 0, 0); headerRenderer.getTableCellRendererComponent(table, tableModel.getColumnName(0), false, false, 0, 1); headerRenderer.getTableCellRendererComponent(table, tableModel.getColumnName(0), false, false, 0, 2); TableComparatorChooser.install(table, sortedColors, TableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD); sortedColors.setComparator(null); assertEquals(rgb, sortedColors); clickColumnHeader(table, 0); assertEquals(gbr, sortedColors); }
@Override public void dispose() { if (swingThreadSource != null) { swingThreadSource.dispose(); } swingThreadSource = null; super.dispose(); }
EventTableModel extends DefaultEventTableModel<E> { @Override public void dispose() { if (swingThreadSource != null) { swingThreadSource.dispose(); } swingThreadSource = null; super.dispose(); } }
EventTableModel extends DefaultEventTableModel<E> { @Override public void dispose() { if (swingThreadSource != null) { swingThreadSource.dispose(); } swingThreadSource = null; super.dispose(); } @Deprecated  EventTableModel(EventList<E> source, TableFormat<? super E> tableFormat); @Deprecated  EventTableModel(EventList<E> source, String[] propertyNames, String[] columnLabels, boolean[] writable); }
EventTableModel extends DefaultEventTableModel<E> { @Override public void dispose() { if (swingThreadSource != null) { swingThreadSource.dispose(); } swingThreadSource = null; super.dispose(); } @Deprecated  EventTableModel(EventList<E> source, TableFormat<? super E> tableFormat); @Deprecated  EventTableModel(EventList<E> source, String[] propertyNames, String[] columnLabels, boolean[] writable); @Override void dispose(); }
EventTableModel extends DefaultEventTableModel<E> { @Override public void dispose() { if (swingThreadSource != null) { swingThreadSource.dispose(); } swingThreadSource = null; super.dispose(); } @Deprecated  EventTableModel(EventList<E> source, TableFormat<? super E> tableFormat); @Deprecated  EventTableModel(EventList<E> source, String[] propertyNames, String[] columnLabels, boolean[] writable); @Override void dispose();  }