/*
 * #%L
 * SciJava UI components for Java Swing.
 * %%
 * Copyright (C) 2010 - 2020 SciJava developers.
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * #L%
 */

package org.scijava.ui.swing.widget;

import javax.swing.JLabel;
import javax.swing.JPanel;

import org.scijava.Priority;
import org.scijava.plugin.Plugin;
import org.scijava.widget.InputWidget;
import org.scijava.widget.MessageWidget;
import org.scijava.widget.WidgetModel;

/**
 * Swing implementation of message widget.
 * 
 * @author Curtis Rueden
 */
@Plugin(type = InputWidget.class, priority = Priority.HIGH)
public class SwingMessageWidget extends SwingInputWidget<String> implements
	MessageWidget<JPanel>
{

	private JLabel label;

	// -- InputWidget methods --

	@Override
	public String getValue() {
		return null;
	}

	@Override
	public boolean isLabeled() {
		final String l = get().getItem().getLabel();
		return l != null && !l.isEmpty();
	}

	@Override
	public boolean isMessage() {
		return true;
	}

	// -- WrapperPlugin methods --

	@Override
	public void set(final WidgetModel model) {
		super.set(model);

		final String text = model.getText();

		label = new JLabel(text);
		getComponent().add(label);
	}

	// -- Typed methods --

	@Override
	public boolean supports(final WidgetModel model) {
		return super.supports(model) && model.isMessage();
	}

	// -- AbstractUIInputWidget methods ---

	@Override
	public void doRefresh() {
		// maybe dialog owner changed message content
		label.setText(get().getText());
	}
}

@@ -1475,79 +1475,315 @@
 java
-x.swing.JLabel;%0Aimport javax.swing.JPanel;%0A%0Aimport org.scijava.Priority
+.io.IOException;%0A%0Aimport javax.swing.JEditorPane;%0Aimport javax.swing.JPanel;%0Aimport javax.swing.event.HyperlinkEvent;%0Aimport javax.swing.event.HyperlinkListener;%0A%0Aimport org.scijava.Priority;%0Aimport org.scijava.log.LogService;%0Aimport org.scijava.platform.PlatformService;%0Aimport org.scijava.plugin.Parameter
 ;%0Aim
@@ -2179,30 +2179,133 @@
 %3E%0A%7B%0A
-%0A%09private JLabel label
+%09@Parameter%0A%09private PlatformService platformService;%0A%0A%09@Parameter%0A%09private LogService logService;%0A%0A%09private JEditorPane pane
 ;%0A%0A%09
@@ -2735,21 +2735,20 @@
 %0A%0A%09%09
-label
+pane
  = new J
 Labe
@@ -2747,18 +2747,599 @@
 ew J
-Label(text
+EditorPane(%22text/html%22, text);%0A%0A%09%09// NB: use format (font etc.) from parent component%0A%09%09pane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);%0A%0A%09%09pane.setEditable(false);%0A%09%09pane.setOpaque(false);%0A%09%09pane.addHyperlinkListener(new HyperlinkListener() %7B%0A%0A%09%09%09@Override%0A%09%09%09public void hyperlinkUpdate(HyperlinkEvent hle) %7B%0A%09%09%09%09if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) %7B%0A%09%09%09%09%09try %7B%0A%09%09%09%09%09%09platformService.open(hle.getURL());%0A%09%09%09%09%09%7D%0A%09%09%09%09%09catch (IOException exc) %7B%0A%09%09%09%09%09%09logService.error(%22Error while opening %22 + hle.getURL(), exc);%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D
 );%0A%09
@@ -3358,21 +3358,20 @@
 t().add(
-label
+pane
 );%0A%09%7D%0A%0A%09
@@ -3648,13 +3648,12 @@
 t%0A%09%09
-label
+pane
 .set

make hyperlinks work