Exemple #1
0
  /**
   * Creates component.
   *
   * @param collection collection to show.
   * @param treeMode <code>TRUE</code> to set tree mode by default.
   * @param readingLists <code>TRUE</code> if showing reading lists.
   */
  public CListTree(Collection collection, boolean treeMode, boolean readingLists) {
    this.collection = collection;
    this.readingLists = readingLists;

    itemListener = new CItemListener();

    setLayout(new BorderLayout());
    setTreeMode(treeMode);

    BBFormBuilder builder = new BBFormBuilder("p, 2dlu, p, 0:grow");

    JComboBox cbViewMode =
        new JComboBox(
            new Object[] {
              Strings.message("collections.viewmode.tree"),
              Strings.message("collections.viewmode.list")
            });
    cbViewMode.setSelectedIndex(treeMode ? 0 : 1);
    cbViewMode.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            JComboBox box = (JComboBox) e.getSource();
            boolean isTree = box.getSelectedIndex() == 0;
            setTreeMode(isTree);
          }
        });

    builder.append(Strings.message("collections.viewmode"), cbViewMode);
    builder.appendRelatedComponentsGapRow(2);

    add(builder.getPanel(), BorderLayout.NORTH);

    // Description area
    taDescription = new JEditorPane();
    Color back = taDescription.getBackground();
    taDescription.setEditable(false);
    taDescription.setBackground(back);
    taDescription.setEditorKit(new CustomHTMLEditorKit());

    HTMLDocument doc = (HTMLDocument) taDescription.getDocument();
    Style def = doc.getStyle("default");
    Font font = UIManager.getFont("TextArea.font");
    if (SystemUtils.IS_OS_MAC) font = UifUtilities.applyFontBias(font, -2);
    UifUtilities.setFontAttributes(doc.addStyle(TEXT_STYLE, def), font);

    builder = new BBFormBuilder("0:grow");
    builder.appendUnrelatedComponentsGapRow(2);
    builder.appendRow("p");

    builder.append(Strings.message("collections.description"), 1);
    builder.appendRelatedComponentsGapRow(2);
    builder.appendRow("50px");
    builder.append(taDescription, 1, CellConstraints.FILL, CellConstraints.FILL);

    add(builder.getPanel(), BorderLayout.SOUTH);
  }
  /**
   * Builds reading lists tab.
   *
   * @return component.
   */
  protected JComponent buildReadingListsTab() {
    // Wording
    JComponent wording = msg(Strings.message("guide.dialog.readinglists.wording"));

    // Buttons
    Dimension btnSize = new Dimension(20, 20);
    btnAddReadingList.setPreferredSize(btnSize);
    btnRemoveList.setPreferredSize(btnSize);
    FlowLayout layout = new FlowLayout(FlowLayout.LEFT);
    JPanel bbar = new JPanel(layout);
    bbar.add(btnAddReadingList);
    bbar.add(btnRemoveList);
    layout.setHgap(0);
    layout.setVgap(0);

    // Panel
    BBFormBuilder builder = new BBFormBuilder("0:grow");
    builder.setDefaultDialogBorder();

    builder.append(wording);
    builder.appendUnrelatedComponentsGapRow(2);
    builder.appendRow("min:grow");
    builder.append(new JScrollPane(tblReadingLists), 1, CellConstraints.FILL, CellConstraints.FILL);
    builder.append(bbar);

    return builder.getPanel();
  }
  /**
   * Builds panel for publishing tab when publishing is available.
   *
   * @param aWording wording to put on the page.
   * @return component.
   */
  private JPanel buildPublishingTabAvailable(JComponent aWording) {
    JPanel sscPanel = new JPanel(new BorderLayout());
    sscPanel.add(sscPublishingRating, BorderLayout.WEST);

    // Panel
    BBFormBuilder builder = new BBFormBuilder("7dlu, p, 2dlu, 100dlu, 0:grow, 2dlu, p");
    builder.setDefaultDialogBorder();

    builder.append(aWording, 7);
    builder.appendUnrelatedComponentsGapRow(2);

    builder.append(chPublishingEnabled, 7);
    builder.setLeadingColumnOffset(1);
    builder.append(lbPublishingTitle, tfPublishingTitle);
    builder.nextLine();
    builder.append(lbPublishingTags, tfPublishingTags);
    builder.nextLine();
    builder.append(lbPublishingPublic, chPublishingPublic);
    builder.nextLine();
    builder.append(lbPublishingRating, sscPanel);
    builder.appendUnrelatedComponentsGapRow(2);

    builder.append(lbPublishingURL);
    builder.append(lnkPublishingURL, 2);
    builder.append(btnCopyToClipboard);
    builder.append(lbLastPublishingDate, tfLastPublishingDate);

    builder.setLeadingColumnOffset(0);
    builder.appendUnrelatedComponentsGapRow(2);
    builder.appendRow("min:grow");

    JComponent instructionsBox =
        ComponentsFactory.createInstructionsBox(
            Strings.message("guide.dialog.publishing.instructions"));
    builder.append(instructionsBox, 7, CellConstraints.FILL, CellConstraints.FILL);

    return builder.getPanel();
  }