Drop objects onto the XML editor.
Oxygen general issues.
-
- Posts: 206
- Joined: Thu Dec 01, 2011 4:22 pm
- Location: Hamburg, Germany
Drop objects onto the XML editor.
Hello,
We do use the Eclipse version of Oxygen 13.2.
I´d like to drop graphic objects onto the XML editor, so that they are inserted at the location where the drop takes place.
Currently I try to use com.oxygenxml.editor.editors.author.AuthorDnDListener extension to achieve that.
When a drop occurs I want to use one of the insertXMLFragment methods of the ro.sync.ecss.extensions.api.AuthorDocumentController, but I do not know where to get the correct arguments for the method.
Do you have a hint for me, how I can achieve to insert XML fragments via Drag&Drop at the right position where the drop takes place?
Regards,
Simon
We do use the Eclipse version of Oxygen 13.2.
I´d like to drop graphic objects onto the XML editor, so that they are inserted at the location where the drop takes place.
Currently I try to use com.oxygenxml.editor.editors.author.AuthorDnDListener extension to achieve that.
When a drop occurs I want to use one of the insertXMLFragment methods of the ro.sync.ecss.extensions.api.AuthorDocumentController, but I do not know where to get the correct arguments for the method.
Do you have a hint for me, how I can achieve to insert XML fragments via Drag&Drop at the right position where the drop takes place?
Regards,
Simon
Simon Scholz
vogella GmbH
http://www.vogella.com
vogella GmbH
http://www.vogella.com
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Drop objects onto the XML editor.
Hi Simon,
Yes, you can get from the drop event the X and Y coordinates and translate them to an offset in the Author page.
But it's not as simple as it should be, we should probably add some API to translate this point which comes in screen coordinates to a certain offset (the correctDropLocation method you see below).
Here's the code which should work:
Regards,
Radu
Yes, you can get from the drop event the X and Y coordinates and translate them to an offset in the Author page.
But it's not as simple as it should be, we should probably add some API to translate this point which comes in screen coordinates to a certain offset (the correctDropLocation method you see below).
Here's the code which should work:
Code: Select all
/**
* Correct the drop location taking onto account the scroll offsets.
*
* @param e The drop location in screen coordinates.
* @return The corrected location, depending on the scroll insets.
*/
private org.eclipse.swt.graphics.Point correctDropLocation(DropTargetEvent e) {
org.eclipse.swt.graphics.Point p = new org.eclipse.swt.graphics.Point(e.x, e.y);
// Obtain the control absolute coordinates.
Control control = (Control) authorAccess.getEditorAccess().getAuthorComponent();
p = control.toControl(p);
Scrollable canvas = (Scrollable) authorAccess.getEditorAccess().getAuthorComponent();
ScrollBar vbar = canvas.getVerticalBar();
ScrollBar hbar = canvas.getHorizontalBar();
p.y += vbar.getSelection();
p.x += hbar.getSelection();
return p;
}
@Override
public void authorDrop(DropTargetEvent event) {
Point pt = correctDropLocation(event);
AuthorViewToModelInfo vtm = authorAccess.getEditorAccess().viewToModel(pt.x, pt.y);
authorAccess.getEditorAccess().setCaretPosition(vtm.getOffset());
}
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Drop objects onto the XML editor.
Hi,
In Oxygen 14.2 we added the method:
ro.sync.exml.workspace.api.editor.page.WSTextBasedEditorPage.getLocationRelativeToEditorFromScreen(int, int)
which can be used for such cases.
Regards,
Radu
In Oxygen 14.2 we added the method:
ro.sync.exml.workspace.api.editor.page.WSTextBasedEditorPage.getLocationRelativeToEditorFromScreen(int, int)
which can be used for such cases.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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