private void generateFilePreviewContent()

in taverna-perspective-myexperiment/src/main/java/org/apache/taverna/ui/perspectives/myexperiment/ResourcePreviewFactory.java [313:429]


  private void generateFilePreviewContent(File f, JPanel panelToPopulate, EventListener eventHandler) {
	if (f != null) {
	  try {
		StringBuffer content = new StringBuffer();
		content.append("<div class='outer'>");
		content.append("<div class='file'>");

		content.append("<br>");

		content.append("<p class='title'>");
		content.append("File: <a href='preview:" + Resource.FILE + ":"
			+ f.getURI() + "'>" + f.getTitle() + "</a>");
		content.append("</p>");

		content.append("<br>");

		content.append("<p class='info'>");
		content.append("<b>Type:</b> " + f.getVisibleType() + "<br>");
		content.append("<b>Filename:</b> " + f.getFilename() + "<br><br>");
		content.append("<b>Uploader:</b> <a href='preview:" + Resource.USER
			+ ":" + f.getUploader().getURI() + "'>" + f.getUploader().getName()
			+ "</a><br>");
		content.append("<b>Created at: </b> " + f.getCreatedAt() + "<br>");
		content.append("<b>Last updated at: </b> " + f.getUpdatedAt() + "<br>");
		content.append("<b>License: </b> <a href='"
			+ f.getLicense().getLink()
			+ "'>"
			+ f.getLicense().getText()
			+ "</a>"
			+ "&nbsp;<img src='"
			+ MyExperimentPerspective.getLocalResourceURL("external_link_small_icon")
			+ "' />");
		content.append("</p>");

		content.append("<br>");

		if (!f.getDescription().equals("")) {
		  content.append("<p class='desc'>");
		  content.append("<br>");
		  content.append(Util.stripHTML(f.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 ===
		// TABS FOR file's tags, credits, etc
		JScrollPane spTagsTab = createTagPreviewTab(f.getTags());
		JScrollPane spCommentsTab = createCommentsPreviewTab(f.getComments());
		JScrollPane spCreditsTab = createCreditsPreviewTab(f.getCredits());
		JScrollPane spAttributionsTab = createAttributionsPreviewTab(f.getAttributions());

		// ASSEMBLE tabs into tabbed view
		JTabbedPane tpTabbedView = new JTabbedPane();
		tpTabbedView.add("Tags (" + f.getTags().size() + ")", spTagsTab);
		tpTabbedView.add("Comments (" + f.getComments().size() + ")", spCommentsTab);
		tpTabbedView.add("Credits (" + f.getCredits().size() + ")", spCreditsTab);
		tpTabbedView.add("Attributions (" + f.getAttributions().size() + ")", spAttributionsTab);

		// PUT EVERYTHING TOGETHER
		JTextPane tpFilePreview = new JTextPane();
		tpFilePreview.setEditable(false);
		tpFilePreview.setEditorKit(kit);
		tpFilePreview.setDocument(doc);
		tpFilePreview.addHyperlinkListener((HyperlinkListener) eventHandler);

		JPanel jpFullFilePreview = new JPanel();
		jpFullFilePreview.setBackground(Color.WHITE); // white background for
		// the whole file preview
		// panel
		jpFullFilePreview.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
		jpFullFilePreview.add(tpFilePreview, 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
		jpFullFilePreview.add(tpTabbedView, c);

		// POPULATE THE GIVEN PANEL
		panelToPopulate.setLayout(new BorderLayout());
		panelToPopulate.add(jpFullFilePreview, BorderLayout.CENTER);

		// this.statusLabel.setText("File 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 File Preview pane", e);
	  }
	} else {
	  // statusLabel.setText("Could not find information for file ID: " +
	  // currentFileId);
	  // clearContentTextPane();
	  // disableButtons();
	}
  }