From: <ha...@us...> - 2009-06-26 08:37:22
|
Revision: 11125 http://jmol.svn.sourceforge.net/jmol/?rev=11125&view=rev Author: hansonr Date: 2009-06-26 08:37:10 +0000 (Fri, 26 Jun 2009) Log Message: ----------- version=11.7.45_dev # new feature: drag/drop and file menu-open scripts directly into editor, from where they can be checked or tested. Modified Paths: -------------- trunk/Jmol/src/org/jmol/api/JmolScriptEditorInterface.java trunk/Jmol/src/org/jmol/applet/Jmol.java trunk/Jmol/src/org/jmol/applet/Jvm12.java trunk/Jmol/src/org/jmol/console/JmolConsole.java trunk/Jmol/src/org/jmol/console/ScriptEditor.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/StatusManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/api/JmolScriptEditorInterface.java =================================================================== --- trunk/Jmol/src/org/jmol/api/JmolScriptEditorInterface.java 2009-06-26 07:56:18 UTC (rev 11124) +++ trunk/Jmol/src/org/jmol/api/JmolScriptEditorInterface.java 2009-06-26 08:37:10 UTC (rev 11125) @@ -22,4 +22,6 @@ void notifyScriptStart(); + void setFilename(String filename); + } Modified: trunk/Jmol/src/org/jmol/applet/Jmol.java =================================================================== --- trunk/Jmol/src/org/jmol/applet/Jmol.java 2009-06-26 07:56:18 UTC (rev 11124) +++ trunk/Jmol/src/org/jmol/applet/Jmol.java 2009-06-26 08:37:10 UTC (rev 11125) @@ -852,8 +852,9 @@ // + " " + strInfo); switch (type) { case JmolConstants.SHOW_EDITOR: + String filename = (String) data[2]; if (jvm12 != null) - jvm12.showEditor(true, strInfo); + jvm12.showEditor(true, filename, strInfo); return; case JmolConstants.CALLBACK_ANIMFRAME: // Note: twos-complement. To get actual frame number, use Modified: trunk/Jmol/src/org/jmol/applet/Jvm12.java =================================================================== --- trunk/Jmol/src/org/jmol/applet/Jvm12.java 2009-06-26 07:56:18 UTC (rev 11124) +++ trunk/Jmol/src/org/jmol/applet/Jvm12.java 2009-06-26 08:37:10 UTC (rev 11125) @@ -196,13 +196,15 @@ JmolScriptEditorInterface scriptEditor; - void showEditor(boolean showEditor, String msg) { + void showEditor(boolean showEditor, String filename, String msg) { if (scriptEditor == null) { scriptEditor = (JmolScriptEditorInterface) Interface.getOptionInterface("console.ScriptEditor"); scriptEditor = scriptEditor.getScriptEditor(viewer, awtComponent, console); } - if (msg != null) + if (msg != null) { + scriptEditor.setFilename(filename); scriptEditor.output(msg); + } scriptEditor.setVisible(showEditor); } Modified: trunk/Jmol/src/org/jmol/console/JmolConsole.java =================================================================== --- trunk/Jmol/src/org/jmol/console/JmolConsole.java 2009-06-26 07:56:18 UTC (rev 11124) +++ trunk/Jmol/src/org/jmol/console/JmolConsole.java 2009-06-26 08:37:10 UTC (rev 11125) @@ -65,7 +65,7 @@ } else if (source == historyButton) { clearContent(viewer.getSetHistory(Integer.MAX_VALUE)); } else if (source == stateButton) { - viewer.getProperty("DATA_API","scriptEditor", viewer.getStateInfo()); + viewer.getProperty("DATA_API","scriptEditor", new String[] { "current state" , viewer.getStateInfo() }); } } Modified: trunk/Jmol/src/org/jmol/console/ScriptEditor.java =================================================================== --- trunk/Jmol/src/org/jmol/console/ScriptEditor.java 2009-06-26 07:56:18 UTC (rev 11124) +++ trunk/Jmol/src/org/jmol/console/ScriptEditor.java 2009-06-26 08:37:10 UTC (rev 11125) @@ -124,7 +124,7 @@ pauseButton = new JButton(GT._("Pause")); pauseButton.addActionListener(this); buttonPanel.add(pauseButton); - pauseButton.setEnabled(false); + pauseButton.setEnabled(true); stepButton = new JButton(GT._("Step")); stepButton.addActionListener(this); @@ -234,13 +234,16 @@ private ScriptContext context; - //int ntest = 0; + String filename; private synchronized void setContext(ScriptContext scriptContext) { if (scriptContext.script.indexOf(JmolConstants.SCRIPT_EDITOR_IGNORE) >= 0) return; context = scriptContext; String s = context.script; + filename = context.filename; + if (filename == null && context.functionName != null) + filename = "function " + context.functionName; editor.clearContent(s); boolean isPaused = context.executionPaused || context.executionStepping; resumeButton.setEnabled(isPaused); @@ -297,6 +300,7 @@ return; } if (source == runButton) { + notifyScriptStart(); jmolConsole.execute(editor.getText() + "\0##"); return; } @@ -345,7 +349,8 @@ return; parsedData = text; parsedContext = (ScriptContext) viewer.getProperty("DATA_API","scriptCheck", text); - setTitle(title + " -- " + parsedContext.aatoken.length + " commands " + setTitle(title + (filename == null ? "" : "[" + filename + "]") + + " -- " + parsedContext.aatoken.length + " commands " + (parsedContext.iCommandError < 0 ? "" : " ERROR: " + parsedContext.errorType)); } @@ -374,6 +379,7 @@ } public void clearContent() { + filename = null; clearContent(null); } @@ -440,4 +446,8 @@ } } } + + public void setFilename(String filename) { + this.filename = filename; + } } Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-06-26 07:56:18 UTC (rev 11124) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-06-26 08:37:10 UTC (rev 11125) @@ -3,6 +3,7 @@ version=11.7.45_dev +# new feature: drag/drop and file menu-open scripts directly into editor, from where they can be checked or tested. # code: refactored readers, allowing for more obvious initialization/finalization methods # new feature: App and applet consoles now have "editor" buttons # that load scripts into a "script editor" and allow stepping through Modified: trunk/Jmol/src/org/jmol/viewer/StatusManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StatusManager.java 2009-06-26 07:56:18 UTC (rev 11124) +++ trunk/Jmol/src/org/jmol/viewer/StatusManager.java 2009-06-26 08:37:10 UTC (rev 11125) @@ -558,10 +558,14 @@ jmolStatusListener.showConsole(showConsole); } - synchronized void showEditor(String text) { + synchronized void showEditor(String[] file_text) { + if (file_text == null) + file_text = new String[]{ null, null }; + if (file_text[1] == null) + file_text[1] = "<no data>"; if (jmolStatusListener != null) jmolCallbackListener.notifyCallback(JmolConstants.SHOW_EDITOR, - new Object[] { null, text, }); + new Object[] { null, file_text[1], file_text[0] }); } float[][] functionXY(String functionName, int nX, int nY) { Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2009-06-26 07:56:18 UTC (rev 11124) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2009-06-26 08:37:10 UTC (rev 11125) @@ -1632,8 +1632,12 @@ String type = fileManager.getFileTypeName(fileName); checkHalt("exit"); // assumes a Jmol script file if no other file type - evalString((type == null && allowScript ? "script " : "load ") - + Escape.escape(fileName)); + allowScript &= (type == null); + if (scriptEditorVisible && allowScript) + statusManager.showEditor(new String[] { fileName, getFileAsString(fileName) }); + else + evalString((allowScript ? "script " : "load ") + + Escape.escape(fileName)); } private final static int FILE_STATUS_NOT_LOADED = -1; @@ -6626,7 +6630,7 @@ case 20: return eval.getScriptContext(); case 40: - statusManager.showEditor((String) paramInfo); + statusManager.showEditor((String[]) paramInfo); return null; case 60: scriptEditorVisible = ((Boolean)paramInfo).booleanValue(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |