From: <ha...@us...> - 2009-09-02 15:51:14
|
Revision: 11433 http://jmol.svn.sourceforge.net/jmol/?rev=11433&view=rev Author: hansonr Date: 2009-09-02 15:51:03 +0000 (Wed, 02 Sep 2009) Log Message: ----------- version=11.9.2 # new feature: script LOCALPATH "xxx" and write script LOCALPATH "xxx" # either on reading or writing sets all LOCAL file references in script # to be within the path indicated. For example, # # write script LOCALPATH "" "tx.spt" # # will create a script "tx.spt" stripping all file paths from file names -- that is, # a script that assumes all files are in the current directory. # # script LOCALPATH "data" "tx.spt" # # will convert a reference "C:/temp/myfile.xyz" in script "tx.spt" to "data/myfile.xyz" # # file references including the LOCALPATH will be truncated: # "C:/temp/data/myfile.xyz" will become simply "data/myfile.xyz" # # new feature: script REMOTEPATH "xxx" and write script REMOTEPATH "xxx" # same as REMOTEPATH, but only changes http: https: or ftp: references # Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/viewer/FileManager.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2009-09-02 15:29:48 UTC (rev 11432) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2009-09-02 15:51:03 UTC (rev 11433) @@ -208,7 +208,7 @@ public boolean compileScriptFile(String filename, boolean tQuiet) { clearState(tQuiet); contextPath = filename; - return compileScriptFileInternal(filename, null); + return compileScriptFileInternal(filename, null, null); } public void evaluateCompiledScript(boolean isCmdLine_c_or_C_Option, @@ -1600,7 +1600,7 @@ runScript(script, outputBuffer); } - private boolean compileScriptFileInternal(String filename, String path) { + private boolean compileScriptFileInternal(String filename, String localPath, String remotePath) { // from "script" command, with push/pop surrounding or viewer if (filename.toLowerCase().indexOf("javascript:") == 0) return compileScript(filename, viewer.jsEval(filename.substring(11)), @@ -1612,8 +1612,10 @@ return false; } this.filename = filename; - if (path != null) - data[1] = FileManager.setScriptFileReferences(data[1], path); + if (localPath != null) + data[1] = FileManager.setScriptFileReferences(data[1], localPath, true); + if (remotePath != null) + data[1] = FileManager.setScriptFileReferences(data[1], remotePath, false); return compileScript(filename, data[1], debugScript); } @@ -7291,7 +7293,8 @@ int pcEnd = 0; int i = 2; String filename = null; - String path = null; + String localPath = null; + String remotePath = null; String theScript = parameterAsString(1); if (tok == Token.javascript) { checkLength(2); @@ -7323,8 +7326,13 @@ if (filename.equalsIgnoreCase("inline")) { theScript = parameterExpression(2, (doStep ? statementLength - 1 : 0), "_script", false).toString(); i = iToken + 1; - } else if (filename.equalsIgnoreCase("localPath")) { - path = parameterAsString(i++); + } + while (filename.equalsIgnoreCase("localPath") + || filename.equalsIgnoreCase("remotePath")) { + if (filename.equalsIgnoreCase("localPath")) + localPath = parameterAsString(i++); + else + remotePath = parameterAsString(i++); filename = parameterAsString(i++); } option = optParameterAsString(i); @@ -7373,7 +7381,7 @@ isSyntaxCheck = isCmdLine_c_or_C_Option = true; pushContext(null); contextPath += " >> " + filename; - if (theScript == null ? compileScriptFileInternal(filename, path) + if (theScript == null ? compileScriptFileInternal(filename, localPath, remotePath) : compileScript(null, theScript, false)) { this.pcEnd = pcEnd; this.lineEnd = lineEnd; @@ -10367,7 +10375,8 @@ boolean isShow = false; boolean isExport = false; BitSet bsFrames = null; - String path = null; + String localPath = null; + String remotePath = null; String val = null; int quality = Integer.MIN_VALUE; if (tok == Token.string) { @@ -10433,9 +10442,12 @@ case Token.state: case Token.script: val = ScriptVariable.sValue(tokenAt(++pt, args)).toLowerCase(); - if (val.equalsIgnoreCase("localPath")) { - path = ScriptVariable.sValue(tokenAt(++pt, args)).toLowerCase(); - pt++; + while (val.equals("localpath") || val.equals("remotepath")) { + if (val.equals("localpath")) + localPath = ScriptVariable.sValue(tokenAt(++pt, args)); + else + remotePath = ScriptVariable.sValue(tokenAt(++pt, args)); + val = ScriptVariable.sValue(tokenAt(++pt, args)).toLowerCase(); } type = "SPT"; break; @@ -10661,8 +10673,10 @@ viewer.setTaintedAtoms(tainted, AtomCollection.TAINT_COORD); } else { data = (String) viewer.getProperty("string", "stateInfo", null); - if (path != null) - data = FileManager.setScriptFileReferences(data, path); + if (localPath != null) + data = FileManager.setScriptFileReferences(data, localPath, true); + if (remotePath != null) + data = FileManager.setScriptFileReferences(data, remotePath, false); } } else if (data == "HIS") { data = viewer.getSetHistory(Integer.MAX_VALUE); Modified: trunk/Jmol/src/org/jmol/viewer/FileManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/FileManager.java 2009-09-02 15:29:48 UTC (rev 11432) +++ trunk/Jmol/src/org/jmol/viewer/FileManager.java 2009-09-02 15:51:03 UTC (rev 11433) @@ -1008,9 +1008,10 @@ * * @param script * @param dataPath + * @param isLocal * @return revised script */ - public static String setScriptFileReferences(String script, String dataPath) { + public static String setScriptFileReferences(String script, String dataPath, boolean isLocal) { if (dataPath == null) return script; if (dataPath.equals(".")) @@ -1023,7 +1024,7 @@ for (int iFile = 0; iFile < nFiles; iFile++) { String name = (String) fileNames.get(iFile); int itype = urlTypeIndex(name); - if (itype < 0 || itype == URL_LOCAL) { + if (isLocal == (itype < 0 || itype == URL_LOCAL)) { int pt = (noPath ? -1 : name.indexOf("/" + dataPath + "/")); if (pt >= 0) { name = name.substring(pt + 1); Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-09-02 15:29:48 UTC (rev 11432) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-09-02 15:51:03 UTC (rev 11433) @@ -1,7 +1,7 @@ # Developers: to add a description of changes you have made, # add it on a line starting with # below the "version=..." line -version=11.9.2_dev +version=11.9.2 # new feature: script LOCALPATH "xxx" and write script LOCALPATH "xxx" # either on reading or writing sets all LOCAL file references in script @@ -19,6 +19,9 @@ # file references including the LOCALPATH will be truncated: # "C:/temp/data/myfile.xyz" will become simply "data/myfile.xyz" # +# new feature: script REMOTEPATH "xxx" and write script REMOTEPATH "xxx" +# same as REMOTEPATH, but only changes http: https: or ftp: references +# # bug fix: show pointgroup can give wrong format after getproperty PointGroupInfo # bug fix: mmCIF misreads bfactor data # new feature: crystallographic symmetry and anisotropic ellipsoids for proteins. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |