Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmacher committed May 28, 2024
1 parent f1ec4ba commit 599a1d3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ private RowObjectFilterModel<Integer> createTableModelWithNewlines() {
testTableModel.addColumn("Name",
new String[] { "Hello World\n", "\nHello World", "Hello\nWorld", "Hello World" });

testTableModel.addColumn("Long ID",
new Long[] { 1000l, 2000l, 3000l });
testTableModel.addColumn("Long ID", new Long[] { 1000l, 2000l, 3000l });

return new TableModelWrapper<>(testTableModel);
}
Expand Down Expand Up @@ -775,18 +774,22 @@ private void addOrFilter(String columnName, String constraintName, String constr

private void addFilter(String columnName, String constraintName, String constraintValue,
LogicOperation logicOperation, boolean first) {
DialogFilterRow filterRow = createFilterRow(logicOperation, first);
ColumnFilterData<?> columnData = getColumnFilterData(columnName);
filterRow.setColumnData(columnData);
List<DialogFilterCondition<?>> conditions = filterRow.getFilterConditions();
DialogFilterCondition<?> condition = conditions.get(0);
condition.setSelectedConstraint(constraintName);
condition.setValue(constraintValue, null);

// Many of the hasValidValue() implementations compare against a GUI component that
// doesn't get built without these calls.
condition.getInlineEditorComponent();
condition.getDetailEditorComponent();

runSwing(() -> {
DialogFilterRow filterRow = createFilterRow(logicOperation, first);
ColumnFilterData<?> columnData = getColumnFilterData(columnName);
filterRow.setColumnData(columnData);
List<DialogFilterCondition<?>> conditions = filterRow.getFilterConditions();
DialogFilterCondition<?> condition = conditions.get(0);
condition.setSelectedConstraint(constraintName);
condition.setValue(constraintValue, null);

// Many of the hasValidValue() implementations compare against a GUI component that
// doesn't get built without these calls.
condition.getInlineEditorComponent();
condition.getDetailEditorComponent();
});

}

private DialogFilterRow createFilterRow(LogicOperation logicalOp, boolean first) {
Expand All @@ -799,8 +802,10 @@ private DialogFilterRow createFilterRow(LogicOperation logicalOp, boolean first)
}

private void applyFilter() {
ColumnBasedTableFilter<Integer> tableColumnFilter = filterModel.getTableColumnFilter();
tableModel.setTableFilter(tableColumnFilter);
runSwing(() -> {
ColumnBasedTableFilter<Integer> tableColumnFilter = filterModel.getTableColumnFilter();
tableModel.setTableFilter(tableColumnFilter);
});
}

private ColumnFilterData<?> getColumnFilterData(String columnName) {
Expand All @@ -816,31 +821,34 @@ private ColumnFilterData<?> getColumnFilterData(String columnName) {
private void addConstraints(String columnName, String[] constraintNames,
String[] constraintValues, boolean first) {

DialogFilterRow filterRow = createFilterRow(LogicOperation.AND, first);
ColumnFilterData<?> columnData = getColumnFilterData(columnName);
filterRow.setColumnData(columnData);

// set the first one
List<DialogFilterCondition<?>> conditions = filterRow.getFilterConditions();
DialogFilterCondition<?> condition = conditions.get(0);
condition.setSelectedConstraint(constraintNames[0]);
condition.setValue(constraintValues[0], null);

// Many of the hasValidValue() implementations compare against a GUI component that
// doesn't get built without these calls.
condition.getInlineEditorComponent();
condition.getDetailEditorComponent();
runSwing(() -> {
DialogFilterRow filterRow = createFilterRow(LogicOperation.AND, first);
ColumnFilterData<?> columnData = getColumnFilterData(columnName);
filterRow.setColumnData(columnData);

for (int i = 1; i < constraintNames.length; i++) {
DialogFilterCondition<?> c = filterRow.addFilterCondition();
c.setSelectedConstraint(constraintNames[i]);
c.setValue(constraintValues[i], null);
// set the first one
List<DialogFilterCondition<?>> conditions = filterRow.getFilterConditions();
DialogFilterCondition<?> condition = conditions.get(0);
condition.setSelectedConstraint(constraintNames[0]);
condition.setValue(constraintValues[0], null);

// Many of the hasValidValue() implementations compare against a GUI component that
// doesn't get built without these calls.
c.getInlineEditorComponent();
c.getDetailEditorComponent();
}
condition.getInlineEditorComponent();
condition.getDetailEditorComponent();

for (int i = 1; i < constraintNames.length; i++) {
DialogFilterCondition<?> c = filterRow.addFilterCondition();
c.setSelectedConstraint(constraintNames[i]);
c.setValue(constraintValues[i], null);

// Many of the hasValidValue() implementations compare against a GUI component that
// doesn't get built without these calls.
c.getInlineEditorComponent();
c.getDetailEditorComponent();
}

});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@

import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.AbstractTableModel;

import docking.widgets.table.RowObjectTableModel;

/**
* Table model used by {@link ColumnTableFilterTest}
*/
class TestTableModel implements RowObjectTableModel<Integer> {
public class TestTableModel extends AbstractTableModel implements RowObjectTableModel<Integer> {

private List<ColumnTestData<?>> columns = new ArrayList<>();
private int rowCount = 0;
Expand Down

0 comments on commit 599a1d3

Please sign in to comment.