Search in sources :

Example 16 with AbstractTableModel

use of javax.swing.table.AbstractTableModel in project intellij-community by JetBrains.

the class ImportLayoutPanel method moveRowDown.

private void moveRowDown() {
    int selected = myImportLayoutTable.getSelectedRow();
    if (selected >= myImportLayoutList.getEntryCount() - 1) {
        return;
    }
    TableUtil.stopEditing(myImportLayoutTable);
    PackageEntry entry = myImportLayoutList.getEntryAt(selected);
    PackageEntry nextEntry = myImportLayoutList.getEntryAt(selected + 1);
    myImportLayoutList.setEntryAt(nextEntry, selected);
    myImportLayoutList.setEntryAt(entry, selected + 1);
    AbstractTableModel model = (AbstractTableModel) myImportLayoutTable.getModel();
    model.fireTableRowsUpdated(selected, selected + 1);
    myImportLayoutTable.setRowSelectionInterval(selected + 1, selected + 1);
}
Also used : PackageEntry(com.intellij.psi.codeStyle.PackageEntry) AbstractTableModel(javax.swing.table.AbstractTableModel)

Example 17 with AbstractTableModel

use of javax.swing.table.AbstractTableModel in project intellij-community by JetBrains.

the class EditMigrationDialog method addRow.

private void addRow() {
    EditMigrationEntryDialog dialog = new EditMigrationEntryDialog(myProject);
    MigrationMapEntry entry = new MigrationMapEntry();
    dialog.setEntry(entry);
    if (!dialog.showAndGet()) {
        return;
    }
    dialog.updateEntry(entry);
    myMigrationMap.addEntry(entry);
    AbstractTableModel model = (AbstractTableModel) myTable.getModel();
    model.fireTableRowsInserted(myMigrationMap.getEntryCount() - 1, myMigrationMap.getEntryCount() - 1);
    myTable.setRowSelectionInterval(myMigrationMap.getEntryCount() - 1, myMigrationMap.getEntryCount() - 1);
}
Also used : AbstractTableModel(javax.swing.table.AbstractTableModel)

Example 18 with AbstractTableModel

use of javax.swing.table.AbstractTableModel in project intellij-community by JetBrains.

the class EditMigrationDialog method removeRow.

private void removeRow() {
    int selected = myTable.getSelectedRow();
    if (selected < 0)
        return;
    myMigrationMap.removeEntryAt(selected);
    AbstractTableModel model = (AbstractTableModel) myTable.getModel();
    model.fireTableRowsDeleted(selected, selected);
    if (selected >= myMigrationMap.getEntryCount()) {
        selected--;
    }
    if (selected >= 0) {
        myTable.setRowSelectionInterval(selected, selected);
    }
}
Also used : AbstractTableModel(javax.swing.table.AbstractTableModel)

Example 19 with AbstractTableModel

use of javax.swing.table.AbstractTableModel in project intellij-community by JetBrains.

the class EditMigrationDialog method moveDown.

private void moveDown() {
    int selected = myTable.getSelectedRow();
    if (selected >= myMigrationMap.getEntryCount() - 1)
        return;
    MigrationMapEntry entry = myMigrationMap.getEntryAt(selected);
    MigrationMapEntry nextEntry = myMigrationMap.getEntryAt(selected + 1);
    myMigrationMap.setEntryAt(nextEntry, selected);
    myMigrationMap.setEntryAt(entry, selected + 1);
    AbstractTableModel model = (AbstractTableModel) myTable.getModel();
    model.fireTableRowsUpdated(selected, selected + 1);
    myTable.setRowSelectionInterval(selected + 1, selected + 1);
}
Also used : AbstractTableModel(javax.swing.table.AbstractTableModel)

Example 20 with AbstractTableModel

use of javax.swing.table.AbstractTableModel in project jdk8u_jdk by JetBrains.

the class ImageableAreaTest method createAuthorTable.

private static JTable createAuthorTable(int rows) {
    final String[] headers = { "Book", "Title" };
    final Object[][] data = new Object[rows][2];
    for (int i = 0; i < rows; i++) {
        int n = i + 1;
        data[i] = new Object[] { "Book: " + n, "Title: " + n };
    }
    TableModel dataModel = new AbstractTableModel() {

        public int getColumnCount() {
            return headers.length;
        }

        public int getRowCount() {
            return data.length;
        }

        public Object getValueAt(int row, int col) {
            return data[row][col];
        }

        public String getColumnName(int column) {
            return headers[column];
        }

        public Class getColumnClass(int col) {
            return getValueAt(0, col).getClass();
        }

        public void setValueAt(Object aValue, int row, int column) {
            data[row][column] = aValue;
        }

        public boolean isCellEditable(int row, int col) {
            return false;
        }
    };
    JTable table = new JTable(dataModel);
    table.setGridColor(Color.BLUE);
    table.setBackground(Color.WHITE);
    table.setForeground(Color.BLACK);
    table.setSize(600, 800);
    frame = new JFrame();
    frame.setSize(400, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(table);
    frame.setVisible(true);
    return table;
}
Also used : JFrame(javax.swing.JFrame) JTable(javax.swing.JTable) AbstractTableModel(javax.swing.table.AbstractTableModel) AbstractTableModel(javax.swing.table.AbstractTableModel) TableModel(javax.swing.table.TableModel)

Aggregations

AbstractTableModel (javax.swing.table.AbstractTableModel)24 TableModel (javax.swing.table.TableModel)6 PackageEntry (com.intellij.psi.codeStyle.PackageEntry)4 JBTable (com.intellij.ui.table.JBTable)3 JScrollPane (javax.swing.JScrollPane)3 JTable (javax.swing.JTable)3 JFrame (javax.swing.JFrame)2 TableModelEvent (javax.swing.event.TableModelEvent)2 TableRowSorter (javax.swing.table.TableRowSorter)2 FormBuilder (com.jgoodies.forms.builder.FormBuilder)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 MouseEvent (java.awt.event.MouseEvent)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 JButton (javax.swing.JButton)1 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)1