/*
 * Copyright 2004-2007 IDCA. All rights reserved.
 *
 * 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 IDCA 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 IDCA 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.
 * 
 * The views and conclusions contained in the software and documentation are those of the authors and
 * should not be interpreted as representing official policies, either expressed or implied, of IDCA.
 */

package com.idcanet.vasc.core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.idcanet.vasc.core.actions.ColumnVascAction;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.column.VascTableColumn;
import com.idcanet.vasc.core.ui.VascUIComponent;

/**
 * 
 * @author Willem Cazander
 * @version 1.0 Mar 21, 2007
 */
public class VascTable {
	
	
    private String name = null;
    private String headerName = null;
    private String headerImage = null;
    private String headerToolTip = null;
    private List<VascTableColumn> tableColumns = null;
    private List<RowVascAction> rowActions = null;
    private List<ColumnVascAction> columnActions = null;
    private List<GlobalVascAction> globalActions = null;
    private VascDataSource vascDataSource = null;
	private List<Object> tableData = null;
	private Object selectedObject = null;
	private VascRecordCreator vascRecordCreator = null;
	private VascViewRenderer vascViewRenderer = null;
	private VascTextValue vascTextValue = null;
	private List<VascUserOption> userOptions = null;
	private String helpId = null;
	private VascTableController vascTableController = null;
	private Map<Class,Class> uiComponents = null;
	
	public VascTable() {
		tableColumns = new ArrayList<VascTableColumn>(6);
		rowActions = new ArrayList<RowVascAction>(6);
		columnActions = new ArrayList<ColumnVascAction>(6);
		globalActions = new ArrayList<GlobalVascAction>(6);
		tableData = new ArrayList<Object>(6);
		userOptions = new ArrayList<VascUserOption>(6);
		uiComponents = new HashMap<Class,Class>(6);
	}

	/**
	 * @return the columnActions
	 */
	public List<ColumnVascAction> getColumnActions() {
		return columnActions;
	}

	/**
	 * @param columnActions the columnActions to set
	 */
	public void addColumnActions(ColumnVascAction columnAction) {
		columnActions.add(columnAction);
	}


	/**
	 * @return the globalActions
	 */
	public List<GlobalVascAction> getGlobalActions() {
		return globalActions;
	}

	/**
	 * @param globalActions the globalActions to set
	 */
	public void addGlobalActions(GlobalVascAction globalAction) {
		globalActions.add(globalAction);
	}

	/**
	 * @return the headerName
	 */
	public String getHeaderName() {
		return headerName;
	}

	/**
	 * @param headerName the headerName to set
	 */
	public void setHeaderName(String headerName) {
		this.headerName = headerName;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the rowActions
	 */
	public List<RowVascAction> getRowActions() {
		return rowActions;
	}

	/**
	 * @param rowActions the rowActions to set
	 */
	public void addRowActions(RowVascAction rowAction) {
		rowActions.add(rowAction);
	}

	/**
	 * @return the selectedObject
	 */
	public Object getSelectedObject() {
		return selectedObject;
	}

	/**
	 * @param selectedObject the selectedObject to set
	 */
	public void setSelectedObject(Object selectedObject) {
		this.selectedObject = selectedObject;
	}

	/**
	 * @return the tableColumns
	 */
	public List<VascTableColumn> getTableColumns() {
		return tableColumns;
	}

	/**
	 * @param tableColumns the tableColumns to set
	 */
	public void addTableColumns(VascTableColumn tableColumn) {
		if (tableColumn.getVascTable()!=null) {
			if (tableColumn.getVascTable().equals(this) == false) {
				throw new IllegalStateException("VascTableColumn already bound to an other VascTable instance.");
			}
		}
		tableColumn.setVascTable(this);
		tableColumns.add(tableColumn);
	}
	
	/**
	 * @return the tableData
	 */
	public List<Object> getTableData() {
		return tableData;
	}

	/**
	 * @param tableData the tableData to set
	 */
	public void setTableData(List<Object> tableData) {
		this.tableData = tableData;
	}


	/**
	 * @return the userOptions
	 */
	public List<VascUserOption> getUserOptions() {
		return userOptions;
	}

	/**
	 * @param userOptions the userOptions to set
	 */
	public void addUserOptions(VascUserOption userOption) {
		userOptions.add(userOption);
	}

	/**
	 * @return the vascDataSource
	 */
	public VascDataSource getVascDataSource() {
		return vascDataSource;
	}

	/**
	 * @param vascDataSource the vascDataSource to set
	 */
	public void setVascDataSource(VascDataSource vascDataSource) {
		this.vascDataSource = vascDataSource;
	}

	/**
	 * @return the vascRecordCreator
	 */
	public VascRecordCreator getVascRecordCreator() {
		return vascRecordCreator;
	}

	/**
	 * @param vascRecordCreator the vascRecordCreator to set
	 */
	public void setVascRecordCreator(VascRecordCreator vascRecordCreator) {
		this.vascRecordCreator = vascRecordCreator;
	}

	/**
	 * @return the vascTextValue
	 */
	public VascTextValue getVascTextValue() {
		return vascTextValue;
	}

	/**
	 * @param vascTextValue the vascTextValue to set
	 */
	public void setVascTextValue(VascTextValue vascTextValue) {
		this.vascTextValue = vascTextValue;
	}

	/**
	 * @return the vascViewRenderer
	 */
	public VascViewRenderer getVascViewRenderer() {
		return vascViewRenderer;
	}

	/**
	 * @param vascViewRenderer the vascViewRenderer to set
	 */
	public void setVascViewRenderer(VascViewRenderer vascViewRenderer) {
		this.vascViewRenderer = vascViewRenderer;
	}

	/**
	 * @return the helpId
	 */
	public String getHelpId() {
		return helpId;
	}

	/**
	 * @param helpId the helpId to set
	 */
	public void setHelpId(String helpId) {
		this.helpId = helpId;
	}

	/**
	 * @return the vascTableController
	 */
	public VascTableController getVascTableController() {
		return vascTableController;
	}

	/**
	 * @param vascTableController the vascTableController to set
	 */
	public void setVascTableController(VascTableController vascTableController) {
		this.vascTableController = vascTableController;
	}

	/**
	 * @return the headerImage
	 */
	public String getHeaderImage() {
		return headerImage;
	}

	/**
	 * @param headerImage the headerImage to set
	 */
	public void setHeaderImage(String headerImage) {
		this.headerImage = headerImage;
	}

	/**
	 * @return the headerToolTip
	 */
	public String getHeaderToolTip() {
		return headerToolTip;
	}

	/**
	 * @param headerToolTip the headerToolTip to set
	 */
	public void setHeaderToolTip(String headerToolTip) {
		this.headerToolTip = headerToolTip;
	}
	
	
	public Class getUIComponent(Class classType) {
		return uiComponents.get(classType);
	}
	public void putUIComponent(Class classType,Class comp) {
		uiComponents.put(classType, comp);
	}
}