add-on frameworks location

Oxygen general issues.
chris.ditcher
Posts: 2
Joined: Thu Aug 29, 2013 2:29 am

add-on frameworks location

Post by chris.ditcher »

Hi,

I am deploying a framework as an add on to one of our web servers so that our clients can receive updates when we deploy new versions of the framework. This is a nice feature and works well. However, I am trying to resolve a reference to a file found in the frameworks directory (the schema) and having a hard time getting there.

The framework is deployed in the %APPDATA% directory (users.{username}.AppData.Roaming.etc) by default and all the editor variables in my framework seem to expand correctly (${frameworks}, etc). The problem occurs when I try to reference files in my ${frameworks} directory using the following code from an implementation of AuthorOperation:

Code: Select all

String frameworksDir = EditorVariables.expandEditorVariables("${frameworks}", aa.getDocumentController().getAuthorDocumentNode().getSystemID());
The value of expandedVar is always the default value set for frameworks directory (ex: C:\ProgramFiles\OxygenAuthor\frameworks) instead of the frameworks directory my add-on is using (in the %APPDATA% directory).

Is there a way to access these files better?
Radu
Posts: 9472
Joined: Fri Jul 09, 2004 5:18 pm

Re: add-on frameworks location

Post by Radu »

Hi Chris,

Indeed the ${frameworks} editor variable always expand to Oxygen's builtin frameworks folder.
Your add-on works because when it makes references it uses the editor variable ${framework} and thus refers to locations relative to the place where it is deployed in the user's home folder.

If you have access to the API ro.sync.ecss.extensions.api.AuthorAccess you can do this:

Code: Select all


authorAccess.getUtilAccess().expandEditorVariables("${framework}", null);
Because you are calling the code from the add-on Oxygen should expand the path to the add-on for you. Attention, the EditorVariables code will not work given the same parameters.

Or:

When you edit your document type in Oxygen's Preferences->Document Type Association page you have the "Classpath" tab in which you probably already added references to all your JAR libraries.
This list of classpath entries is used to create the individual add-on class loader in which your code gets executed. If in that list you add a reference to your schema's folder like:

Code: Select all

${framework}/schemas/
then in the add-on's Java code you could probably do something like:

Code: Select all


this.getClass().getResource("/mySchema.xsd");
to obtain an URL pointing to the mySchema.xsd schema located in the schemas folder from your add-on.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
chris.ditcher
Posts: 2
Joined: Thu Aug 29, 2013 2:29 am

Re: add-on frameworks location

Post by chris.ditcher »

Thanks Radu! That did the trick. Also good to know I can get a hold of resources as you suggested. I will test this option as well.

Cheers.
Post Reply