public boolean finish() {
    boolean changed = false;
    List<String> activeStyles = activeStylesModel.getStyles();

    if (activeStyles.size() > 0) {
      if (Main.pref.putCollection(pref, activeStyles)) {
        changed = true;
      }
    } else if (Main.pref.putCollection(pref, null)) {
      changed = true;
    }

    if (tblIconPaths != null) {
      List<String> iconPaths = iconPathsModel.getIconPaths();

      if (!iconPaths.isEmpty()) {
        if (Main.pref.putCollection(iconpref, iconPaths)) {
          changed = true;
        }
      } else if (Main.pref.putCollection(iconpref, null)) {
        changed = true;
      }
    }
    return changed;
  }
  /**
   * @param stylesPreferencesKey the preferences key with the list of active style sources
   *     (filenames and URLs)
   * @param iconsPreferenceKey the preference key with the list of icon sources (can be null)
   * @param availableStylesUrl the URL to the list of available style sources
   */
  public StyleSourceEditor(
      String stylesPreferencesKey, String iconsPreferenceKey, final String availableStylesUrl) {

    DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
    tblActiveStyles = new JTable(activeStylesModel = new ActiveStylesModel(selectionModel));
    tblActiveStyles.putClientProperty("terminateEditOnFocusLost", true);
    tblActiveStyles.setSelectionModel(selectionModel);
    tblActiveStyles.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    tblActiveStyles.setTableHeader(null);
    tblActiveStyles.getColumnModel().getColumn(0).setCellEditor(new FileOrUrlCellEditor());
    tblActiveStyles.setRowHeight(20);
    activeStylesModel.setActiveStyles(Main.pref.getCollection(stylesPreferencesKey, null));

    selectionModel = new DefaultListSelectionModel();
    lstAvailableStyles =
        new JList(availableStylesModel = new AvailableStylesListModel(selectionModel));
    lstAvailableStyles.setSelectionModel(selectionModel);
    lstAvailableStyles.setCellRenderer(new StyleSourceCellRenderer());
    // availableStylesModel.setStyleSources(reloadAvailableStyles(availableStylesUrl));
    this.availableStylesUrl = availableStylesUrl;

    this.pref = stylesPreferencesKey;
    this.iconpref = iconsPreferenceKey;

    JButton iconadd = null;
    JButton iconedit = null;
    JButton icondelete = null;

    if (iconsPreferenceKey != null) {
      selectionModel = new DefaultListSelectionModel();
      tblIconPaths = new JTable(iconPathsModel = new IconPathTableModel(selectionModel));
      tblIconPaths.setSelectionModel(selectionModel);
      tblIconPaths.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
      tblIconPaths.setTableHeader(null);
      tblIconPaths.getColumnModel().getColumn(0).setCellEditor(new FileOrUrlCellEditor());
      tblIconPaths.setRowHeight(20);
      iconPathsModel.setIconPaths(Main.pref.getCollection(iconsPreferenceKey, null));

      iconadd = new JButton(new NewIconPathAction());

      EditIconPathAction editIconPathAction = new EditIconPathAction();
      tblIconPaths.getSelectionModel().addListSelectionListener(editIconPathAction);
      iconedit = new JButton(editIconPathAction);

      RemoveIconPathAction removeIconPathAction = new RemoveIconPathAction();
      tblIconPaths.getSelectionModel().addListSelectionListener(removeIconPathAction);
      icondelete = new JButton(removeIconPathAction);
      tblIconPaths
          .getInputMap(JComponent.WHEN_FOCUSED)
          .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete");
      tblIconPaths.getActionMap().put("delete", removeIconPathAction);
    }

    JButton add = new JButton(new NewActiveStyleAction());

    EditActiveStyleAction editActiveStyleAction = new EditActiveStyleAction();
    tblActiveStyles.getSelectionModel().addListSelectionListener(editActiveStyleAction);
    JButton edit = new JButton(editActiveStyleAction);

    RemoveActiveStylesAction removeActiveStylesAction = new RemoveActiveStylesAction();
    tblActiveStyles.getSelectionModel().addListSelectionListener(removeActiveStylesAction);
    tblActiveStyles
        .getInputMap(JComponent.WHEN_FOCUSED)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete");
    tblActiveStyles.getActionMap().put("delete", removeActiveStylesAction);
    JButton delete = new JButton(removeActiveStylesAction);

    ActivateStylesAction activateStylesAction = new ActivateStylesAction();
    lstAvailableStyles.addListSelectionListener(activateStylesAction);
    JButton copy = new JButton(activateStylesAction);

    JButton update = new JButton(new ReloadStylesAction(availableStylesUrl));

    setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    setLayout(new GridBagLayout());
    add(new JLabel(tr("Active styles")), GBC.eol().insets(5, 5, 5, 0));
    JScrollPane sp;
    add(sp = new JScrollPane(tblActiveStyles), GBC.eol().insets(5, 0, 5, 0).fill(GBC.BOTH));
    sp.setColumnHeaderView(null);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    add(buttonPanel, GBC.eol().insets(5, 0, 5, 5).fill(GBC.HORIZONTAL));
    buttonPanel.add(add, GBC.std().insets(0, 5, 0, 0));
    buttonPanel.add(edit, GBC.std().insets(5, 5, 5, 0));
    buttonPanel.add(delete, GBC.std().insets(0, 5, 5, 0));
    buttonPanel.add(copy, GBC.std().insets(0, 5, 5, 0));
    add(
        new JLabel(tr("Available styles (from {0})", availableStylesUrl)),
        GBC.eol().insets(5, 5, 5, 0));
    add(new JScrollPane(lstAvailableStyles), GBC.eol().insets(5, 0, 5, 0).fill(GBC.BOTH));
    buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    add(buttonPanel, GBC.eol().insets(5, 0, 5, 5).fill(GBC.HORIZONTAL));
    buttonPanel.add(update, GBC.std().insets(0, 5, 0, 0));
    if (tblIconPaths != null) {
      add(new JLabel(tr("Icon paths")), GBC.eol().insets(5, -5, 5, 0));
      add(sp = new JScrollPane(tblIconPaths), GBC.eol().insets(5, 0, 5, 0).fill(GBC.BOTH));
      sp.setColumnHeaderView(null);
      buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
      add(buttonPanel, GBC.eol().insets(5, 0, 5, 5).fill(GBC.HORIZONTAL));
      buttonPanel.add(iconadd);
      buttonPanel.add(iconedit);
      buttonPanel.add(icondelete);
    }
  }