[oXygen-user] Plugin config, plugin dir, and API

Oxygen XML Editor Support support at oxygenxml.com
Mon Feb 20 03:09:53 CST 2012


Hi Florent,

We do not yet have such support of setting pairs of key/value in the 
plugin.xml and then making them available to the Plugin Java classes.
But it seems like an interesting improvement in order to control some 
configuration of a plugin without making changes in the Java code so 
we'll look into it.

Please see more answers below:

>  My second (related) question is: how can we get the plugin dir via
> the API?  And how to resolve resources in that dir?

Well, you could use the class loader to see from where the main plugin 
JAR library was loaded. For example on one of our implemented plugins we 
used a method like:

> 	private File getLibDir() {
> 		URLClassLoader cl = (URLClassLoader) getClass().getClassLoader();
> 		URL[] urls = cl.getURLs();
> 		for (int i = 0; i < urls.length; i++) {
> 			URL url = urls[i];
> 			if(url.toString().endsWith("acrolinx.jar")){
> 				return pluginWorkspaceAccess.getUtilAccess().locateFile(url).getParentFile();
> 			}
> 		}
> 		return null;
> 	}

Another approach would be to find out the location where Oxygen is 
installed using code like:

> pluginWorkspaceAccess.getUtilAccess().expandEditorVariables(EditorVariables.OXYGEN_INSTALL_DIR, null);

and then append a "plugins/your-plugin-name" to that path.

>   Congrats for the SDK!  Starting a new plugin is very easy! (even
> though I still have to investigate more deeply the APIs :-p)

If you find any quirks or have trouble finding certain APIs please do 
not hesitate to contact us.

Regards,
Radu

Radu Coravu
<oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On 2/18/2012 12:25 AM, Florent Georges wrote:
>    Hi,
>
>    I am investigating a bit with writing plugins for oXygen.  I am at
> the point where I'd like to be able to configure it.  I can of course
> write my own config file format and read it explicitely, but I guess
> that something similar already exists (like e.g. configuring simple
> key/value pairs in plugin.xml et read them through an API from the
> plugin SDK).
>
>    Is there anything like that?
>
>    My second (related) question is: how can we get the plugin dir via
> the API?  And how to resolve resources in that dir?
>
>    Congrats for the SDK!  Starting a new plugin is very easy! (even
> though I still have to investigate more deeply the APIs :-p)
>
>    Regards,
>


More information about the oXygen-user mailing list