Search in sources :

Example 56 with TableModelListener

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

the class CustomLayersTableModel method swap.

/**
 * Swap two layers.
 *
 * @param rowIndex1 The index of the first layer.
 * @param rowIndex2 The index of the second layer.
 */
public void swap(int rowIndex1, int rowIndex2) {
    if (isHeaderRow(rowIndex1) || isHeaderRow(rowIndex2)) {
        throw new IllegalStateException("Cannot swap with header rows");
    }
    CustomLayer layer = customLayers.get(rowIndex1);
    customLayers.set(rowIndex1, customLayers.get(rowIndex2));
    customLayers.set(rowIndex2, layer);
    orderPristine = false;
    TableModelEvent event = new TableModelEvent(this, Math.min(rowIndex1, rowIndex2), Math.max(rowIndex1, rowIndex2));
    for (TableModelListener listener : listeners) {
        listener.tableChanged(event);
    }
}
Also used : CustomLayer(org.pepsoft.worldpainter.layers.CustomLayer) TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Example 57 with TableModelListener

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

the class CoderRelationTableModel method clear.

public void clear() {
    Dna.data.getCoderRelations().clear();
    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 58 with TableModelListener

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

the class StatementTableModel method remove.

public void remove(int index) {
    Dna.data.getStatements().remove(index);
    TableModelEvent e = new TableModelEvent(this);
    for (int j = 0, n = listeners.size(); j < n; j++) {
        ((TableModelListener) listeners.get(j)).tableChanged(e);
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Example 59 with TableModelListener

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

the class DocumentTableModel method setValueAt.

public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    Document document = Dna.data.getDocuments().get(rowIndex);
    switch(columnIndex) {
        case 0:
            document.setId((Integer) aValue);
            break;
        case 1:
            document.setTitle((String) aValue);
            break;
        case 3:
            document.setDate((Date) aValue);
            break;
        case 4:
            document.setDate((Date) aValue);
            break;
        case 5:
            document.setCoder(((Coder) aValue).getId());
            break;
        case 6:
            document.setAuthor((String) aValue);
            break;
        case 7:
            document.setSource((String) aValue);
            break;
        case 8:
            document.setSection((String) aValue);
            break;
        case 9:
            document.setType((String) aValue);
            break;
        case 10:
            document.setNotes((String) aValue);
            break;
    }
    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) Document(dna.dataStructures.Document)

Example 60 with TableModelListener

use of javax.swing.event.TableModelListener in project CodenameOne by codenameone.

the class MultiImageSVGEditor method setImage.

public void setImage(com.codename1.ui.Image img) {
    com.codename1.impl.javase.SVG s = (com.codename1.impl.javase.SVG) img.getSVGDocument();
    if (s.getDpis() != null) {
        for (int iter = 0; iter < dpiTable.getRowCount(); iter++) {
            dpiTable.setValueAt(Boolean.FALSE, iter, 1);
        }
        for (int iter = 0; iter < s.getDpis().length; iter++) {
            int row = getDPIRow(s.getDpis()[iter]);
            dpiTable.setValueAt(Boolean.TRUE, row, 1);
            dpiTable.setValueAt(s.getWidthForDPI()[iter], row, 2);
            dpiTable.setValueAt(s.getHeightForDPI()[iter], row, 3);
        }
    }
    renderer = new CodenameOneImageRenderer(img);
    preview.removeAll();
    preview.add(BorderLayout.CENTER, renderer);
    preview.revalidate();
    dpiTable.getModel().addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            updateSVGImage();
        }
    });
}
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