AuthorDnDListener Sample
Post here questions and problems related to oXygen frameworks/document types.
AuthorDnDListener Sample
Hi, I'm trying to implement a drag and drop listener in the authoring environment. Essentially what I am looking for is the ability to allow files to be dragged from a project or folder, and then have an element added to the target document which references the dropped file via an href attribute (similar to the way images are handled with the DITA framework).
I found this page which I believe describes the functionality, but I haven't had any luck finding any in-depth information or examples in the referenced SDK documentation.
I have a framework extension created that extends AuthorDnDListener and have been able to debug it. I catch an authorDragEnter event, but whether I return true or false, I don't seem to catch any other events (presuming I'm looking for authorDragExit).
Any information you can point me to would be very much appreciated.
Brian
I found this page which I believe describes the functionality, but I haven't had any luck finding any in-depth information or examples in the referenced SDK documentation.
I have a framework extension created that extends AuthorDnDListener and have been able to debug it. I catch an authorDragEnter event, but whether I return true or false, I don't seem to catch any other events (presuming I'm looking for authorDragExit).
Any information you can point me to would be very much appreciated.
Brian
Re: AuthorDnDListener Sample
I think I found my answer. The DITA framework apparently does not use the drag and drop handler, but instead uses an ExternalObjectInsertionHandler called DITAMapExternalObjectInsertionHandler. Still wouldn't mind seeing a sample DnD handler, but I think this alternative method will work for what I was trying to do. For anyone else that happens across this, here's what my modified version looks like:
Code: Select all
@API(type=APIType.INTERNAL, src=SourceType.PUBLIC)
public class ExternalObjectInsertionHandler extends AuthorExternalObjectInsertionHandler{
@Override
public void insertURLs(AuthorAccess authorAccess, List<URL> urls, int source) throws AuthorOperationException
{
if(! urls.isEmpty())
{
URL base = getBaseURLAtCaretPosition(authorAccess);
for (int i = 0; i < urls.size(); i++) {
URL url = urls.get(i);
// Obtain the relative url from the given url.
String relativeLocation = authorAccess.getUtilAccess().makeRelative(base, url);
//Probably add a topicref to it.
int cp = authorAccess.getEditorAccess().getCaretOffset();
String extension = authorAccess.getUtilAccess().getExtension(url);
String filename = relativeLocation.substring(0, relativeLocation.lastIndexOf('.'));
SchemaAwareHandlerResult result;
if ( "ngpsmap".equals(extension) )
{
result = authorAccess.getDocumentController().insertXMLFragmentSchemaAware(
"<MAPREF UniqueID=\"" + filename + "\" "
+ "HREF=\"" + relativeLocation + "\" "
+ "CHG=\"U\" "
+ "/>",
cp,
true);
}
else
{
result = authorAccess.getDocumentController().insertXMLFragmentSchemaAware(
"<ITEMREF UniqueID=\"" + filename + "\" "
+ "HREF=\"" + relativeLocation + "\" "
+ "CHG=\"U\" "
+ "/>",
cp,
true);
}
if(result != null && i < urls.size() - 1)
{
//Move after the inserted element to insert the next one.
Integer off = (Integer) result.getResult(SchemaAwareHandlerResultInsertConstants.RESULT_ID_HANDLE_INSERT_FRAGMENT_OFFSET);
if(off != null)
{
authorAccess.getEditorAccess().setCaretPosition(off.intValue() + 2);
}
}
}
}
}
}
Re: AuthorDnDListener Sample
Hi,
Indeed the handling of dropped files and URLs is made through this special extension you found.
We'll try to update our documentation to add more details about this.
This same extension is also useful for smart paste (interpreting HTML clipboard content pasted from MS Office or from a web browser and converting it to your target vocabulary):
http://blog.oxygenxml.com/2015/10/how-s ... xygen.html
Regards,
Radu
Indeed the handling of dropped files and URLs is made through this special extension you found.
We'll try to update our documentation to add more details about this.
This same extension is also useful for smart paste (interpreting HTML clipboard content pasted from MS Office or from a web browser and converting it to your target vocabulary):
http://blog.oxygenxml.com/2015/10/how-s ... xygen.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
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