Search in sources :

Example 26 with TableModelListener

use of javax.swing.event.TableModelListener in project dna by leifeld.

the class DocumentTableModel method addDocument.

public void addDocument(Document document) {
    int id = document.getId();
    Dna.data.getDocuments().add(document);
    sort();
    int index = getModelIndexById(id);
    // notify all listeners
    TableModelEvent e = new TableModelEvent(this, index, index, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT);
    for (int i = 0, n = listeners.size(); i < n; i++) {
        ((TableModelListener) listeners.get(i)).tableChanged(e);
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Example 27 with TableModelListener

use of javax.swing.event.TableModelListener in project dna by leifeld.

the class DocumentTableModel method remove.

public void remove(int index, boolean alsoStatements) {
    if (alsoStatements == true) {
        int id = Dna.data.getDocuments().get(index).getId();
        for (int i = Dna.data.getStatements().size() - 1; i > -1; i--) {
            if (Dna.data.getStatements().get(i).getDocumentId() == id) {
                Dna.data.getStatements().remove(i);
            }
        }
        Dna.dna.gui.rightPanel.statementPanel.statementTable.updateUI();
    }
    Dna.data.getDocuments().remove(index);
    TableModelEvent e = new TableModelEvent(this);
    for (int i = 0, n = listeners.size(); i < n; i++) {
        ((TableModelListener) listeners.get(i)).tableChanged(e);
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Example 28 with TableModelListener

use of javax.swing.event.TableModelListener in project WorldPainter by Captain-Chaos.

the class CombinedLayerTableModel method addRow.

void addRow(Row row) {
    rows.add(row);
    TableModelEvent event = new TableModelEvent(this, rows.size() - 1, rows.size() - 1, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT);
    for (TableModelListener listener : listeners) {
        listener.tableChanged(event);
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Example 29 with TableModelListener

use of javax.swing.event.TableModelListener in project WorldPainter by Captain-Chaos.

the class CombinedLayerTableModel method deleteRow.

void deleteRow(int rowIndex) {
    rows.remove(rowIndex);
    TableModelEvent event = new TableModelEvent(this, rowIndex, rowIndex, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE);
    for (TableModelListener listener : listeners) {
        listener.tableChanged(event);
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Example 30 with TableModelListener

use of javax.swing.event.TableModelListener in project WorldPainter by Captain-Chaos.

the class TunnelFloorLayersTableModel method addLayer.

public void addLayer(Layer layer) {
    if (!layers.contains(layer)) {
        layers.add(layer);
        settings.put(layer, new TunnelLayer.LayerSettings());
        int row = layers.size() - 1;
        TableModelEvent event = new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT);
        for (TableModelListener listener : listeners) {
            listener.tableChanged(event);
        }
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Aggregations

TableModelListener (javax.swing.event.TableModelListener)68 TableModelEvent (javax.swing.event.TableModelEvent)54 JScrollPane (javax.swing.JScrollPane)11 Iterator (java.util.Iterator)9 JTable (javax.swing.JTable)9 ListSelectionEvent (javax.swing.event.ListSelectionEvent)9 ActionEvent (java.awt.event.ActionEvent)8 ListSelectionListener (javax.swing.event.ListSelectionListener)8 Dimension (java.awt.Dimension)7 ActionListener (java.awt.event.ActionListener)7 JButton (javax.swing.JButton)7 JPanel (javax.swing.JPanel)7 DefaultTableModel (javax.swing.table.DefaultTableModel)6 TableColumn (javax.swing.table.TableColumn)6 ArrayList (java.util.ArrayList)5 GridBagConstraints (java.awt.GridBagConstraints)4 KeyShortcut (com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut)3 BorderLayout (java.awt.BorderLayout)3 Insets (java.awt.Insets)3 MouseAdapter (java.awt.event.MouseAdapter)3