package com.pg.deploytool.client.custom;
/*
 * Smart GWT (GWT for SmartClient)
 * Copyright 2008 and beyond, Isomorphic Software, Inc.
 *
 * Smart GWT is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation.  Smart GWT is also
 * available under typical commercial license terms - see
 * http://smartclient.com/license
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 */

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.types.SelectionAppearance;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
import com.smartgwt.client.widgets.grid.events.FilterEditorSubmitEvent;
import com.smartgwt.client.widgets.grid.events.FilterEditorSubmitHandler;
import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeGridField;

public class NodeTitlesTreeSample implements EntryPoint {

    public void onModuleLoad() {
    
    final TreeGrid employeeTreeGrid = new TreeGrid();  
    employeeTreeGrid.setWidth100();  
    employeeTreeGrid.setHeight(400);  

    // Changes for my example of filtering a TreeGrid.
    //        employeeTreeGrid.setNodeIcon("icons/16/person.png");  
    //        employeeTreeGrid.setFolderIcon("icons/16/person.png");  
   
//    employeeTreeGrid.setUseAllDataSourceFields(true);
    
    employeeTreeGrid.setShowOpenIcons(false);  
    employeeTreeGrid.setShowDropIcons(false);  
    employeeTreeGrid.setClosedIconSuffix("");  
    employeeTreeGrid.setSelectionType(SelectionStyle.SIMPLE);
    employeeTreeGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
    employeeTreeGrid.setCascadeSelection(true);
    employeeTreeGrid.setShowPartialSelection(true);
    employeeTreeGrid.setShowFilterEditor(true); 
    employeeTreeGrid.setLoadDataOnDemand(false);
    employeeTreeGrid.setFilterLocalData(true);
    employeeTreeGrid.setKeepParentsOnFilter(true);
    employeeTreeGrid.setFilterOnKeypress(true);
    employeeTreeGrid.setDataSource(EmployeeXmlDS.getInstance());  
    employeeTreeGrid.setAutoFetchData(true);
    
    employeeTreeGrid.addDataArrivedHandler(new DataArrivedHandler() {
		
		@Override
		public void onDataArrived(DataArrivedEvent event) {
			employeeTreeGrid.getTree().openAll();			
		}
	});
    /*employeeTreeGrid.addFilterEditorSubmitHandler(new FilterEditorSubmitHandler() {
		
		@Override
		public void onFilterEditorSubmit(FilterEditorSubmitEvent event) {
			employeeTreeGrid.filterData(event.getCriteria());
			event.cancel();
		}
	});*/
  
    TreeGridField name=new TreeGridField("Name");
    name.setCanFilter(true);
    employeeTreeGrid.setFields(name);
    employeeTreeGrid.draw();  }

}
