function applicationStarted(pluginWorkspaceAccess) {
 Packages.java.lang.System.err.println("Application started " + pluginWorkspaceAccess);
 referenceResolver = {
  /*Called when a reference is resolved*/
  makeRelative: function (baseURL, childURL) {
          try {
            if(!baseURL.toString().endsWith("/")) {
              lastIndexOfSlash = baseURL.getPath().lastIndexOf('/');
              baseURL = new Packages.java.net.URL(baseURL.getProtocol(), baseURL.getHost(), baseURL.getPort(), baseURL.getPath().substring(0, lastIndexOfSlash + 1));
            }
            return  Packages.java.net.URI.create(Packages.ro.sync.basic.util.URLUtil.uncorrect(baseURL.toString())).relativize(new Packages.java.net.URI(Packages.ro.sync.basic.util.URLUtil.uncorrect(childURL.toString()))).toString();
          } catch (e) {
            e.printStackTrace();
          }
          return null;
  }
 }
 pluginWorkspaceAccess.addRelativeReferencesResolver("file", new JavaAdapter(Packages.ro.sync.exml.workspace.api.util.RelativeReferenceResolver, referenceResolver));
}

function applicationClosing(pluginWorkspaceAccess) {
 Packages.java.lang.System.err.println("Application closing " + pluginWorkspaceAccess);
}

function applicationStarted(pluginWorkspaceAccess) {
 Packages.java.lang.System.err.println("Application started " + pluginWorkspaceAccess);
 var calledFromOwnCode = false;
 referenceResolver = {
  /*Called when a reference is resolved*/
  makeRelative: function (baseURL, childURL) {
            if(calledFromOwnCode){
                return null;
            }
          try {
            calledFromOwnCode = true;
            ret = Packages.ro.sync.basic.util.URLUtil.makeRelative(new Packages.java.net.URL(Packages.ro.sync.basic.util.URLUtil.uncorrect(baseURL.toString())), new Packages.java.net.URL(Packages.ro.sync.basic.util.URLUtil.uncorrect(childURL.toString()))); 
            calledFromOwnCode = false;
            return ret;
          } catch (e) {
            e.printStackTrace();
            calledFromOwnCode = false;
          }
          return null;
  }
 }
 pluginWorkspaceAccess.addRelativeReferencesResolver("file", new JavaAdapter(Packages.ro.sync.exml.workspace.api.util.RelativeReferenceResolver, referenceResolver));
}

function applicationClosing(pluginWorkspaceAccess) {
 Packages.java.lang.System.err.println("Application closing " + pluginWorkspaceAccess);
}

Use Oxygen code to make URLs relative
Use Oxygen code to make URLs relative
