package com.ssdi.test.client;



import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.OperatorId;
import com.smartgwt.client.types.ReadOnlyDisplayAppearance;
import com.smartgwt.client.widgets.form.fields.DateTimeItem;
import com.smartgwt.client.widgets.form.fields.TextItem;  
  
public class WorldXmlDS extends DataSource {  
  
    private static WorldXmlDS instance = null;  
  
    public static WorldXmlDS getInstance() {  
        if (instance == null) {  
            instance = new WorldXmlDS("worldDS");  
        }  
        return instance;  
    }  
  
    public WorldXmlDS(String id) {  
  
        setID(id);  
        setRecordXPath("/List/country");  
      
  
        DataSourceTextField countryNameField = new DataSourceTextField("countryName", "Country");  
        countryNameField.setRequired(true);  
        countryNameField.setValidOperators(OperatorId.CONTAINS,
		OperatorId.STARTS_WITH, OperatorId.ENDS_WITH,
		OperatorId.EQUALS, OperatorId.NOT_EQUAL);
  
       
        DateTimeItem dateItem = new DateTimeItem();
		dateItem.setUseTextField(true);  
		TextItem textItem = new TextItem();

		textItem.setReadOnlyDisplay(ReadOnlyDisplayAppearance.READONLY);
		textItem.setCanEdit(false);
		textItem.setTextAlign(Alignment.LEFT);
		
		dateItem.setTextFieldProperties(textItem);
        DataSourceDateTimeField independenceField = new DataSourceDateTimeField("independence", "Nationhood"); 
        independenceField.setValidOperators(OperatorId.GREATER_OR_EQUAL,
				OperatorId.LESS_OR_EQUAL, OperatorId.BETWEEN);
       independenceField.setEditorProperties(dateItem);
        
         
        setFields(countryNameField,independenceField);  
  
        setDataURL("data/world.data.xml");  
        setClientOnly(true);  
    }  
}  