Rvanlaak
4 May 2009, 1:28 AM
When using the DnD functionality, I want to disable the dragSource when an event happens. I've got it working, but it seems GXT doesn't really disable the dragging, but only hides the content. It is still possible to drag and it leaves a artifact at the right bottom of the mouse cursor (as shown on screenshot)
Code sample (without get/setters and imports) :
public class QueueCurrent extends LayoutContainer {
private Html html;
private String callerNumber;
private String sourceChannel;
private Button redirectButton;
private Button notesButton;
private NoteDetailsWindow noteWindow = new NoteDetailsWindow();
private DragSource source;
private StaticServiceAsync asterSvc = GWT.create(StaticService.class);
public QueueCurrent() {
setLayoutOnChange(true);
setBorders(true);
setSize(200, 50);
html = new Html();
add(html, new FlowData(3));
source = new DragSource(html) {
@Override
protected void onDragStart(DNDEvent event) {
// by default drag is allowed
event.setData(html);
event.getStatus().update(
El.fly(html.getElement()).cloneNode(true));
}
@Override
protected void onDragDrop(DNDEvent event) {
super.onDragDrop(event);
System.out.println("DragSource: " + event.getDragSource());
System.out.println("DropTarget: " + event.getDropTarget());
}
};
// group is optional
source.setGroup("dnd-call");
// Set initial state
unsetCallData();
}
/**
* Set the source channel of the DnD box, needed for redirecting
*/
public void setCallData(String name, String sourceChannel, String callerNumber) {
html.setHtml(name);
html.setStyleName("queueCurrent-active");
html.setToolTip("Kanaal: " + sourceChannel);
setSourceChannel(sourceChannel);
setCallerNumber(callerNumber);
redirectButton.setEnabled(true);
notesButton.setEnabled(true);
source.enable();
}
public void unsetCallData( ) {
html.setHtml("---");
html.setStyleName("queueCurrent-inactive");
html.hideToolTip();
setSourceChannel(null);
setCallerNumber(null);
redirectButton.setEnabled(false);
notesButton.setEnabled(false);
source.disable();
}
}
Code sample (without get/setters and imports) :
public class QueueCurrent extends LayoutContainer {
private Html html;
private String callerNumber;
private String sourceChannel;
private Button redirectButton;
private Button notesButton;
private NoteDetailsWindow noteWindow = new NoteDetailsWindow();
private DragSource source;
private StaticServiceAsync asterSvc = GWT.create(StaticService.class);
public QueueCurrent() {
setLayoutOnChange(true);
setBorders(true);
setSize(200, 50);
html = new Html();
add(html, new FlowData(3));
source = new DragSource(html) {
@Override
protected void onDragStart(DNDEvent event) {
// by default drag is allowed
event.setData(html);
event.getStatus().update(
El.fly(html.getElement()).cloneNode(true));
}
@Override
protected void onDragDrop(DNDEvent event) {
super.onDragDrop(event);
System.out.println("DragSource: " + event.getDragSource());
System.out.println("DropTarget: " + event.getDropTarget());
}
};
// group is optional
source.setGroup("dnd-call");
// Set initial state
unsetCallData();
}
/**
* Set the source channel of the DnD box, needed for redirecting
*/
public void setCallData(String name, String sourceChannel, String callerNumber) {
html.setHtml(name);
html.setStyleName("queueCurrent-active");
html.setToolTip("Kanaal: " + sourceChannel);
setSourceChannel(sourceChannel);
setCallerNumber(callerNumber);
redirectButton.setEnabled(true);
notesButton.setEnabled(true);
source.enable();
}
public void unsetCallData( ) {
html.setHtml("---");
html.setStyleName("queueCurrent-inactive");
html.hideToolTip();
setSourceChannel(null);
setCallerNumber(null);
redirectButton.setEnabled(false);
notesButton.setEnabled(false);
source.disable();
}
}