/* * GWT-Ext Widget Library * Copyright(c) 2007-2008, GWT-Ext. * licensing@gwt-ext.com * * http://www.gwt-ext.com/license */ import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel; import com.gwtext.client.util.Format; import com.gwtext.client.widgets.Panel; import com.gwtext.client.widgets.form.TimeField; import com.gwtext.client.widgets.grid.GridEditor; import com.gwtext.client.widgets.grid.GridView; import com.gwtext.client.widgets.grid.PropertyGridPanel; import com.gwtext.client.widgets.grid.event.PropertyGridPanelListener; import java.util.Date; import java.util.HashMap; import java.util.Map; public class PropertyGridSample implements EntryPoint { public void onModuleLoad() { Panel panel = new Panel(); panel.setBorder(false); panel.setPaddings(15); PropertyGridPanel grid = new PropertyGridPanel(); grid.setId("props-grid"); grid.setNameText("Properties Grid"); grid.setWidth(300); grid.setAutoHeight(true); GridView view = new GridView(); view.setForceFit(true); view.setScrollOffset(2); // the grid will never have scrollbars grid.setView(view); Map source = new HashMap(); source.put("(name)", "Properties Grid"); source.put("grouping", Boolean.FALSE); source.put("autoFitColumns", Boolean.TRUE); source.put("productionQuality", Boolean.FALSE); source.put("created", new Date()); source.put("tested", Boolean.FALSE); source.put("version", new Float(0.1f)); source.put("borderWidth", new Integer(1)); Map customEditors = new HashMap(); GridEditor timeEditor = new GridEditor(new TimeField()); customEditors.put("Edit Time", timeEditor); grid.setCustomEditors(customEditors); grid.setSource(source); grid.addPropertyGridPanelListener(new PropertyGridPanelListener() { public boolean doBeforePropertyChange(PropertyGridPanel source, String recordID, Object value, Object oldValue) { return true; } public void onPropertyChange(PropertyGridPanel source, String recordID, Object value, Object oldValue) { System.out.println(Format.format("Property '{0}' changed from {1} to {2}.", recordID, String.valueOf(oldValue), String.valueOf(value))); } }); panel.add(grid); RootPanel.get().add(panel); } }