PDA

View Full Version : dnd problem with panels



lokee103
1 Jun 2009, 11:23 PM
Hi all,

I'm new to gxt. What I'm trying to do is to drag and drop a vertical panel which contains other elements(panels, texts, etc...). I set the source and the target. When I'm trying to move the panel it displays the correct info when I'm over the target but when I release the mouse it won't add the panel to the target. I tried an example where the source was a text and it worked just ok.

Here's a snippet from the code that I used for the source:


final VerticalPanel verticalPanel = new VerticalPanel();

HorizontalPanel horizontalPanel = new HorizontalPanel();
Text someText = new Text("someTxt");
horizontalPanel.add(someText);

verticalPanel.add(horizontalPanel);


DragSource source = new DragSource(verticalPanel) {
@Override
protected void onDragStart(DNDEvent event) {
event.setData(verticalPanel);
event.getStatus().update(El.fly(verticalPanel.getElement()).cloneNode(true));
}
};

And for the target:


final LayoutContainer targetContainer= new LayoutContainer();
notStarted.setLayoutOnChange(true);

DropTarget targetContainerT= new DropTarget(targetContainer) {
@Override
protected void onDragDrop(DNDEvent event) {
super.onDragDrop(event);
VerticalPanel verticalPanel = (VerticalPanel) event.getData();
targetContainer.add(verticalPanel);
}
};
targetContainerT.setOverStyle("drag-ok");

I'd really appreciate some help. I've been googleing for some hours now on this.... but I didn't find any useful information or example where someone was using panels for dnd.

Thanks in advance,

--lokee