コード例 #1
0
    /**
     * Return a component that has been configured to display the specified value.
     *
     * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, Object,
     *     int, boolean, boolean)
     */
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      final String key = (String) value;
      final Icon icon = IconSource.getIcon(key);

      final Color back = isSelected ? list.getSelectionBackground() : list.getBackground();
      setBackground(back);
      iconLabel.setBackground(back);

      iconLabel.setIcon(icon);

      return this;
    }
コード例 #2
0
  /**
   * Enabled / disable publishing controls depending on the state of the "Enable Publishing" mark.
   */
  private void onPublishingEnabled() {
    boolean enabled = chPublishingEnabled.isSelected();

    lbPublishingPublic.setEnabled(enabled);
    chPublishingPublic.setEnabled(enabled);
    lbLastPublishingDate.setEnabled(enabled);
    tfLastPublishingDate.setEnabled(enabled);
    lbPublishingTags.setEnabled(enabled);
    lbPublishingTitle.setEnabled(enabled);
    lbPublishingURL.setEnabled(enabled);
    lnkPublishingURL.setEnabled(enabled);
    btnCopyToClipboard.setEnabled(enabled);
    tfPublishingTags.setEnabled(enabled);
    tfPublishingTitle.setEnabled(enabled);
    lbPublishingRating.setEnabled(enabled);
    sscPublishingRating.setEnabled(enabled);

    if (enabled && StringUtils.isEmpty(getPublishingTitle())) {
      tfPublishingTitle.setText(getGuideTitle());
    }
  }
コード例 #3
0
  /**
   * 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"));
  }