use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.
the class TableReorderManager method checkReorder.
private void checkReorder(TruthTableTableModel model) {
ArrayList<Variable> varList = model.getTable().getVars();
ArrayList<String> vars = new ArrayList<>();
ArrayList<String> results = new ArrayList<>();
boolean wasChange = false;
for (int i = 0; i < model.getColumnCount(); i++) {
String name = table.getTableHeader().getColumnModel().getColumn(i).getHeaderValue().toString();
if (!name.equals(table.getModel().getColumnName(i)))
wasChange = true;
BoolTable r = model.getTable().getResult(name);
if (r != null && varList.contains(new Variable(name)))
return;
if (r != null)
results.add(name);
else
vars.add(name);
}
if (wasChange) {
if (isVarChange(varList, vars)) {
try {
TruthTable tt = new ReorderInputs(model.getTable(), vars).reorder();
tableDialog.setModel(new TruthTableTableModel(tt));
} catch (ExpressionException e) {
// can't happen because no columns are removed
e.printStackTrace();
}
} else if (isResultChange(model.getTable(), results)) {
try {
TruthTable tt = new ReorderOutputs(model.getTable(), results).reorder();
tableDialog.setModel(new TruthTableTableModel(tt));
} catch (ExpressionException e) {
// can't happen because no columns are removed
e.printStackTrace();
}
} else
tableDialog.setModel(new TruthTableTableModel(model.getTable()));
}
}
Aggregations