package com.se.smartgwt.client.data;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceBooleanField;
import com.smartgwt.client.data.fields.DataSourceDateField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.form.fields.MultiPickerItem;

/*******************************************************************************
* 
*******************************************************************************/
public class SampleDataSource extends DataSource
{
   private static SampleDataSource instance = null;

   public static SampleDataSource getInstance()
   {
      if(instance == null)
      {
         instance = new SampleDataSource("localSampleDS");
      }
      return instance;
   }

   public SampleDataSource(String id)
   {
      setID(id);

      DataSourceBooleanField indexfield = new DataSourceBooleanField("dataIndex", "Index");
      DataSourceTextField nameField = new DataSourceTextField("dataName", "Name");
      DataSourceIntegerField agefield = new DataSourceIntegerField("dataAge", "Age");
      DataSourceDateField dateField = new DataSourceDateField("dataDate", "Date");

      MultiPickerItem multiItem = new MultiPickerItem();
      multiItem = multiItem.setSortDirection(SortDirection.ASCENDING);
      multiItem.setAllowExpressions(true);
      multiItem = multiItem.setDeriveUniqueValues(true);
      nameField.setFilterEditorProperties(multiItem);
      agefield.setFilterEditorProperties(multiItem);
      dateField.setFilterEditorProperties(multiItem);

      setFields(indexfield, nameField, agefield, dateField);
      setTestData(SampleData.getRecords());
      setClientOnly(true);

   }
}
