package com.treestar.lib.core;

import com.google.gwt.editor.client.Editor;
import com.google.gwt.i18n.client.Messages;
import com.treestar.lib.core.ExportFileTypes;
import com.treestar.lib.core.ExternalAlgorithmResults;
import com.treestar.lib.xml.SElement;
import org.junit.Ignore;

import javax.swing.*;
import java.io.File;
import java.util.List;


public interface ExternalPopulationAlgorithmInterface {

	/**
	 * Return the name by which this algorithm will be identified in the FlowJo workspace.
	 * @return The String name.  It should not contain any characters that cannot be embedded as an XML attribute (e.g. '<', '>')
	 */
	public String getName();

	/**
	 * This method returns the XML that contains any necessary state so that the algorithm instance can be reconstructed using the 'setElement' method.
	 * @return Return the XML element that is saved in the FlowJo workspace.
	 */
	public SElement getElement();

	/**
	 * Using the given XML element, set the internal state of the algorithm instance.
	 * @param element The XML element with the same state as generated by the 'getElement' method.
	 */
	public void setElement(SElement element);

	/**
	 * This method is called by FlowJo to invoke the external program.
	 * @param fcmlQueryElement The XML element that is used by FlowJo to make the engine request for a population.
	 * @param sampleFile The sample file used as input to the algorithm.
	 * @param outputFolder The destination folder where  any result files should be created.
	 * @return The ExternalAlgorithmResults object, which encapsulates CLR/CSV files, derived parameter formulas, etc
	 */
	public ExternalAlgorithmResults invokeAlgorithm(SElement fcmlQueryElement, File sampleFile, File outputFolder);

	/**
	 * @return The list of sample parameter names that will be used by the algorithm, or null if not applicable.
	 */
	public List<String> getParameters();

	/**
	 * @return the Icon object to be used by FlowJo in the workspace window, or null to use the default icon.
	 */
	public Icon getIcon();

	/**
	 * This method is called before the algorithm is invoked, so that the implementation can prompt the user for any options needed to perform the calculations.
	 * @param fcmlQueryElement The XML element that is used by FlowJo to make the engine request for a population.
	 * @param parameterNames The list of parameter names for the data sample
	 * @return Whether the ExternalAlgorithm should be invoked.
	 */
	public boolean promptForOptions(SElement fcmlQueryElement, List<String> parameterNames);

	/**
	 * This method allows the algorithm to specify if the input file should be a CSV file (CSV_SCALE OR CSV_CHANNEL), or an FCS file based on algorithm's requirements.
	 * @return ExportFileTypes One of three values (ExportFileTypes.FCS, ExportFileTypes.CSV_SCALE, ExportFileTypes.CSV_CHANNEL) will be returned according to algorithm's requirement.
	 */
	public ExportFileTypes useExportFileType();

	/**
	 * This method returns a version string that can be used to display in the promptForOptions method.
	 * The version will be included in the getElement XML result.
	 * @return A version string
	 */
	public String getVersion();
}
