import jalview.javascript.JSFunctionExec;
import jalview.javascript.JalviewLiteJsApi;
import jalview.javascript.JsCallBack;
+import jalview.javascript.MouseOverStructureListener;
import jalview.structure.SelectionListener;
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
return;
}
}
- jalview.javascript.MouseOverStructureListener mol = new jalview.javascript.MouseOverStructureListener(
- this, listener, separatorListToArray(modelSet));
+ MouseOverStructureListener mol = new MouseOverStructureListener(this,
+ listener, separatorListToArray(modelSet));
javascriptListeners.addElement(mol);
StructureSelectionManager.getStructureSelectionManager(this)
.addStructureViewerListener(mol);
* form a complete URL given a path to a resource and a reference location on
* the same server
*
- * @param url
+ * @param targetPath
* - an absolute path on the same server as localref or a document
* located relative to localref
* @param localref
* - a URL on the same server as url
* @return a complete URL for the resource located by url
*/
- private String resolveUrlForLocalOrAbsolute(String url, URL localref)
+ private String resolveUrlForLocalOrAbsolute(String targetPath,
+ URL localref)
{
- String codebase = localref.toString();
- if (url.indexOf("/") == 0)
+ String resolvedPath = "";
+
+ /*
+ * get URL path and strip off any trailing file e.g.
+ * www.jalview.org/examples/index.html#applets?a=b is trimmed to
+ * www.jalview.org/examples/
+ */
+ String urlPath = localref.toString();
+ String directoryPath = urlPath;
+ int lastSeparator = directoryPath.lastIndexOf("/");
+ if (lastSeparator > 0)
{
+ directoryPath = directoryPath.substring(0, lastSeparator + 1);
+ }
+
+ if (targetPath.startsWith("/"))
+ {
+ /*
+ * construct absolute URL to a file on the server
+ */
String localfile = localref.getFile();
- url = codebase.substring(0, codebase.length() - localfile.length())
- + url;
+ resolvedPath = urlPath.substring(0,
+ urlPath.length() - localfile.length())
+ + targetPath;
}
else
{
- url = localref + url;
+ resolvedPath = directoryPath + targetPath;
}
- if (true/* debug */)
+ if (debug)
{
- System.err.println("URL: " + localref.toString());
- System.err.println("URL.getFile: " + localref.getFile());
- System.err.println("URL.getPath: " + localref.getPath());
- System.err.println("URL.getQuery: " + localref.getQuery());
- System.err.println("resolveUrlForLocalOrAbsolute returning " + url);
+ System.err.println("resolveUrlForLocalOrAbsolute returning "
+ + resolvedPath);
}
- return url;
+ return resolvedPath;
}
/**
URL prepend;
url = resolveUrlForLocalOrAbsolute(
url,
- prepend = getDefaultParameter("resolvetocodebase", false) ? getDocumentBase()
- : getCodeBase());
+ prepend = getDefaultParameter("resolvetocodebase", false) ? getCodeBase()
+ : getDocumentBase());
if (debug)
{
System.err