package de.visone.nlpext.gui;

import java.awt.Dimension;
import java.io.File;

import javax.swing.JTextPane;

import de.visone.base.Mediator;
import de.visone.base.Network;
import de.visone.ext.nlp.TextNetworkUtil;
import de.visone.gui.tabs.AbstractAlgorithmTaskCard;
import de.visone.gui.tabs.option.DummyVisoneOptionItem;
import de.visone.nlpext.network.CreateAttributes;
import de.visone.nlpext.network.CreationProcess;
import de.visone.nlpext.network.TextNetwork;

/**
 * Panel to create missing {@link TextNetworkUtil#ATTR_NAME_SENTENCE_BEGINNINGS}
 * and {@link TextNetworkUtil#ATTR_NAME_WORD_BEGINNINGS} attributes in existing
 * text networks.
 * 
 * @author matthias
 */
public class CreateAttributesCard extends AbstractAlgorithmTaskCard {
	/**
	 * @param mediator
	 *            the mediator
	 */
	public CreateAttributesCard(final Mediator mediator) {
		super("create text attributes", mediator);
	}

	@Override
	public String getApplyText() {
		return "create attributes";
	}

	@Override
	public void runAlgorithm(final Network net) {
		final TextNetwork textNetw = new CreateAttributes(net);
		new CreationProcess(new File(""), textNetw, false, mediator);
	}

	@Override
	protected void setParameters(final Network net) {
		return; // no parameters
	}

	@Override
	protected void fillParameterPanel() {
		final JTextPane text = new JTextPane();
		text.setContentType("text/html");
		text.setPreferredSize(new Dimension(200, 100));
		text.setEditable(false);
		text.setText("<html><p>use this algorithm if the TEXT button doesn't"
				+ " work on a text network created by an old version of the"
				+ " text extension. it creates the required network attributes"
				+ " that old versions didn't create.</p><p>for networks created"
				+ " with the current version of the text extension, this operation"
				+ " isn't necessary.</p></html>");
		addDummyOptionItem(new DummyVisoneOptionItem(text));
	}
}
