@Override public synchronized Object getValueAt(int rowIndex, int columnIndex) { StyleRule config = styleRules.getPatternStyles().get(rowIndex); return config; }
@Override public synchronized int getRowCount() { return styleRules.getPatternStyles().size(); }
public synchronized StyleRule getValueAt(int rowIndex) { return styleRules.getPatternStyles().get(rowIndex); }
private synchronized void firePatternChanged(StyleRule rule) { int row = styleRules.getPatternStyles().indexOf(rule); fireTableCellUpdated(row, 0); fireTableCellUpdated(row, 1); }
public void setActiveRule(StyleRule rule) { if (rule != null) { editPanel.unsetStyleRule(); configTable.clearSelection(); final int index = styleRules.getPatternStyles().indexOf(rule); if (index >= 0) { configTable.setRowSelectionInterval(index, index); } } } }
@Override public void actionPerformed(ActionEvent e) { editPanel.unsetStyleRule(); int selectedRow = configTable.getSelectedRow(); if (selectedRow != -1) { StyleRule rule = configTableModel.getValueAt(selectedRow); styleRules.moveUp(rule); int index = styleRules.getPatternStyles().indexOf(rule); configTable.clearSelection(); configTable.setRowSelectionInterval(index, index); } } }
@Override public void actionPerformed(ActionEvent e) { editPanel.unsetStyleRule(); int selectedRow = configTable.getSelectedRow(); if (selectedRow != -1) { StyleRule rule = configTableModel.getValueAt(selectedRow); styleRules.moveDown(rule); int index = styleRules.getPatternStyles().indexOf(rule); configTable.clearSelection(); configTable.setRowSelectionInterval(index, index); } } }
@Override public void listStructureChanged(StyleRules newStyleRules) { int oldRowCount = styleRules.getPatternStyles().size(); int newRowCount = newStyleRules.getPatternStyles().size(); styleRules.removeListener(this); styleRules = newStyleRules; styleRules.addListener(this); // Remove first since we do not want to be registered twice on old // rules. styleRules.removeStyleRuleListener(this); styleRules.addStyleRuleListener(this); // fireTableDataChanged() - Which would seem like the perfect event // messes up the selections in the table. TableRowsUpdated does not even // if we say that all rows are updated if (oldRowCount > newRowCount) { fireTableRowsDeleted(newRowCount, oldRowCount); } else { fireTableRowsInserted(oldRowCount, newRowCount); } int rowsToUpdate = Math.min(oldRowCount, newRowCount); fireTableRowsUpdated(0, rowsToUpdate); }