use of org.knime.core.node.property.hilite.KeyEvent in project knime-core by knime.
the class TableContentModelTest method testResetHilite.
// testUnHilite()
/**
* Method being tested: resetHiLite().
*/
public final void testResetHilite() {
final HiLiteHandler hiliter = new HiLiteHandler();
final TableContentModel m = new TableContentModel(DATA, hiliter);
final JTable table = new JTable(m);
final ListSelectionModel listModel = table.getSelectionModel();
// make sure, the content model knows about ALL ROWS
m.getRow(OBJECT_DATA.length - 1);
assertEquals(table.getRowCount(), OBJECT_DATA.length);
// first: hilite all;
listModel.setSelectionInterval(0, OBJECT_DATA.length - 1);
m.requestHiLite(listModel);
flushEDTQueue();
for (int i = 0; i < OBJECT_DATA.length; i++) {
assertTrue(m.isHiLit(i));
}
// reset hilite
m.requestResetHiLite();
// hilite happens in EDT thread, this is executed in main - need to wait
ViewUtils.invokeAndWaitInEDT(new Runnable() {
@Override
public void run() {
// nothing, just run
}
});
for (int i = 0; i < OBJECT_DATA.length; i++) {
assertFalse(m.isHiLit(i));
}
int lucky = (int) (Math.random() * OBJECT_DATA.length);
listModel.setSelectionInterval(lucky, lucky);
m.requestHiLite(listModel);
flushEDTQueue();
m.setTableContentFilter(TableContentFilter.HiliteOnly);
// 0 should be ok, it returns the lucky row
m.getRow(0);
m.unHiLiteAll(new KeyEvent(this));
assertEquals(m.getRowCount(), 0);
}
Aggregations