/** * 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); }
/** * On node selection changes description text. * * @param node node. */ private void onNodeSelected(CollectionNode node) { if (node == null) { taDescription.setText(null); } else { taDescription.setText(node.getDescription()); UifUtilities.installTextStyle(taDescription, TEXT_STYLE); } }
/** * 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")); }