From: <gu...@us...> - 2014-02-03 00:13:22
|
Revision: 19248 http://sourceforge.net/p/jmol/code/19248 Author: gutow Date: 2014-02-03 00:13:12 +0000 (Mon, 03 Feb 2014) Log Message: ----------- make webexport discovery of path to Jmol.jar more robust. Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2014-02-02 13:46:16 UTC (rev 19247) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2014-02-03 00:13:12 UTC (rev 19248) @@ -15,6 +15,8 @@ ___JmolVersion="14.1.8_dev_2014.02.02" +bug fix: make webexport discovery of path to Jmol.jar and jsmol.zip more robust. + bug fix: getProperty extractModel not honoring subset bug fix: set pdbGetHeader TRUE does not capture REMARK3 REMARK290 REMARK350 Modified: trunk/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java 2014-02-02 13:46:16 UTC (rev 19247) +++ trunk/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java 2014-02-03 00:13:12 UTC (rev 19248) @@ -41,6 +41,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.net.URLDecoder; import java.util.ArrayList; import java.util.zip.GZIPOutputStream; import java.util.zip.ZipFile; @@ -598,7 +599,12 @@ List<String> filesToCopy = new List<String>(); String localPath = localAppletPath.getText(); if (localPath.equals(".") || remoteAppletPath.getText().equals(".")) { - filesToCopy.addLast(localPath + "/jsmol.zip"); + try{ + String jmolJarDirPath=jmolJarPath().substring(0, jmolJarPath().lastIndexOf("/")); + filesToCopy.addLast(jmolJarDirPath+"/jsmol.zip"); + }catch (java.io.UnsupportedEncodingException e){ + LogPanel.log(GT._("There was an error in the text encoding so the path to jsmol.zip is unknown.")); + } } JmolBinary.getFileReferences(script, filesToCopy); ArrayList<String> copiedFileNames = new ArrayList<String>(); @@ -875,6 +881,30 @@ } return(dataPath); } + + /***** + * @return the URL pointing to the Jmol.jar that is running + */ + private URL jmolJarURL(){ + return(this.getClass().getProtectionDomain().getCodeSource(). + getLocation()); + } +/****** +* Returns a string version of the path to Jmol.jar (including the trailing Jmol.jar) +* decoded using the system default text encoding (usually UTF-8). +* @return system text encoding translated string version of the path to Jmol.jar +* @throws java.io.UnsupportedEncodingException if the encoding can't be used to +* decode the URL or the encoding is bad. +*/ + private String jmolJarPath() throws java.io.UnsupportedEncodingException{ + String pathStr; + pathStr=null; + URL jarURL = jmolJarURL(); + pathStr=URLDecoder.decode(jarURL.toString(), System.getProperty("file.encoding")); + pathStr = pathStr.substring(pathStr.indexOf(":")+1, pathStr.length()); + return(pathStr); + } + void syncLists() { DefaultListModel<JmolInstance> model1 = (DefaultListModel<JmolInstance>) instanceList.getModel(); for (int j = 0; j < webPanels.length; j++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |