It's all about the answers!

Ask a question

Drag and drop type?


Eric Lee (1462412) | asked Aug 24 '08, 9:15 p.m.
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.

7 answers



permanent link
Work Item & UI Commons Team (1.3k1) | answered Aug 25 '08, 4:35 a.m.
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

permanent link
Eric Lee (1462412) | answered Aug 25 '08, 12:39 p.m.
Great thanks for the help!

Sorry, really dumb question - when you say there is an example in com.ibm.team.fulltext.ide.ui.internal.search.ArtifactSearchResultPage.hookDropSupport

what source code are you referring to and where do I get it?

Thanks!

Eric.

permanent link
Eric Lee (1462412) | answered Aug 25 '08, 1:00 p.m.
I couldn't find any references to URIReferenceTransfer, can you tell me what the fully qualified name of that class is?

Thanks!

Eric.

permanent link
Eric Lee (1462412) | answered Aug 25 '08, 11:17 p.m.
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.

permanent link
Work Item & UI Commons Team (1.3k1) | answered Aug 26 '08, 5:35 a.m.
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

permanent link
Eric Lee (1462412) | answered Aug 26 '08, 9:35 p.m.
That worked!!! Thanks for your help, I really appreciate it!

I'm really amazed at how relatively easy it is to extend Eclipse/RTC. This was my first plug-in for Eclipse and all things considered it has been a really pleasant experience.

Thanks!

Eric.

permanent link
Work Item & UI Commons Team (1.3k1) | answered Aug 27 '08, 4:48 a.m.
Great to hear that, enjoy :)

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.