/* * 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 java.util.HashMap; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.types.DragAppearance; import com.smartgwt.client.types.TextMatchStyle; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.events.ItemChangedHandler; import com.smartgwt.client.widgets.form.events.ItemChangedEvent; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.tile.TileGrid; import com.smartgwt.client.widgets.viewer.DetailViewerField; import com.smartgwt.sample.showcase.client.data.AnimalXmlDS; import com.google.gwt.core.client.EntryPoint; public class RecategorizeTilingSample implements EntryPoint { public void onModuleLoad() { final TileGrid boundList1 = new TileGrid(); boundList1.setWidth(400); boundList1.setHeight(400); boundList1.setTileWidth(150); boundList1.setTileHeight(185); boundList1.setHeight(400); boundList1.setShowAllRecords(true); boundList1.setDataSource(AnimalXmlDS.getInstance()); boundList1.setAutoFetchData(true); Criteria initialCriteria1 = new Criteria(); initialCriteria1.addCriteria("status", "Endangered"); boundList1.setInitialCriteria(initialCriteria1); boundList1.setAutoFetchTextMatchStyle(TextMatchStyle.EXACT); boundList1.setAnimateTileChange(true); boundList1.setCanAcceptDroppedRecords(true); boundList1.setCanDragTilesOut(true); boundList1.setTileDragAppearance(DragAppearance.TARGET); DetailViewerField pictureField1 = new DetailViewerField("picture"); DetailViewerField commonNameField1 = new DetailViewerField("commonName"); DetailViewerField statusField1 = new DetailViewerField("status"); boundList1.setFields(pictureField1, commonNameField1, statusField1); SelectItem statusItem1 = new SelectItem(); statusItem1.setName("status"); statusItem1.setTitle("<b>Status</b>"); statusItem1.setDefaultValue("Endangered"); HashMap map1 = new HashMap(); map1.put("Threatened", "Threatened"); map1.put("Endangered", "Endangered"); map1.put("Not Endangered", "Not Endangered"); map1.put("Not currently listed", "Not currently listed"); map1.put("May become threatened", "May become threatened"); map1.put("Protected", "Protected"); statusItem1.setValueMap(map1); final DynamicForm form1 = new DynamicForm(); form1.setFields(statusItem1); form1.addItemChangedHandler(new ItemChangedHandler() { @Override public void onItemChanged(ItemChangedEvent event) { boundList1.fetchData(form1.getValuesAsCriteria()); } }); final TileGrid boundList2 = new TileGrid(); boundList2.setWidth(400); boundList2.setHeight(400); boundList2.setTileWidth(150); boundList2.setTileHeight(185); boundList2.setHeight(400); boundList2.setShowAllRecords(true); boundList2.setDataSource(AnimalXmlDS.getInstance()); boundList2.setAutoFetchData(true); Criteria initialCriteria2 = new Criteria(); initialCriteria2.addCriteria("status", "Threatened"); boundList2.setInitialCriteria(initialCriteria2); boundList2.setAutoFetchTextMatchStyle(TextMatchStyle.EXACT); boundList2.setAnimateTileChange(true); boundList2.setCanAcceptDroppedRecords(true); boundList2.setCanDragTilesOut(true); boundList2.setTileDragAppearance(DragAppearance.TARGET); DetailViewerField pictureField2 = new DetailViewerField("picture"); DetailViewerField commonNameField2 = new DetailViewerField("commonName"); DetailViewerField statusField2 = new DetailViewerField("status"); boundList2.setFields(pictureField2, commonNameField2, statusField2); SelectItem statusItem2 = new SelectItem(); statusItem2.setName("status"); statusItem2.setTitle("<b>Status</b>"); statusItem2.setDefaultValue("Threatened"); HashMap map2 = new HashMap(); map2.put("Threatened", "Threatened"); map2.put("Endangered", "Endangered"); map2.put("Not Endangered", "Not Endangered"); map2.put("Not currently listed", "Not currently listed"); map2.put("May become threatened", "May become threatened"); map2.put("Protected", "Protected"); statusItem2.setValueMap(map2); final DynamicForm form2 = new DynamicForm(); form2.setFields(statusItem2); form2.addItemChangedHandler(new ItemChangedHandler() { @Override public void onItemChanged(ItemChangedEvent event) { boundList2.fetchData(form2.getValuesAsCriteria()); } }); VLayout vLayout1 = new VLayout(); vLayout1.addMember(form1); vLayout1.addMember(boundList1); VLayout vLayout2 = new VLayout(); vLayout2.addMember(form2); vLayout2.addMember(boundList2); HLayout hLayout = new HLayout(); hLayout.setMembersMargin(10); hLayout.addMember(vLayout1); hLayout.addMember(vLayout2); hLayout.draw(); } }