public void apply(CodeStyleSettings settings) {
    stopTableEditing();

    settings.LAYOUT_STATIC_IMPORTS_SEPARATELY = myImportLayoutPanel.areStaticImportsEnabled();
    settings.USE_FQ_CLASS_NAMES = myCbUseFQClassNames.isSelected();
    settings.USE_SINGLE_CLASS_IMPORTS = myCbUseSingleClassImports.isSelected();
    settings.INSERT_INNER_CLASS_IMPORTS = myCbInsertInnerClassImports.isSelected();
    try {
      settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND = Integer.parseInt(myClassCountField.getText());
    } catch (NumberFormatException e) {
      // just a bad number
    }
    try {
      settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND = Integer.parseInt(myNamesCountField.getText());
    } catch (NumberFormatException e) {
      // just a bad number
    }

    final PackageEntryTable list = myImportLayoutPanel.getImportLayoutList();
    list.removeEmptyPackages();
    settings.IMPORT_LAYOUT_TABLE.copyFrom(list);

    myPackageList.removeEmptyPackages();
    settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND.copyFrom(myPackageList);

    myFqnInJavadocOption.apply(settings);
  }
  public void reset(CodeStyleSettings settings) {
    myCbUseFQClassNames.setSelected(settings.USE_FQ_CLASS_NAMES);
    myCbUseSingleClassImports.setSelected(settings.USE_SINGLE_CLASS_IMPORTS);
    myCbInsertInnerClassImports.setSelected(settings.INSERT_INNER_CLASS_IMPORTS);
    myClassCountField.setText(Integer.toString(settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND));
    myNamesCountField.setText(Integer.toString(settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND));

    myImportLayoutPanel.getImportLayoutList().copyFrom(settings.IMPORT_LAYOUT_TABLE);
    myPackageList.copyFrom(settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND);
    myFqnInJavadocOption.reset(settings);

    myImportLayoutPanel
        .getCbLayoutStaticImportsSeparately()
        .setSelected(settings.LAYOUT_STATIC_IMPORTS_SEPARATELY);

    final JBTable importLayoutTable = myImportLayoutPanel.getImportLayoutTable();
    AbstractTableModel model = (AbstractTableModel) importLayoutTable.getModel();
    model.fireTableDataChanged();

    model = (AbstractTableModel) myPackageTable.getModel();
    model.fireTableDataChanged();

    if (importLayoutTable.getRowCount() > 0) {
      importLayoutTable.getSelectionModel().setSelectionInterval(0, 0);
    }
    if (myPackageTable.getRowCount() > 0) {
      myPackageTable.getSelectionModel().setSelectionInterval(0, 0);
    }
  }
 private void refreshTable(final JBTable table, final PackageEntryTable packageTable) {
   AbstractTableModel model = (AbstractTableModel) table.getModel();
   table.createDefaultColumnsFromModel();
   model.fireTableDataChanged();
   ImportLayoutPanel.resizeColumns(
       packageTable, table, myImportLayoutPanel.areStaticImportsEnabled());
 }
  public boolean isModified(CodeStyleSettings settings) {
    boolean isModified =
        isModified(
            myImportLayoutPanel.getCbLayoutStaticImportsSeparately(),
            settings.LAYOUT_STATIC_IMPORTS_SEPARATELY);
    isModified |= isModified(myCbUseFQClassNames, settings.USE_FQ_CLASS_NAMES);
    isModified |= myFqnInJavadocOption.isModified(settings);
    isModified |= isModified(myCbUseSingleClassImports, settings.USE_SINGLE_CLASS_IMPORTS);
    isModified |= isModified(myCbInsertInnerClassImports, settings.INSERT_INNER_CLASS_IMPORTS);
    isModified |= isModified(myClassCountField, settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND);
    isModified |= isModified(myNamesCountField, settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND);

    isModified |=
        isModified(myImportLayoutPanel.getImportLayoutList(), settings.IMPORT_LAYOUT_TABLE);
    isModified |= isModified(myPackageList, settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND);

    return isModified;
  }
 private void createPackagePanel() {
   myPackageTable =
       ImportLayoutPanel.createTableForPackageEntries(myPackageList, myImportLayoutPanel);
   myPackagesPanel.add(
       PackagePanel.createPackagesPanel(myPackageTable, myPackageList), BorderLayout.CENTER);
 }
 private void stopTableEditing() {
   TableUtil.stopEditing(myImportLayoutPanel.getImportLayoutTable());
   TableUtil.stopEditing(myPackageTable);
 }