Search in sources :

Example 31 with TableModelEvent

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) {
    }
}
Also used : TreePath(javax.swing.tree.TreePath) TableModelEvent(javax.swing.event.TableModelEvent) AbstractTableModel(javax.swing.table.AbstractTableModel) Point(java.awt.Point) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) MalformedURLException(java.net.MalformedURLException)

Example 32 with TableModelEvent

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);
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) NullDataColumn(teamdash.wbs.columns.NullDataColumn)

Example 33 with TableModelEvent

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());
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent)

Example 34 with TableModelEvent

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();
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) Date(java.util.Date)

Example 35 with TableModelEvent

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;
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener) JButton(javax.swing.JButton) Box(javax.swing.Box) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

TableModelEvent (javax.swing.event.TableModelEvent)35 TableModelListener (javax.swing.event.TableModelListener)15 DefaultTableModel (javax.swing.table.DefaultTableModel)6 ActionEvent (java.awt.event.ActionEvent)4 ActionListener (java.awt.event.ActionListener)4 ArrayList (java.util.ArrayList)4 JScrollPane (javax.swing.JScrollPane)4 TableColumn (javax.swing.table.TableColumn)4 JBTable (com.intellij.ui.table.JBTable)3 Dimension (java.awt.Dimension)3 GridBagConstraints (java.awt.GridBagConstraints)3 Insets (java.awt.Insets)3 JButton (javax.swing.JButton)3 JTable (javax.swing.JTable)3 ListSelectionEvent (javax.swing.event.ListSelectionEvent)3 ListSelectionListener (javax.swing.event.ListSelectionListener)3 GridBagLayout (java.awt.GridBagLayout)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 JComboBox (javax.swing.JComboBox)2 JPanel (javax.swing.JPanel)2