Page 1 of 1

Specifying application for open image

Posted: Wed Aug 23, 2017 12:21 am
by steve.cuzner
In a docbook document, if I have an imagedata element with a fileref attribute that points to an image file, I can double click or use the context menu->Open image to launch the image in an external image editor that is the default editor for the file extension. Is it possible to configure Oxygen to launch different editors based on criteria such as an attribute? For example, if the imagedata also has a role attribute set to "editor1" it would launch draw but if the role is set to "editor2" it would use a snagit.

Re: Specifying application for open image

Posted: Wed Aug 23, 2017 8:30 am
by Radu
Hi Steve,

We have API which allows you to add a mouse listener on the Author visual editing page, something like:

Code: Select all

    PluginWorkspaceProvider.getPluginWorkspace().addEditorChangeListener(new WSEditorChangeListener(){
/**
* @see ro.sync.exml.workspace.api.listeners.WSEditorChangeListener#editorOpened(java.net.URL)
*/
@Override
public void editorOpened(URL editorLocation) {
WSEditor editor = PluginWorkspaceProvider.getPluginWorkspace().getEditorAccess(editorLocation, PluginWorkspace.MAIN_EDITING_AREA);
WSEditorPage currentPage = editor.getCurrentPage();
if(currentPage instanceof WSAuthorEditorPage){
final WSAuthorEditorPage authorPage = (WSAuthorEditorPage)currentPage;
authorPage.addAuthorMouseListener(new AuthorMouseAdapter(){
/**
* @see ro.sync.ecss.extensions.api.AuthorMouseAdapter#mouseClicked(ro.sync.ecss.extensions.api.AuthorMouseEvent)
*/
@Override
public void mouseClicked(AuthorMouseEvent e) {
if(e.clickCount == 2 && ! e.isPopupTrigger()){
//Double click...
AuthorViewToModelInfo vtm = authorPage.viewToModel(e.X, e.Y);
if("image".equals(vtm.getAuthorNode().getName())){
System.err.println("CUSTOM OPEN " + ((AuthorElement)vtm.getAuthorNode()).getAttribute("href"));
// Runtime.getRuntime().exec(".....");
//Consume event...
e.consume();
}
}
}
});
}
}
}, PluginWorkspace.MAIN_EDITING_AREA);
The same API could be used from a Javascript-based Workspace Access Plugin Extension.
We also have API WSAuthorEditorPage.addPopUpMenuCustomizer(AuthorPopupMenuCustomizer) to customize the contextual menu in the Author visual editing mode.

Regards,
Radu