web page drag'n drop never reaches authorDrop
Post here questions and problems related to oXygen frameworks/document types.
web page drag'n drop never reaches authorDrop
Hello everyone,
In would like to perform a drag'n drop from a JxBrowser (javafx webview) to the author view component.
More generally, is it possible to perform a drag'n drop from an html page (Web browser) to the author view component (Java swing application) ?
I know that's not a common question but I have tested several dnd from a webbrowser page to the author view component but none of them reached authorDrop method of the AuthorDnDListener implementation.
Have you ever experienced this kind of things ? Do you think it is possible ?
Thanks for your response,
Johann
In would like to perform a drag'n drop from a JxBrowser (javafx webview) to the author view component.
More generally, is it possible to perform a drag'n drop from an html page (Web browser) to the author view component (Java swing application) ?
I know that's not a common question but I have tested several dnd from a webbrowser page to the author view component but none of them reached authorDrop method of the AuthorDnDListener implementation.
Have you ever experienced this kind of things ? Do you think it is possible ?
Thanks for your response,
Johann
Re: web page drag'n drop never reaches authorDrop
Hi Johann,
I may not have time to check this in our code next week because I"m at a conference, could you maybe create a simple Swing component (like a JTextArea), add a drop listener to it and then try to drag and drop to it? Just to see what flavors are dropped on it and how the information could be obtained from the transferable...
Regards,
Radu
I may not have time to check this in our code next week because I"m at a conference, could you maybe create a simple Swing component (like a JTextArea), add a drop listener to it and then try to drag and drop to it? Just to see what flavors are dropped on it and how the information could be obtained from the transferable...
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: web page drag'n drop never reaches authorDrop
Hello Radu,
I have performed some drops from an HTML page to a swing Component and It seems that the working data flavor mimetype for this drop is: text/html; document=selection; class=java.io.InputStream; charset=UTF-16
Maybe transfered data of type inputStream are not authorized in author view ?
Regards,
Johann
I have performed some drops from an HTML page to a swing Component and It seems that the working data flavor mimetype for this drop is: text/html; document=selection; class=java.io.InputStream; charset=UTF-16
Maybe transfered data of type inputStream are not authorized in author view ?
Regards,
Johann
Re: web page drag'n drop never reaches authorDrop
Hi Johann,
Thanks for testing this, I'll have a look at our code when I get back.
By the way, what version of our Author Component are you using?
Regards,
Radu
Thanks for testing this, I'll have a look at our code when I get back.
By the way, what version of our Author Component are you using?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: web page drag'n drop never reaches authorDrop
Hi Johann,
Did you implement an external object insertion handler?
https://www.oxygenxml.com/doc/versions/ ... ndler.html
from what I tested, dropped HTML should be handled by this API.
Regards,
Radu
Did you implement an external object insertion handler?
https://www.oxygenxml.com/doc/versions/ ... ndler.html
from what I tested, dropped HTML should be handled by this API.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: web page drag'n drop never reaches authorDrop
Hello Radu,
Sorry for the delay...
Can you test something ?
Open the following page in a browser and try to drag the image (not present) in the left box and drop it into an author view.
You will see that "drag1" is inserted in the Author view and I saw that I came in "authorDrop" method of my AuthorDnDListener.
The thing is "authorDrop" method returned "false" and I haven't been able to access to transferable.getTransferData(....). In fact, I do not know how "drag1" was inserted... I would like to catch this insertion in "authorDrop" method.
Regards,
Johann
Sorry for the delay...
Can you test something ?
Open the following page in a browser and try to drag the image (not present) in the left box and drop it into an author view.
You will see that "drag1" is inserted in the Author view and I saw that I came in "authorDrop" method of my AuthorDnDListener.
The thing is "authorDrop" method returned "false" and I haven't been able to access to transferable.getTransferData(....). In fact, I do not know how "drag1" was inserted... I would like to catch this insertion in "authorDrop" method.
Code: Select all
<!DOCTYPE HTML>
<html>
<head>
<style>
#div1, #div2 {
float: left;
width: 100px;
height: 35px;
margin: 10px;
padding: 10px;
border: 1px solid black;
}
</style>
<script>
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
}
</script>
</head>
<body>
<h2>Drag and Drop</h2>
<p>Drag the image back and forth between the two div elements.</p>
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="img_w3slogo.gif" draggable="true" ondragstart="drag(event)" id="drag1" width="88" height="31">
</div>
<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
</body>
</html>
Johann
Re: web page drag'n drop never reaches authorDrop
Hi Johann,
I tested this on my side. In this case the callback:
ro.sync.ecss.extensions.api.AuthorExternalObjectInsertionHandler.insertURLs(AuthorAccess, List<URL>, List<ReferenceType>, int)
should be given with an URL pointing to your image.
Indeed the "authorDrop" is no longer called because we have this specific callback for URLs getting dropped in the editing area.
Regards,
Radu
I tested this on my side. In this case the callback:
ro.sync.ecss.extensions.api.AuthorExternalObjectInsertionHandler.insertURLs(AuthorAccess, List<URL>, List<ReferenceType>, int)
should be given with an URL pointing to your image.
Indeed the "authorDrop" is no longer called because we have this specific callback for URLs getting dropped in the editing area.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: web page drag'n drop never reaches authorDrop
Hello Radu,
Indeed, when I put an URL in my <img> insertURLs method is fired. It's a good start !
But, my need is more global.
If I take the example from above, what is important for me is not the image itself but the data transfered in the javascript method "ev.dataTransfer.setData("text", ev.target.id);" (drag1 in this case)
The author view well managed the drop because I see "drag1" inserted but I do no see any method fired allowing me to access this transfered data and to manage it properly.
Is it clearer with this example ?
Regards,
Johann
Indeed, when I put an URL in my <img> insertURLs method is fired. It's a good start !
But, my need is more global.
If I take the example from above, what is important for me is not the image itself but the data transfered in the javascript method "ev.dataTransfer.setData("text", ev.target.id);" (drag1 in this case)
The author view well managed the drop because I see "drag1" inserted but I do no see any method fired allowing me to access this transfered data and to manage it properly.
Is it clearer with this example ?
Regards,
Johann
Re: web page drag'n drop never reaches authorDrop
Hi Johann,
In the sample HTML you sent me I replaced the <img> with a div:
and obtained the behavior you have on your side, then I added an AuthorDnDListener like the one below and it seems to properly intercept the dropped content.
But you should take care to only handle dropped text which concerns you, otherwise you may lose some standard drag and drop functionality implemented in the Oxygen code.
Regards,
Radu
In the sample HTML you sent me I replaced the <img> with a div:
Code: Select all
<div draggable="true" ondragstart="drag(event)" id="drag1" width="88" height="31">aaaaaa</div>
Code: Select all
/**
* @see ro.sync.ecss.extensions.api.ExtensionsBundle#createAuthorAWTDndListener()
*/
@Override
public AuthorDnDListener createAuthorAWTDndListener() {
return new AuthorDnDListener() {
private AuthorAccess authorAccess;
@Override
public String getDescription() {
return null;
}
@Override
public void init(AuthorAccess authorAccess) {
this.authorAccess = authorAccess;
}
@Override
public boolean authorSupportsFlavor(DataFlavor flavor) {
System.err.println("SUPPORTS " + DataFlavor.stringFlavor.equals(flavor));
return DataFlavor.stringFlavor.equals(flavor);
}
@Override
public boolean authorDrop(Transferable transferable, DropTargetDropEvent event) {
if(event.isDataFlavorSupported(DataFlavor.stringFlavor)) {
event.acceptDrop(DnDConstants.ACTION_MOVE);
try {
//TODO now you need to use the AuthorAccess to insert the content yourself.
System.err.println("SRING IS " + event.getTransferable().getTransferData(DataFlavor.stringFlavor));
} catch (UnsupportedFlavorException | IOException e) {
e.printStackTrace();
}
return true;
}
return false;
}
@Override
public boolean authorDragOver(DropTargetDragEvent event) {
if(event.isDataFlavorSupported(DataFlavor.stringFlavor)) {
System.err.println("DRAG OVER");
return true;
}
return false;
}
@Override
public boolean authorDragExit(DropTargetEvent event) {
return false;
}
@Override
public boolean authorDragEnter(DropTargetDragEvent event) {
if(event.isDataFlavorSupported(DataFlavor.stringFlavor)) {
return true;
}
return false;
}
};
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: web page drag'n drop never reaches authorDrop
Hello Radu,
unfortunately I cannot reproduce your behavior...
I added your code in my CustomExtensionsBundle like this :
When I open the document matching with this CustomExtensionsBundle I see in my console "TEST 1", "TEST 2" but "TEST 3" corresponding to your code never appears.... so, of course, the drag'n drop does not work.
Do you have an idea about this issue ?
Regards,
Johann
unfortunately I cannot reproduce your behavior...
I added your code in my CustomExtensionsBundle like this :
Code: Select all
public class CustomExtensionsBundle extends AbstractExtensionsBundle {
private CustomDefaultUniqueAttributesRecognizer uniqueAttributesRecognizer;
private CustomStylesFilter stylesFilter;
public CustomExtensionsBundle() {
super();
}
public String getDescription() {
return "Custom Extensions Bundle";
}
public String getDocumentTypeID() {
return null;
}
@Override
public AuthorExtensionStateListener createAuthorExtensionStateListener() {
System.out.println("TEST 1");
if (uniqueAttributesRecognizer == null) {
uniqueAttributesRecognizer = new CustomDefaultUniqueAttributesRecognizer();
}
return uniqueAttributesRecognizer;
}
@Override
public CustomStylesFilter createAuthorStylesFilter() {
System.out.println("TEST 2");
if (stylesFilter == null) {
stylesFilter = new CustomStylesFilter();
}
return stylesFilter;
}
public ClipboardFragmentProcessor getClipboardFragmentProcessor() {
return uniqueAttributesRecognizer;
}
@Override
public CustomDefaultUniqueAttributesRecognizer getUniqueAttributesIdentifier() {
return uniqueAttributesRecognizer;
}
@Override
public AuthorDnDListener createAuthorAWTDndListener() {
System.out.println("TEST 3");
return new AuthorDnDListener() {
private AuthorAccess authorAccess;
@Override
public String getDescription() {
return null;
}
@Override
public void init(AuthorAccess authorAccess) {
this.authorAccess = authorAccess;
}
@Override
public boolean authorSupportsFlavor(DataFlavor flavor) {
System.err.println("SUPPORTS " + DataFlavor.stringFlavor.equals(flavor));
return DataFlavor.stringFlavor.equals(flavor);
}
@Override
public boolean authorDrop(Transferable transferable, DropTargetDropEvent event) {
if (event.isDataFlavorSupported(DataFlavor.stringFlavor)) {
event.acceptDrop(DnDConstants.ACTION_MOVE);
try {
//TODO now you need to use the AuthorAccess to insert the content yourself.
System.err.println("SRING IS " + event.getTransferable().getTransferData(DataFlavor.stringFlavor));
} catch (UnsupportedFlavorException | IOException e) {
e.printStackTrace();
}
return true;
}
return false;
}
@Override
public boolean authorDragOver(DropTargetDragEvent event) {
if (event.isDataFlavorSupported(DataFlavor.stringFlavor)) {
System.err.println("DRAG OVER");
return true;
}
return false;
}
@Override
public boolean authorDragExit(DropTargetEvent event) {
return false;
}
@Override
public boolean authorDragEnter(DropTargetDragEvent event) {
if (event.isDataFlavorSupported(DataFlavor.stringFlavor)) {
return true;
}
return false;
}
};
}
}
Do you have an idea about this issue ?
Regards,
Johann
Re: web page drag'n drop never reaches authorDrop
Hi Johann,
So this is the exact HTML with which I'm testing:
I replaced the original image reference with a text "aaaaaa" which needs to be dragged instead.
I tested dropping from IE, FF and Chrome to the Author visual editing mode and I get the proper result from all of them.
Regards,
Radu
So this is the exact HTML with which I'm testing:
Code: Select all
<!DOCTYPE HTML>
<html>
<head>
<style>
#div1, #div2 {
float: left;
width: 100px;
height: 35px;
margin: 10px;
padding: 10px;
border: 1px solid black;
}
</style>
<script>
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
}
</script>
</head>
<body>
<h2>Drag and Drop</h2>
<p>Drag the image back and forth between the two div elements.</p>
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)">
<div draggable="true" ondragstart="drag(event)" id="drag1" width="88" height="31">aaaaaa</div>
</div>
<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
</body>
</html>
I tested dropping from IE, FF and Chrome to the Author visual editing mode and I get the proper result from all of them.
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