package org.cloudcoder.app.wizard.ui;

import java.awt.Component;

import javax.swing.JEditorPane;
import javax.swing.text.html.HTMLEditorKit;

import org.cloudcoder.app.wizard.model.ImmutableStringValue;

public class ImmutableStringValueField extends JEditorPane implements IPageField {
	private static final long serialVersionUID = 1L;
	private HTMLEditorKit kit;
	
	public ImmutableStringValueField() {
		setEditable(false);
		this.kit = new HTMLEditorKit();
		setDocument(kit.createDefaultDocument());
		setEditorKit(kit);
	}
	
	public void setValue(ImmutableStringValue value) {
		setText("<html><body>" + value.getString() + "</body></html>");
	}
	
	@Override
	public Component asComponent() {
		return this;
	}
	
	@Override
	public int getFieldHeight() {
		// Should this be configurable somehow?
		return 240;
	}
}

@@ -58,16 +58,41 @@
 mponent;
+%0Aimport java.awt.Desktop;
 %0A%0Aimport
@@ -117,16 +117,101 @@
 orPane;%0A
+import javax.swing.event.HyperlinkEvent;%0Aimport javax.swing.event.HyperlinkListener;%0A
 import j
@@ -610,16 +610,16 @@
 ent());%0A
-
 %09%09setEdi
@@ -631,16 +631,453 @@
 t(kit);%0A
+%09%09addHyperlinkListener(new HyperlinkListener() %7B%0A%09%09%09@Override%0A%09%09%09public void hyperlinkUpdate(HyperlinkEvent evt) %7B%0A%09%09%09%09if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) %7B%0A%09%09%09%09%09if (Desktop.isDesktopSupported()) %7B%0A%09%09%09%09%09%09try %7B%0A%09%09%09%09%09%09%09Desktop.getDesktop().browse(evt.getURL().toURI());%0A%09%09%09%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%09%09%09%09System.err.println(%22Error attempting to browse link: %22 + e.getMessage());%0A%09%09%09%09%09%09%7D%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D);%0A
 %09%7D%0A%09%0A%09pu

support clicking on hyperlinks in help text