in taverna-perspective-myexperiment/src/main/java/org/apache/taverna/ui/perspectives/myexperiment/ResourcePreviewFactory.java [757:890]
private void generateGroupPreviewContent(Group g, JPanel panelToPopulate, EventListener eventHandler) {
if (g != null) {
try {
// === Render group details in HTML format ===
StringBuffer content = new StringBuffer();
content.append("<div class='outer'>");
content.append("<div class='group'>");
content.append("<br>");
content.append("<p class='title'>");
content.append("Group: <a href='preview:" + Resource.GROUP + ":"
+ g.getURI() + "'>" + g.getTitle() + "</a>");
content.append("</p>");
content.append("<br>");
content.append("<p class='info'>");
content.append("<b>Administrator:</b> <a href='preview:"
+ Resource.USER + ":" + g.getAdmin().getURI() + "'>"
+ g.getAdmin().getName() + "</a><br>");
content.append("<b>Created at: </b> " + g.getCreatedAt() + "<br>");
content.append("</p>");
content.append("<br>");
if (!g.getDescription().equals("")) {
content.append("<p class='desc'>");
content.append("<br>");
content.append(Util.stripHTML(g.getDescription()));
content.append("<br>");
content.append("</p>");
} else {
content.append("<span class='none_text'>No description</span>");
}
content.append("<br>");
content.append("</div>");
content.append("</div>");
HTMLEditorKit kit = new StyledHTMLEditorKit(pluginMainComponent.getStyleSheet());
HTMLDocument doc = (HTMLDocument) (kit.createDefaultDocument());
doc.insertAfterStart(doc.getRootElements()[0].getElement(0), content.toString());
// === Now render group's items as Swing components ===
// .. MEMBERS ..
JPanel jpMembersTabContent = createStandardTabContentPanel();
// iterate through all shared items and add all to the panel
Iterator<User> iMembers = g.getMembers().iterator();
while (iMembers.hasNext()) {
User uCurMember = iMembers.next();
jpMembersTabContent.add(new JClickableLabel(uCurMember.getName(), "preview:"
+ uCurMember.getItemType() + ":" + uCurMember.getURI(), pluginMainComponent.getPreviewBrowser(), new ImageIcon(MyExperimentPerspective.getLocalIconURL(uCurMember.getItemType()))));
}
// wrap into a standard scroll pane
JScrollPane spMembersTabContent = wrapPreviewTabContentIntoScrollPane(jpMembersTabContent);
// .. SHARED ITEMS ..
JPanel jpSharedItemsTabContent = createStandardTabContentPanel();
// iterate through all shared items and add all to the panel
Iterator<Resource> iSharedItems = g.getSharedItems().iterator();
while (iSharedItems.hasNext()) {
Resource rCurItem = iSharedItems.next();
jpSharedItemsTabContent.add(new JClickableLabel(rCurItem.getTitle(), "preview:"
+ rCurItem.getItemType() + ":" + rCurItem.getURI(), pluginMainComponent.getPreviewBrowser(), new ImageIcon(MyExperimentPerspective.getLocalIconURL(rCurItem.getItemType()))));
}
// wrap into a standard scroll pane
JScrollPane spSharedItemsTabContent = wrapPreviewTabContentIntoScrollPane(jpSharedItemsTabContent);
// .. TAGS, COMMENTS ..
JScrollPane spTagsTabContent = createTagPreviewTab(g.getTags());
JScrollPane spCommentsTab = createCommentsPreviewTab(g.getComments());
// ASSEMBLE tabs together
JTabbedPane tpTabbedItems = new JTabbedPane();
tpTabbedItems.addTab("Members (" + g.getMemberCount() + ")", spMembersTabContent);
tpTabbedItems.addTab("Shared Items (" + g.getSharedItemCount() + ")", spSharedItemsTabContent);
tpTabbedItems.addTab("Tags (" + g.getTags().size() + ")", spTagsTabContent);
tpTabbedItems.addTab("Comments (" + g.getComments().size() + ")", spCommentsTab);
// PUT EVERYTHING TOGETHER
JTextPane tpGroupPreview = new JTextPane();
tpGroupPreview.setEditable(false);
tpGroupPreview.setEditorKit(kit);
tpGroupPreview.setDocument(doc);
tpGroupPreview.addHyperlinkListener((HyperlinkListener) eventHandler);
JPanel jpFullGroupPreview = new JPanel();
jpFullGroupPreview.setBackground(Color.WHITE); // white background for
// the whole group
// preview panel
jpFullGroupPreview.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridx = GridBagConstraints.REMAINDER;
c.gridy = 0;
c.weighty = 0; // will not change size when the window is resized
jpFullGroupPreview.add(tpGroupPreview, c);
c.gridx = GridBagConstraints.REMAINDER;
c.gridy = 1;
c.weighty = 1; // will grow in size when the window is resized..
c.fill = GridBagConstraints.VERTICAL; // ..and fill all available space
// vertically
c.insets = new Insets(20, 0, 5, 0); // a bit of margin at the top &
// bottom
jpFullGroupPreview.add(tpTabbedItems, c);
// POPULATE THE GIVEN PANEL
panelToPopulate.setLayout(new BorderLayout());
panelToPopulate.add(jpFullGroupPreview, BorderLayout.CENTER);
// this.statusLabel.setText("Group information found. Last fetched: " +
// new Date().toString());
// this.clearButton.setEnabled(true);
// this.refreshButton.setEnabled(true);
// this.loadButton.setEnabled(true);
// this.importButton.setEnabled(true);
} catch (Exception e) {
logger.error("Failed to populate Group Preview pane", e);
}
} else {
// statusLabel.setText("Could not find information for group ID: " +
// currentGroupId);
// clearContentTextPane();
// disableButtons();
}
}