Specifying application for open image

Having trouble installing Oxygen? Got a bug to report? Post it all here.
steve.cuzner
Posts: 72
Joined: Thu Mar 26, 2015 4:57 pm

Specifying application for open image

Post 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.
Radu
Posts: 9470
Joined: Fri Jul 09, 2004 5:18 pm

Re: Specifying application for open image

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply