/* * 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.data.Record; import com.smartgwt.client.types.DragDataAction; import com.smartgwt.client.util.EventHandler; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.TransferImgButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.events.DragStartEvent; import com.smartgwt.client.widgets.events.DragStartHandler; import com.smartgwt.client.widgets.layout.HStack; import com.smartgwt.sample.showcase.client.data.PartData; import com.google.gwt.core.client.EntryPoint; public class RecordsAcrossWindowsSample implements EntryPoint { @Override public void onModuleLoad() { final PartsListGrid myList1 = new PartsListGrid(); myList1.setID("myList1"); Record[] data = PartData.getRecords(); myList1.setData(data); myList1.setCanDragRecordsOut(true); myList1.setCanReorderRecords(true); myList1.setUseNativeDrag(true); myList1.setDragDataAction(DragDataAction.COPY); myList1.setDragType("partsListRecord"); myList1.addDragStartHandler(new DragStartHandler() { @Override public void onDragStart(DragStartEvent event) { final Record[] dragData = myList1.getDragData(); if (dragData != null && dragData.length != 0) { final Record record = dragData[0]; EventHandler.setDragTrackerImage("pieces/16/" + record.getAttributeAsString("partSrc"), 12, 12); } } }); final PartsListGrid myList2 = new PartsListGrid(); myList2.setID("myList2"); myList2.setCanAcceptDroppedRecords(true); myList2.setCanReorderRecords(true); final TransferImgButton transferImgButton = new TransferImgButton(TransferImgButton.RIGHT); transferImgButton.setID("transferButton"); transferImgButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { myList2.transferSelectedData(myList1); } }); final HStack hstack = new HStack(10); hstack.setHeight(160); hstack.setMembers(myList1, transferImgButton, myList2); hstack.draw(); } protected boolean isTopIntro() { return true; } }