@Override
public void listStructureChanged(StyleRules newStyleRules) {
int oldRowCount = styleRules.getPatternStyles().size();
int newRowCount = newStyleRules.getPatternStyles().size();
styleRules.removeListener(this);
styleRules = newStyleRules;
styleRules.addListener(this);
styleRules.removeStyleRuleListener(this);
styleRules.addStyleRuleListener(this);
if (oldRowCount > newRowCount) {
fireTableRowsDeleted(newRowCount, oldRowCount);
} else {
fireTableRowsInserted(oldRowCount, newRowCount);
}
int rowsToUpdate = Math.min(oldRowCount, newRowCount);
fireTableRowsUpdated(0, rowsToUpdate);
}