Drag n Drop for Editor and DITA Maps Manager
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 17
- Joined: Tue Sep 05, 2023 12:14 am
Drag n Drop for Editor and DITA Maps Manager
Hello Team,
I am trying to implement drag (from my custom panel) and drop operation for both Editor and DITA Maps Manager where I want to transfer path (String) from custom panel.
For editor I am implementing custom AuthorDnDListener. For DITA Maps Manager I am extending custom DITAMapTreeDropHandler.
As per my testing it looks like DITAMapTreeDropHandler is accepting only DataFlavor.javaFileListFlavor where it is converting File list into URL list to execute consumeDropURLs() function and I'm unable to use DataFlavor.stringFlavor for DITAMapTreeDropHandler.
In case of AuthorDnDListener I'm able to transfer String with DataFlavor.stringFlavor, but with DataFlavor.javaFileListFlavor it is not executing authorDrop() function of AuthorDnDListener.
For DataFlavor.javaFileListFlavor editor is trying to open the file. This seem like default behaviour for editor in oxygen and I'm not able to override this behaviour with AuthorDnDListener for DataFlavor.javaFileListFlavor.
I am not able to figure out DataFlavor for Transferable to implement drag and drop operation for both Editor and DITA Maps Manager.
Can you please suggest a solution to implement custom Drag (from my custom panel) and Drop for both Editor and DITA Maps Manager?
Thanks,
AbhiK
I am trying to implement drag (from my custom panel) and drop operation for both Editor and DITA Maps Manager where I want to transfer path (String) from custom panel.
For editor I am implementing custom AuthorDnDListener. For DITA Maps Manager I am extending custom DITAMapTreeDropHandler.
As per my testing it looks like DITAMapTreeDropHandler is accepting only DataFlavor.javaFileListFlavor where it is converting File list into URL list to execute consumeDropURLs() function and I'm unable to use DataFlavor.stringFlavor for DITAMapTreeDropHandler.
In case of AuthorDnDListener I'm able to transfer String with DataFlavor.stringFlavor, but with DataFlavor.javaFileListFlavor it is not executing authorDrop() function of AuthorDnDListener.
For DataFlavor.javaFileListFlavor editor is trying to open the file. This seem like default behaviour for editor in oxygen and I'm not able to override this behaviour with AuthorDnDListener for DataFlavor.javaFileListFlavor.
I am not able to figure out DataFlavor for Transferable to implement drag and drop operation for both Editor and DITA Maps Manager.
Can you please suggest a solution to implement custom Drag (from my custom panel) and Drop for both Editor and DITA Maps Manager?
Thanks,
AbhiK
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Drag n Drop for Editor and DITA Maps Manager
Hi Abnik,
Please see some remarks below:
Besides the DataFlavor.javaFileListFlavor flavor the DITAMapTreeDropHandler will be called for other custom flavors which may contain URLs in string format:
Can you give me an example about what content is in that string you are attempting to drop?
For the Author editor page we have a separate API "AuthorExternalObjectInsertionHandler" which has callback methods which get called when pasting or drag and dropping URL-like content:
https://www.oxygenxml.com/doc/versions/ ... ndler.html
Regards,
Radu
Please see some remarks below:
Yes, the DITAMapTreeDropHandler is targered towards accepting dropped references to resources in order to create topic references in the DITA Map.As per my testing it looks like DITAMapTreeDropHandler is accepting only DataFlavor.javaFileListFlavor where it is converting File list into URL list to execute consumeDropURLs() function and I'm unable to use DataFlavor.stringFlavor for DITAMapTreeDropHandler.
Besides the DataFlavor.javaFileListFlavor flavor the DITAMapTreeDropHandler will be called for other custom flavors which may contain URLs in string format:
Code: Select all
/**
* Flavor used for DnD of files on Mac OS X / Linux platforms.
*/
DataFlavor FLAVOR_LINUX_LIST_OF_URIs = new DataFlavor("text/uri-list;class=java.lang.String", null);
You mentioned you are only interested in pasting plain strings, now do you want also to paste a file list flavor?In case of AuthorDnDListener I'm able to transfer String with DataFlavor.stringFlavor, but with DataFlavor.javaFileListFlavor it is not executing authorDrop() function of AuthorDnDListener.
For the Author editor page we have a separate API "AuthorExternalObjectInsertionHandler" which has callback methods which get called when pasting or drag and dropping URL-like content:
https://www.oxygenxml.com/doc/versions/ ... ndler.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 17
- Joined: Tue Sep 05, 2023 12:14 am
Re: Drag n Drop for Editor and DITA Maps Manager
Hi Radu,
Thank you for replying.
I have tried the flavour mentioned by you, but it is not working for me. Please check my custom class for Transferable:
These are the logs I'm getting for CustomTransferable:
I have tried all the flavours mentioned in logs, but only "application/x-java-file-list;class=java.util.List" (which is DataFlavor.javaFileListFlavor) is working for me.
Content of the string is path of the file located at remote server. (e.g. path = "/content/folder/sample.dita"). I want to do some custom operation after receiving the file path. I have also tried (path = "file:/content/folder/sample.dita" ) so that it can be converted into URL, but it is not working.
Can you please check if I'm missing something?
Thank you for replying.
I have tried the flavour mentioned by you, but it is not working for me. Please check my custom class for Transferable:
Code: Select all
public class CustomTransferable implements Transferable {
private static final Logger LOG = LoggerFactory.getLogger("TAG_CustomTransferable");
private static final DataFlavor customFlavor = new DataFlavor("text/uri-list;class=java.lang.String", null);
String path;
public CustomTransferable(String path) {
this.path = path;
}
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[]{customFlavor};
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
LOG.debug("CustomTransferable DataFlavor support check for flavor=" + flavor);
return flavor == customFlavor;
}
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor == customFlavor) {
return path;// path = "/content/folder/sample.dita";
}
throw new UnsupportedFlavorException(flavor);
}
}
Code: Select all
47448 DEBUG [ AWT-EventQueue-0 ] TAG_CustomTransferable - CustomTransferable DataFlavor support check for flavor=ro.sync.ui.k.b.b$_b[mimetype=application/x-java-serialized-object;representationclass=javax.swing.tree.TreePath]
47448 DEBUG [ AWT-EventQueue-0 ] TAG_CustomTransferable - CustomTransferable DataFlavor support check for flavor=java.awt.datatransfer.DataFlavor[mimetype=application/x-java-url;representationclass=java.net.URL]
47448 DEBUG [ AWT-EventQueue-0 ] TAG_CustomTransferable - CustomTransferable DataFlavor support check for flavor=java.awt.datatransfer.DataFlavor[mimetype=text/uri-list;representationclass=java.lang.String]
47448 DEBUG [ AWT-EventQueue-0 ] TAG_CustomTransferable - CustomTransferable DataFlavor support check for flavor=java.awt.datatransfer.DataFlavor[mimetype=text/uri-list;representationclass=java.io.InputStream;charset=UTF-8]
47448 DEBUG [ AWT-EventQueue-0 ] TAG_CustomTransferable - CustomTransferable DataFlavor support check for flavor=ro.sync.ui.k.c[mimetype=application/x-java-serialized-object;representationclass=java.util.List]
47448 DEBUG [ AWT-EventQueue-0 ] TAG_CustomTransferable - CustomTransferable DataFlavor support check for flavor=ro.sync.ui.k.c[mimetype=application/x-java-serialized-object;representationclass=java.net.URL]
47448 DEBUG [ AWT-EventQueue-0 ] TAG_CustomTransferable - CustomTransferable DataFlavor support check for flavor=ro.sync.ui.k.c[mimetype=application/x-java-serialized-object;representationclass=java.net.URL]
47448 DEBUG [ AWT-EventQueue-0 ] TAG_CustomTransferable - CustomTransferable DataFlavor support check for flavor=ro.sync.ui.k.c[mimetype=application/x-java-serialized-object;representationclass=java.net.URL]
47448 DEBUG [ AWT-EventQueue-0 ] TAG_CustomTransferable - CustomTransferable DataFlavor support check for flavor=java.awt.datatransfer.DataFlavor[mimetype=application/x-java-file-list;representationclass=java.util.List]
47448 DEBUG [ AWT-EventQueue-0 ] TAG_CustomTransferable - CustomTransferable DataFlavor support check for flavor=java.awt.datatransfer.DataFlavor[mimetype=application/x-java-file-list;representationclass=java.util.List]
Content of the string is path of the file located at remote server. (e.g. path = "/content/folder/sample.dita"). I want to do some custom operation after receiving the file path. I have also tried (path = "file:/content/folder/sample.dita" ) so that it can be converted into URL, but it is not working.
Can you please check if I'm missing something?
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Drag n Drop for Editor and DITA Maps Manager
Hi,
So you are trying to use the code you pasted below for dropping into the DITA Maps Manager view, correct?
Instead of comparing your objects with "flavor == customFlavor" in those two places could you compare them with "flavor.equals(customFlavor)"?
Also the strings you send need to be proper URLs as Oxygen will attempt to create an URL object over them.
So maybe instead of "/content/folder/sample.dita" you could try to pass something like "http://custom-flavor/content/folder/sample.dita" and then on the other side recover the path from the URL and process it further.
Regards,
Radu
So you are trying to use the code you pasted below for dropping into the DITA Maps Manager view, correct?
Instead of comparing your objects with "flavor == customFlavor" in those two places could you compare them with "flavor.equals(customFlavor)"?
Also the strings you send need to be proper URLs as Oxygen will attempt to create an URL object over them.
So maybe instead of "/content/folder/sample.dita" you could try to pass something like "http://custom-flavor/content/folder/sample.dita" and then on the other side recover the path from the URL and process it further.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 17
- Joined: Tue Sep 05, 2023 12:14 am
Re: Drag n Drop for Editor and DITA Maps Manager
Hi Radu,
Thank you for the response.
Using dataflavor "text/uri-list;class=java.lang.String" and string path like "http://custom-flavor/content/folder/sample.dita" is working fine with DITA Maps Manager.
But same is not working with Editor.
When I use the mentioned dataflavor and http path for Editor, I'm getting security popup (check popup.png).
Should I use AuthorExternalObjectInsertionHandler instead of AuthorDnDListener?
Is it feasible for DITA Maps Manager to consume dropped Transferable of DataFlavor.stringFlavor?
Regards,
Abhi_K
Thank you for the response.
Using dataflavor "text/uri-list;class=java.lang.String" and string path like "http://custom-flavor/content/folder/sample.dita" is working fine with DITA Maps Manager.
But same is not working with Editor.
When I use the mentioned dataflavor and http path for Editor, I'm getting security popup (check popup.png).
popup.png
For url like dataflavors, the Editor is trying to connect to the dropped url and it is not executing authorDrop() function of my custom AuthorDnDListener. I have tried using other protocols in string (ftp://,mailto:), but editor is still trying to connect to the dropped url and I'm getting the security popup.Should I use AuthorExternalObjectInsertionHandler instead of AuthorDnDListener?
Is it feasible for DITA Maps Manager to consume dropped Transferable of DataFlavor.stringFlavor?
Regards,
Abhi_K
You do not have the required permissions to view the files attached to this post.
Last edited by abhik on Fri Sep 08, 2023 10:18 pm, edited 2 times in total.
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service