package com.tempusnova.richtext.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.RichTextItem;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class RichTextItemTest implements EntryPoint {
	
	public void onModuleLoad() {
		
		DataSourceField richTextDsf = null;
		// Set up a custom rich text item to use as the editor type
		RichTextItem richTextItem = new RichTextItem();
		richTextItem.setControlGroups("fontControls", "formatControls", "styleControls");
		richTextItem.setShouldSaveValue(true);
		
		richTextDsf = new DataSourceTextField("richTextItem");
		richTextDsf.setEditorType(richTextItem);
		
		DataSource ds = new DataSource();
		ds.addField(richTextDsf);
		
		final DynamicForm form = new DynamicForm();
		// Form item that will match up with the DataSourceTextField with name "richTextItem"
		FormItem formItem = new FormItem("richTextItem");
		form.setFields(formItem);
		form.setDataSource(ds);
		
	    RootPanel.get().add(form);
	}
}
