/** Invoked when removing selected reading list is required. */
  private void onRemoveReadingList() {
    int[] rows = tblReadingLists.getSelectedRows();
    boolean haveFeeds = false;
    for (int i = 0; !haveFeeds && i < rows.length; i++) {
      int row = rows[i];
      haveFeeds = readingListsModel.getLists()[row].getFeeds().length > 0;
    }

    boolean delete = true;
    if (haveFeeds) {
      String msg =
          rows.length == 1
              ? Strings.message("guide.dialog.readinglists.has.feeds")
              : Strings.message("guide.dialog.readinglists.have.feeds");

      delete =
          JOptionPane.showConfirmDialog(
                  this,
                  msg,
                  Strings.message("guide.dialog.delete.readinglist"),
                  JOptionPane.YES_NO_OPTION)
              == JOptionPane.YES_OPTION;
    }

    if (delete) readingListsModel.removeRows(rows);
  }
  /**
   * Shows given list of reading lists.
   *
   * @param lists lists.
   */
  protected void setReadingLists(ReadingList[] lists) {
    tblReadingLists.setEnabled(lists != null);
    btnAddReadingList.setEnabled(lists != null);
    btnRemoveList.setEnabled(lists != null);

    readingListsModel.setLists(lists);
  }
 /**
  * Returns the default table cell renderer.
  *
  * @param table the <code>JTable</code>
  * @param value the value to assign to the cell at <code>[row, column]</code>
  * @param isSelected true if cell is selected
  * @param hasFocus true if cell has focus
  * @param row the row of the cell to render
  * @param column the column of the cell to render
  * @return the default table cell renderer
  */
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   ReadingList list = model.getLists()[row];
   Component comp =
       super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   comp.setForeground(list.isMissing() ? Color.GRAY : table.getForeground());
   return comp;
 }
  /**
   * Creates dialog.
   *
   * @param aFrame parent frame.
   * @param aTitle dialog title.
   * @param aPublishingAvailable <code>TRUE</code> if publishing is available.
   * @param aPublishingLimit the number of guides the user can have published.
   * @param aPublishingLimitReached <code>TRUE</code> if the limit is reached.
   */
  public BasicGuideDialog(
      Frame aFrame,
      String aTitle,
      boolean aPublishingAvailable,
      int aPublishingLimit,
      boolean aPublishingLimitReached) {
    super(aFrame, aTitle);

    publishingAvailable = aPublishingAvailable;
    publishingLimit = aPublishingLimit;
    publishingLimitReached = aPublishingLimitReached;

    presentTitles = Collections.EMPTY_SET;
    model = new GuideIcons.ComboBoxModel();
    renderer = new IconListCellRenderer();
    readingListsModel = new ReadingListsTableModel();

    tblReadingLists = new JTable(readingListsModel);
    tblReadingLists.setDefaultRenderer(
        String.class, new ReadingListsTableCellRenderer(readingListsModel));
    UifUtilities.setTableColWidth(tblReadingLists, 2, 90);

    btnAddReadingList = new JButton(null, ResourceUtils.getIcon("add.icon"));
    btnAddReadingList.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAddReadingList();
          }
        });
    btnRemoveList = new JButton(null, ResourceUtils.getIcon("delete.icon"));
    btnRemoveList.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onRemoveReadingList();
          }
        });

    // Publishing components
    chPublishingEnabled =
        ComponentsFactory.createCheckBox(Strings.message("guide.dialog.enable.publishing"));
    lbPublishingPublic = new JLabel(Strings.message("guide.dialog.public.visibility"));
    chPublishingPublic = new JCheckBox();
    lbPublishingTitle =
        ComponentsFactory.createLabel(Strings.message("guide.dialog.reading.list.title"));
    lbPublishingTags = ComponentsFactory.createLabel(Strings.message("guide.dialog.tags"));
    lbPublishingURL = new JLabel(Strings.message("guide.dialog.publicationurl"));
    lnkPublishingURL = new LinkLabel(Strings.message("guide.dialog.not.published.yet"));
    lbLastPublishingDate = new JLabel(Strings.message("guide.dialog.last.update.date"));
    tfLastPublishingDate = new JLabel(Strings.message("guide.dialog.never.updated"));
    tfPublishingTitle = new JTextField();
    lbPublishingTitle.setLabelFor(tfPublishingTitle);
    tfPublishingTags = new JTextField();
    lbPublishingTags.setLabelFor(tfPublishingTags);

    vhPublishingRating = new ValueHolder(1);
    sscPublishingRating =
        new StarsSelectionComponent(new BoundedRangeAdapter(vhPublishingRating, 0, 1, 5));
    lbPublishingRating = new JLabel(Strings.message("guide.dialog.rating"));

    btnCopyToClipboard = new JButton(Strings.message("guide.dialog.copy"));
    btnCopyToClipboard.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CommonUtils.copyTextToClipboard(lnkPublishingURL.getText());
          }
        });

    onPublishingEnabled();
    chPublishingEnabled.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            onPublishingEnabled();
          }
        });

    chAllowNotifications =
        ComponentsFactory.createCheckBox(Strings.message("guide.dialog.allow.notifications"));
  }