use of javax.swing.event.TableModelEvent in project processdash by dtuma.
the class TaskScheduleDialog method handleEvNodeChanged.
private void handleEvNodeChanged(EVTask node) {
try {
TreePath tp = new TreePath(node.getPath());
int row = treeTable.getTree().getRowForPath(tp);
if (row != -1) {
AbstractTableModel model = (AbstractTableModel) treeTable.getModel();
model.fireTableChanged(new TableModelEvent(model, row));
}
} catch (Exception e) {
}
}
use of javax.swing.event.TableModelEvent in project processdash by dtuma.
the class DataTableModel method recalcColumn.
/** Recalculate a column.
*
* If the column depends upon any other dirty columns, they will be
* recalculated first. The waitingColumns parameter is used to detect
* circular dependencies and avoid infinite recursion.
*
* @param column the column to recalculate.
* @param waitingColumns a list of columns that are waiting on this
* column before they can recalculate.
*/
private void recalcColumn(CalculatedDataColumn column, Set waitingColumns) {
// if this column somehow isn't dirty anymore, do nothing.
if (dirtyColumns.contains(column) == false)
return;
// detect circular dependencies and abort.
if (waitingColumns.contains(column)) {
System.out.println("Circular column dependency:" + waitingColumns);
return;
}
int columnPos = findIndexOfColumn(column);
if (columnPos != -1)
try {
waitingColumns.add(column);
// to calculate them first.
for (int j = columns.size(); j-- > 0; ) if (dependencies[columnPos][j]) {
DataColumn dependentColumn = getColumn(j);
if (dependentColumn instanceof CalculatedDataColumn)
recalcColumn((CalculatedDataColumn) dependentColumn, waitingColumns);
}
} finally {
waitingColumns.remove(column);
}
// recalculate the column
if (column.recalculate()) {
// if data changed, fire an appropriate table model event.
TableModelEvent e = new TableModelEvent(this, 0, getRowCount() - 1, columnPos, TableModelEvent.UPDATE);
fireTableChanged(e);
}
// remove this column from the "dirty" list.
dirtyColumns.remove(column);
}
use of javax.swing.event.TableModelEvent in project processdash by dtuma.
the class TimeLogTableModelTest method assertTableModelEvent.
public void assertTableModelEvent(int type, int firstRow, int lastRow, int col) {
assertFalse("expected to find an event", tableModelEventsReceived.isEmpty());
Object evt = tableModelEventsReceived.remove(0);
assertTrue("event should be a TableModelEvent", evt instanceof TableModelEvent);
TableModelEvent e = (TableModelEvent) evt;
assertSame(tableModel, e.getSource());
assertEquals(type, e.getType());
assertEquals(firstRow, e.getFirstRow());
assertEquals(lastRow, e.getLastRow());
assertEquals(col, e.getColumn());
}
use of javax.swing.event.TableModelEvent in project processdash by dtuma.
the class EVSchedule method insertRow.
public synchronized void insertRow(int row) {
Period r = get(row + 1);
if (r == null)
return;
Date midpoint = new Date((r.getEndDate().getTime() + r.getBeginDate().getTime()) / 2);
Period newPeriod = new Period(midpoint, 0.0);
newPeriod.previous = r.previous;
r.previous = newPeriod;
r.note = NOTE_NEEDS_CALC;
periods.add(row + 1, newPeriod);
r.clearAutomaticFlag();
// fire a "rows added" event.
fireTableChanged(new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT));
// signal the need to recalculate all the schedule data.
fireNeedsRecalc();
}
use of javax.swing.event.TableModelEvent in project processdash by dtuma.
the class DefectImportForm method createButtonBox.
private Box createButtonBox() {
JButton cancelButton = new JButton(resources.getString("Cancel"));
cancelButton.addActionListener((ActionListener) EventHandler.create(ActionListener.class, this, "cancel"));
final JButton importButton = new JButton(resources.getString("Import_Button"));
importButton.addActionListener((ActionListener) EventHandler.create(ActionListener.class, this, "doImport"));
importButton.setEnabled(false);
final BoundDefectData data = BoundDefectData.getDefectData(this);
data.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
importButton.setEnabled(data.hasSelectedDefects());
}
});
Box buttonBox = Box.createHorizontalBox();
buttonBox.add(Box.createHorizontalGlue());
buttonBox.add(cancelButton);
buttonBox.add(Box.createHorizontalStrut(10));
buttonBox.add(importButton);
buttonBox.setBorder(new EmptyBorder(10, 10, 10, 10));
return buttonBox;
}
Aggregations