/* * 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.smartgwt.client.types.DeviceMode; import com.smartgwt.client.types.PageOrientation; import com.smartgwt.client.util.Page; import com.smartgwt.client.util.Browser; import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.events.RecordClickEvent; import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.layout.SplitPane; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.tree.TreeGrid; import com.smartgwt.client.widgets.tree.events.NodeClickEvent; import com.smartgwt.client.widgets.tree.events.NodeClickHandler; import com.smartgwt.client.widgets.viewer.DetailViewer; import com.smartgwt.sample.showcase.client.data.ItemSupplyXmlDS; import com.smartgwt.sample.showcase.client.data.SupplyCategoryXmlDS; import com.google.gwt.core.client.EntryPoint; public class SplitPaneSample extends VLayout implements EntryPoint { public Canvas createSplitPane() { final SplitPane splitPane = new SplitPane(); splitPane.setAutoDraw(Boolean.FALSE); splitPane.setNavigationTitle("Categories"); splitPane.setShowLeftButton(false); splitPane.setShowRightButton(false); splitPane.setBorder("1px solid blue"); final DetailViewer detailPane = new DetailViewer(); detailPane.setDataSource(ItemSupplyXmlDS.getInstance()); detailPane.setAutoDraw(Boolean.FALSE); final ListGrid listPane = new ListGrid(); listPane.setDataSource(ItemSupplyXmlDS.getInstance()); listPane.setAutoDraw(Boolean.FALSE); listPane.addRecordClickHandler(new RecordClickHandler() { @Override public void onRecordClick(RecordClickEvent event) { detailPane.viewSelectedData(listPane); splitPane.setDetailTitle((event.getRecordNum() + 1) + " of " + listPane.getTotalRows()); splitPane.showDetailPane(); } }); if (Browser.getIsTablet()) { ListGridField itemNameField = new ListGridField("itemName"); ListGridField unitCostField = new ListGridField("unitCost"); ListGridField inStockField = new ListGridField("inStock"); listPane.setFields(itemNameField, unitCostField, inStockField); } final TreeGrid navigationPane = new TreeGrid(); navigationPane.setAutoDraw(Boolean.TRUE); navigationPane.setDataSource(SupplyCategoryXmlDS.getInstance()); navigationPane.setAutoFetchData(Boolean.TRUE); navigationPane.setShowHeader(Browser.getIsDesktop()); navigationPane.addNodeClickHandler(new NodeClickHandler() { @Override public void onNodeClick(NodeClickEvent event) { listPane.fetchRelatedData(event.getNode(), navigationPane); splitPane.setListTitle(event.getNode().getAttribute("categoryName")); splitPane.showListPane(); } }); splitPane.setDetailPane(detailPane); splitPane.setNavigationPane(navigationPane); splitPane.setListPane(listPane); return splitPane; } public void onModuleLoad() { setWidth100(); setHeight100(); addMember(createSplitPane()); draw(); } }