Sample code for allowing drag-and-drop of Notes/Domino documents (including email) to a table in a plugin
Posted: - Modified: | geek, lotusBecause I had to piece this together from examples on the Internet, and probably other people do too:
Transfer[] transferArray = new Transfer[]{ XMLTransfer.getInstance(), }; tableViewer.addDropSupport(DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK, transferArray, new DropTargetAdapter() { public void drop(DropTargetEvent event) { TableItem item = (TableItem) event.item; // You can access the object with item.getData() try { NotesThread.sinitThread(); Session session = NotesFactory.createSessionWithFullAccess(); if (event.data instanceof URIDescriptor[]){ URIDescriptor[] droppedURL = (URIDescriptor[]) event.data; for (int i = 0; i < droppedURL.length; i++) { URI uri = ((URIDescriptor) droppedURL[i]).uri; Document d = (Document) session.resolve(uri.toString()); // Do things with the document } } } catch (Exception e) { e.printStackTrace(); } finally { NotesThread.stermThread(); } }});
Use session.resolve instead of db.getDocumentByURL to retrieve a document from a plugin, as both session.getAgentContext() and session.getCurrentDatabase() will return null.
2 comments
samrat
2010-08-18T15:44:19ZHi Sacha,
Thank you for sharing this code, this showed me some light in the dark path of drag and drop fom Lotus to java app...
I need to build a system where users should be able to drag and drop emails from lotus noes client, and the dropped document should get saved in some other database as dxl file.
Again when user double click the mails in the second system it should get open in lotus client again.
do you have any clue on that? I know how to generate DXL and parsing DXL.......
I am seeking for any clue how the other system get the handle of the dropped mail document...
thanking you in advance.....
regards,
Samrat Roy
C LEE
2010-09-28T13:30:51ZThank you for your sharing but I am sorry to say that I still cannot understand the full picture on how it works because I am new in Lotus Expeditor and Eclipse SWT. I would like to know is it possible to do drag and drop in Lotus Notes in this way: Drag an email to the lotus notes sidebar (the sidebar shows folder hierarchy). When the email is dragged to the specific folder, the email will be saved to that particular directory.
Thank you very much.
Regards,
C LEE