Search in sources :

Example 1 with KeyEvent

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);
}
Also used : KeyEvent(org.knime.core.node.property.hilite.KeyEvent) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) JTable(javax.swing.JTable) ListSelectionModel(javax.swing.ListSelectionModel)

Aggregations

JTable (javax.swing.JTable)1 ListSelectionModel (javax.swing.ListSelectionModel)1 HiLiteHandler (org.knime.core.node.property.hilite.HiLiteHandler)1 KeyEvent (org.knime.core.node.property.hilite.KeyEvent)1