use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class TreeEnsembleLearnerNodeView method modelChangedInUI.
private void modelChangedInUI() {
assert SwingUtilities.isEventDispatchThread();
final MODEL nodeModel = getNodeModel();
TreeEnsembleModel ensembleModel = nodeModel.getEnsembleModel();
int nrModels = ensembleModel == null ? 0 : ensembleModel.getNrModels();
m_nrModelLabel.setText(nrModels + " model(s) in total");
int min = nrModels == 0 ? 0 : 1;
m_modelSpinner.setModel(new SpinnerNumberModel(min, min, nrModels, 1));
HiLiteHandler hdl = nodeModel.getInHiLiteHandler(0);
String warnMessage = nodeModel.getViewMessage();
if (warnMessage == null) {
m_warningLabel.setText(" ");
m_warningLabel.setVisible(false);
} else {
m_warningLabel.setText(warnMessage);
m_warningLabel.setVisible(true);
}
newHiliteHandler(hdl);
newModel(min - 1);
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class TableContentModelTest method testHilite.
/**
* Method being tested: hiLite(ListSelectionModel) and
* (implicitly) hiLite(KeyEvent).
*/
public final void testHilite() {
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);
// the hilite handler
for (int i = 0; i < OBJECT_DATA.length; i += 2) {
listModel.addSelectionInterval(i, i);
}
m.requestHiLite(listModel);
flushEDTQueue();
for (int i = 0; i < OBJECT_DATA.length; i++) {
boolean shouldBeHiLit = (i % 2 == 0);
boolean isHiLit = m.isHiLit(i);
assertEquals(shouldBeHiLit, isHiLit);
}
// add every third row to the selection.
for (int i = 0; i < OBJECT_DATA.length; i += 3) {
listModel.addSelectionInterval(i, i);
}
m.requestHiLite(listModel);
flushEDTQueue();
for (int i = 0; i < OBJECT_DATA.length; i++) {
boolean shouldBeHiLit = (i % 2 == 0) || (i % 3 == 0);
boolean isHiLit = m.isHiLit(i);
assertEquals(shouldBeHiLit, isHiLit);
}
// clearing the selection shouldn't have any effect
listModel.clearSelection();
for (int i = 0; i < OBJECT_DATA.length; i++) {
boolean shouldBeHiLit = (i % 2 == 0) || (i % 3 == 0);
boolean isHiLit = m.isHiLit(i);
assertEquals(shouldBeHiLit, isHiLit);
}
listModel.setSelectionInterval(0, OBJECT_DATA.length - 1);
m.requestHiLite(listModel);
flushEDTQueue();
for (int i = 0; i < OBJECT_DATA.length; i++) {
assertTrue(m.isHiLit(i));
}
try {
m.requestHiLite((ListSelectionModel) null);
fail("Expected " + NullPointerException.class + " not thrown");
} catch (NullPointerException e) {
NodeLogger.getLogger(getClass()).debug("Got expected exception: " + e.getClass().getName(), e);
}
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class TableContentModelTest method testTableContentModelDataTableHiLiteHandler.
// testTableContentModelDataTable()
/**
* Class under test for void TableContentModel(DataTable, HiLiteHandler).
*/
public final void testTableContentModelDataTableHiLiteHandler() {
HiLiteHandler handler = new HiLiteHandler();
final TableContentModel m2 = new TableContentModel(DATA, handler);
assertEquals("Col Count", m2.getColumnCount(), OBJECT_DATA[0].length);
assertTrue("Has Data", m2.hasData());
assertTrue("Has HiLiteHandler", m2.hasHiLiteHandler());
final TableContentModel m3 = new TableContentModel(null, handler);
assertFalse("Has Data", m3.hasData());
assertTrue("Has HiLiteHandler", m3.hasHiLiteHandler());
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class TableContentModelTest method testIsHiLit.
/**
* Method being tested: boolean isHiLit(int).
*/
public final void testIsHiLit() {
final HiLiteHandler hiliteHdl = new HiLiteHandler();
final TableContentModel m = new TableContentModel(DATA, hiliteHdl);
// hilite every other in DATA and check if it is correctly reflected
// in m
final HashSet<RowKey> set = new HashSet<RowKey>();
boolean isEvenNumber = true;
for (RowIterator it = DATA.iterator(); it.hasNext(); ) {
RowKey cell = it.next().getKey();
if (isEvenNumber) {
hiliteHdl.fireHiLiteEvent(cell);
set.add(cell);
}
isEvenNumber = !isEvenNumber;
}
flushEDTQueue();
for (int i = 0; i < m.getRowCount(); i++) {
RowKey key = m.getRow(i).getKey();
boolean isHiLit = m.isHiLit(i);
assertEquals(set.contains(key), isHiLit);
}
try {
m.isHiLit(-1);
fail("Expected " + IndexOutOfBoundsException.class + " not thrown");
} catch (IndexOutOfBoundsException e) {
NodeLogger.getLogger(getClass()).debug("Got expected exception: " + e.getClass().getName(), e);
}
try {
m.isHiLit(OBJECT_DATA.length);
fail("Expected " + IndexOutOfBoundsException.class + " not thrown");
} catch (IndexOutOfBoundsException e) {
NodeLogger.getLogger(getClass()).debug("Got expected exception: " + e.getClass().getName(), e);
}
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class TableContentModelTest method testUnHilite.
// testHilite()
/**
* Method being tested: unHiLite(ListSelectionModel)
* (implicitly) unHiLite(KeyEvent).
*/
public final void testUnHilite() {
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; unhilite subsequently
listModel.setSelectionInterval(0, OBJECT_DATA.length - 1);
m.requestHiLite(listModel);
flushEDTQueue();
for (int i = 0; i < OBJECT_DATA.length; i++) {
assertTrue(m.isHiLit(i));
}
listModel.clearSelection();
// the hilite handler
for (int i = 0; i < OBJECT_DATA.length; i += 2) {
listModel.addSelectionInterval(i, i);
}
m.requestUnHiLite(listModel);
flushEDTQueue();
for (int i = 0; i < OBJECT_DATA.length; i++) {
boolean shouldBeUnHiLit = (i % 2 == 0);
boolean isUnHiLit = !m.isHiLit(i);
assertEquals(shouldBeUnHiLit, isUnHiLit);
}
// remove every third row from the selection.
for (int i = 0; i < OBJECT_DATA.length; i += 3) {
listModel.addSelectionInterval(i, i);
}
m.requestUnHiLite(listModel);
flushEDTQueue();
for (int i = 0; i < OBJECT_DATA.length; i++) {
boolean shouldBeUnHiLit = (i % 2 == 0) || (i % 3 == 0);
boolean isUnHiLit = !m.isHiLit(i);
assertEquals(shouldBeUnHiLit, isUnHiLit);
}
// clearing the selection shouldn't have any effect
listModel.clearSelection();
for (int i = 0; i < OBJECT_DATA.length; i++) {
boolean shouldBeUnHiLit = (i % 2 == 0) || (i % 3 == 0);
boolean isUnHiLit = !m.isHiLit(i);
assertEquals(shouldBeUnHiLit, isUnHiLit);
}
listModel.setSelectionInterval(0, OBJECT_DATA.length - 1);
m.requestUnHiLite(listModel);
flushEDTQueue();
for (int i = 0; i < OBJECT_DATA.length; i++) {
assertFalse(m.isHiLit(i));
}
try {
m.requestUnHiLite((ListSelectionModel) null);
fail("Expected " + NullPointerException.class + " not thrown");
} catch (NullPointerException e) {
NodeLogger.getLogger(getClass()).debug("Got expected exception: " + e.getClass().getName(), e);
}
}
Aggregations