Hy, how to DND a Canvas to a ListGrid ?
DND for Canvas to Canvas is working with DropOverHandler and DropHandler.
DND for ListGrid to ListGrid is working with DropOverHandler and DropHandler.
DND for Canvas to Canvas is working with DropOverHandler.
But adding DropHandler on ListGrid doesn't work. When i fire drop my drag Canvas on my ListGrid to drop, the DropHandler does not react.
Moving and dropping Canvas to Canvas :
onDropOver START on idCanvasDrag
drag object : class com.smartgwt.client.widgets.Canvas
onDropOver STOP on idCanvasDrag
onDrop START on idCanvasDrag
drag object : class com.smartgwt.client.widgets.Canvas
onDrop STOP on idCanvasDrag
Moving and dropping Canvas to Canvas :
onDropOver START on idCanvasDrag
drag object : class com.smartgwt.client.widgets.Canvas
onDropOver STOP on idCanvasDrag
??? where is the drop ???
Moving and dropping ListGrid to ListGrid :
onDropOver START on idListGridDrag
drag object : class com.smartgwt.client.widgets.grid.ListGrid
onDropOver STOP on idListGridDrag
onDrop START on idListGridDrag
drag object : class com.smartgwt.client.widgets.grid.ListGrid
onDrop STOP on idListGridDrag
Second question, when i add DropHandler on ListGrid, only the code in my handler is execute. The initial implementation of DND ListGrid to ListGrid disappears.
How to Override the DropHandler without replace it ?
Third (and last) question :)
When i leave java annotation @Override i can't build :
The method onDropOver(DropOverEvent) of type new DropOverHandler(){} must override a superclass method
SmartGwt doesn't support annotation ?
DND for Canvas to Canvas is working with DropOverHandler and DropHandler.
DND for ListGrid to ListGrid is working with DropOverHandler and DropHandler.
DND for Canvas to Canvas is working with DropOverHandler.
But adding DropHandler on ListGrid doesn't work. When i fire drop my drag Canvas on my ListGrid to drop, the DropHandler does not react.
Moving and dropping Canvas to Canvas :
onDropOver START on idCanvasDrag
drag object : class com.smartgwt.client.widgets.Canvas
onDropOver STOP on idCanvasDrag
onDrop START on idCanvasDrag
drag object : class com.smartgwt.client.widgets.Canvas
onDrop STOP on idCanvasDrag
Moving and dropping Canvas to Canvas :
onDropOver START on idCanvasDrag
drag object : class com.smartgwt.client.widgets.Canvas
onDropOver STOP on idCanvasDrag
??? where is the drop ???
Moving and dropping ListGrid to ListGrid :
onDropOver START on idListGridDrag
drag object : class com.smartgwt.client.widgets.grid.ListGrid
onDropOver STOP on idListGridDrag
onDrop START on idListGridDrag
drag object : class com.smartgwt.client.widgets.grid.ListGrid
onDrop STOP on idListGridDrag
Second question, when i add DropHandler on ListGrid, only the code in my handler is execute. The initial implementation of DND ListGrid to ListGrid disappears.
How to Override the DropHandler without replace it ?
Third (and last) question :)
When i leave java annotation @Override i can't build :
The method onDropOver(DropOverEvent) of type new DropOverHandler(){} must override a superclass method
SmartGwt doesn't support annotation ?
Code:
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.types.Alignment; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DragDataAction; import com.smartgwt.client.types.FieldType; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.util.EventHandler; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.events.DragStopEvent; import com.smartgwt.client.widgets.events.DragStopHandler; import com.smartgwt.client.widgets.events.DropEvent; import com.smartgwt.client.widgets.events.DropHandler; import com.smartgwt.client.widgets.events.DropOutEvent; import com.smartgwt.client.widgets.events.DropOutHandler; import com.smartgwt.client.widgets.events.DropOverEvent; import com.smartgwt.client.widgets.events.DropOverHandler; import com.smartgwt.client.widgets.grid.HeaderSpan; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.HLayout; /** * Entry point classes define <code>onModuleLoad()</code>. */ public class TestModuleSmartGwt implements EntryPoint { /** * This is the entry point method. */ public void onModuleLoad() { testDND(); } public void testDND() { HLayout hLayoutTop = new HLayout(); hLayoutTop.setMembersMargin(15); hLayoutTop.setLayoutMargin(15); Canvas canvastoDrag = new Canvas("idCanvasDrag"); canvastoDrag.setCanDrag(true); canvastoDrag.setCanDrop(true); canvastoDrag.setContents("My contents (object to drag)"); canvastoDrag.setBorder("2px solid blue"); Canvas canvasToDropIn = new Canvas("idCanvasDrop"); canvasToDropIn.setCanAcceptDrop(true); canvasToDropIn.setContents("My contents (drop here)"); canvasToDropIn.setBorder("2px solid red"); canvasToDropIn.addDropOverHandler(new DropOverHandler() { // @Override public void onDropOver(DropOverEvent event) { Object draggable = EventHandler.getDragTarget(); Canvas droppable = EventHandler.getDragTarget(); System.out.println("onDropOver START on "+droppable.getID()); System.out.println("drag object : "+draggable.getClass()); System.out.println("onDropOver STOP on "+droppable.getID()); } }); canvasToDropIn.addDropHandler(new DropHandler() { // @Override public void onDrop(DropEvent event) { Object draggable = EventHandler.getDragTarget(); Canvas droppable = EventHandler.getDragTarget(); System.out.println("onDrop START on "+droppable.getID()); System.out.println("drag object : "+draggable.getClass()); System.out.println("onDrop STOP on "+droppable.getID()); } }); int nbr = 3; ListGridRecord listGridRecord[] = new ListGridRecord[nbr]; for( int i=0; i<nbr; i++) { listGridRecord[i] = new ListGridRecord(); listGridRecord[i].setAttribute("ID", "col_id_value_"+i); listGridRecord[i].setAttribute("TXT", "col_txt_value_"+i); } ListGridField col1 = new ListGridField("ID"); ListGridField col2 = new ListGridField("TXT"); ListGrid listGridToDrag = new ListGrid(); listGridToDrag.setCanAcceptDrop(true); listGridToDrag.setWidth(200); listGridToDrag.setHeight(224); listGridToDrag.setID("idListGridDrag"); listGridToDrag.setCanDrag(true); listGridToDrag.setCanDragRecordsOut(true); listGridToDrag.setCanDrop(true); listGridToDrag.setDragDataAction(DragDataAction.MOVE); listGridToDrag.setRecords(listGridRecord); listGridToDrag.setFields(col1, col2); ListGrid listGridToDropIn = new ListGrid(); listGridToDropIn.setCanAcceptDrop(true); listGridToDropIn.setCanAcceptDroppedRecords(true); listGridToDropIn.setWidth(200); listGridToDropIn.setHeight(224); listGridToDropIn.setID("idListGridDrop"); listGridToDropIn.setCanAcceptDrop(true); listGridToDropIn.addDropOverHandler(new DropOverHandler() { // @Override public void onDropOver(DropOverEvent event) { Object draggable = EventHandler.getDragTarget(); Canvas droppable = EventHandler.getDragTarget(); System.out.println("onDropOver START on "+droppable.getID()); System.out.println("drag object : "+draggable.getClass()); System.out.println("onDropOver STOP on "+droppable.getID()); } }); listGridToDropIn.addDropHandler(new DropHandler() { // @Override public void onDrop(DropEvent event) { Object draggable = EventHandler.getDragTarget(); Canvas droppable = EventHandler.getDragTarget(); System.out.println("onDrop START on "+droppable.getID()); System.out.println("drag object : "+draggable.getClass()); System.out.println("onDrop STOP on "+droppable.getID()); } }); hLayoutTop.addMember(canvastoDrag); hLayoutTop.addMember(canvasToDropIn); hLayoutTop.addMember(listGridToDropIn); hLayoutTop.addMember(listGridToDrag); RootPanel.get().add(hLayoutTop); } }
Comment