Drag and drop type?
Hey guys,
I'm contributing a section to Team Central and I would like to let people drag and drop work items into that section.
When a work item is dropped into my section, I'll pull some information out of it.
I've registered by drop target with DND.DROP_COPY | DND.DROP_DEFAULT but I get no notifications when I drop a RTC work item. Regular text works fine.
Is there a new type of drop operation that RTC uses? Any help would be greatly appreciated.
Thanks!
Eric.
I'm contributing a section to Team Central and I would like to let people drag and drop work items into that section.
When a work item is dropped into my section, I'll pull some information out of it.
I've registered by drop target with DND.DROP_COPY | DND.DROP_DEFAULT but I get no notifications when I drop a RTC work item. Regular text works fine.
Is there a new type of drop operation that RTC uses? Any help would be greatly appreciated.
Thanks!
Eric.
7 answers
Getting feedback for a drop operation depends on the kinds of Transfer you support. Make sure to support LocalSelectionTransfer and URIReferenceTransfer. Those are commonly used in RTC to contain a reference (or the actual selection) of work items. You can find an example in com.ibm.team.fulltext.ide.ui.internal.search.ArtifactSearchResultPage.hookDropSupport().
Ben
Foundation & Work Item
Ben
Foundation & Work Item
Hmm, well I've been able to find a reference to that class and I added it. I didn't realize that the RTC source code was available for download as well - that is incredibly useful.
Unfortunately my drop event still won't fire. I wasn't able to find the exact code that was suggested, but I did find some of the chat code which I believe does the same thing. I pretty much copied the following:
final DropTarget target= new DropTarget(fViewTabFolder, DND.DROP_LINK | DND.DROP_DEFAULT);
target.setTransfer(new Transfer[] { URIReferenceTransfer.getInstance()});
target.addDropListener(new ChatMeetingDropTargetListener());
But my control does not appear to accept the drop. Am I missing anything?
Thanks!
Eric.
Unfortunately my drop event still won't fire. I wasn't able to find the exact code that was suggested, but I did find some of the chat code which I believe does the same thing. I pretty much copied the following:
final DropTarget target= new DropTarget(fViewTabFolder, DND.DROP_LINK | DND.DROP_DEFAULT);
target.setTransfer(new Transfer[] { URIReferenceTransfer.getInstance()});
target.addDropListener(new ChatMeetingDropTargetListener());
But my control does not appear to accept the drop. Am I missing anything?
Thanks!
Eric.
Maybe a better example for you is the com.ibm.team.workitem.rcp.ui.internal.activation.ActiveWorkItemControl.addDropSupport(Control) because it works on Work Items.
A simple example where I get a Link-Feedback when dragging a Work Item over my Table is this code:
Table t= new Table(parent, SWT.BORDER);
final DropTarget target= new DropTarget(t, DND.DROP_LINK);
target.setTransfer(new Transfer[] { LocalSelectionTransfer.getTransfer() });
target.addDropListener(new DropTargetAdapter() {
@Override
public void dragEnter(final DropTargetEvent event) {
validateDrop(event);
}
@Override
public void dragOperationChanged(final DropTargetEvent event) {
validateDrop(event);
}
@Override
public void drop(final DropTargetEvent event) {
performDrop(event);
}
@Override
public void dropAccept(final DropTargetEvent event) {
validateDrop(event);
}
private void performDrop(final DropTargetEvent event) {
event.detail= DND.DROP_LINK;
}
private void validateDrop(final DropTargetEvent event) {
event.detail= DND.DROP_LINK;
}
});
Ben
A simple example where I get a Link-Feedback when dragging a Work Item over my Table is this code:
Table t= new Table(parent, SWT.BORDER);
final DropTarget target= new DropTarget(t, DND.DROP_LINK);
target.setTransfer(new Transfer[] { LocalSelectionTransfer.getTransfer() });
target.addDropListener(new DropTargetAdapter() {
@Override
public void dragEnter(final DropTargetEvent event) {
validateDrop(event);
}
@Override
public void dragOperationChanged(final DropTargetEvent event) {
validateDrop(event);
}
@Override
public void drop(final DropTargetEvent event) {
performDrop(event);
}
@Override
public void dropAccept(final DropTargetEvent event) {
validateDrop(event);
}
private void performDrop(final DropTargetEvent event) {
event.detail= DND.DROP_LINK;
}
private void validateDrop(final DropTargetEvent event) {
event.detail= DND.DROP_LINK;
}
});
Ben