package leigh.elements.sdk;

import leigh.elements.sdk.type1.TableElement;
import leigh.eo.EO;
import leigh.mecha.lang.IdentifiedObject;
import leigh.mecha.math.IntIntervals;
import leigh.mecha.sort.SortPolicy;

import java.util.List;

/**
 * Implementation of an Elements DataFrame. This DataFrame implementation should not be confused with a Conflux
 * DataFrame, which provides analytical processing capabilities. The purpose of the Elements DataFrame is to store
 * data ultimately for use in various Element components, such as the {@link TableElement}.
 *
 * @author Alex Leigh
 */
public interface AppDataFrame extends IdentifiedObject {
    /**
     * Return the column configurations for this frame.
     */
    List<ElementsColumnConfig> getColumnConfigs();

    /**
     * Return the current representation of the view of this frame. The view represents the view after all other
     * processing has occurred, such as sorting.
     */
    List<EO> getView();

    /**
     * Create a new object of the given type in this frame.
     */
    EO create(String type);

    void add(EO obj);

    /**
     * Remove the object at the given <code>viewIdx</code> in this frame.
     */
    void remove(Integer viewIdx);

    /**
     * Sort the frame based on the provided policy. After being provided to the frame, the policy should not be
     * modified or undefined results will occur.
     */
    void sort(SortPolicy<EO> policy) throws Exception;

    /**
     * Return a list of objects in this frame which are selected, if any. If no objects are selected, an empty list
     * is returned.
     */
    List<EO> getSelected();

    IntIntervals getSelectedIntervals();

    /**
     * Replace the selection (if any) existing on the frame with the selection provided.
     */
    void clearAndSelect(IntIntervals ranges);

    void setQuickFilter(String key, String filter);

    void applyFilters() throws Exception;

    void clearFilters() throws Exception;

    void setSelectionListener(SelectionListener listener);

    /**
     * Remove all the objects which are currently selected.
     */
    void deleteSelected();
}