From: Michael T H. <mic...@us...> - 2003-02-09 16:37:18
|
Update of /cvsroot/jmol/Jmol/src/org/openscience/jmol/app In directory sc8-pr-cvs1:/tmp/cvs-serv13308/app Modified Files: ScriptWindow.java Log Message: added halt button to script execution Index: ScriptWindow.java =================================================================== RCS file: /cvsroot/jmol/Jmol/src/org/openscience/jmol/app/ScriptWindow.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** ScriptWindow.java 9 Feb 2003 13:09:13 -0000 1.4 --- ScriptWindow.java 9 Feb 2003 16:37:15 -0000 1.5 *************** *** 52,57 **** private ConsoleTextPane console; - private JTextField input; private JButton closeButton; DisplayControl control; --- 52,58 ---- private ConsoleTextPane console; private JButton closeButton; + private JButton runButton; + private JButton haltButton; DisplayControl control; *************** *** 74,80 **** --- 75,91 ---- JPanel buttonPanel = new JPanel(); container.add(buttonPanel, BorderLayout.SOUTH); + closeButton = new JButton("Close"); closeButton.addActionListener(this); buttonPanel.add(closeButton); + + runButton = new JButton("Run"); + runButton.addActionListener(this); + buttonPanel.add(runButton); + + haltButton = new JButton("Halt"); + haltButton.addActionListener(this); + buttonPanel.add(haltButton); + haltButton.setEnabled(false); } *************** *** 89,127 **** console.outputError(strMsg); } } public void enterPressed() { ! executeCommand(); } void executeCommand() { ! String strCommand = console.getCommandString(); console.appendNewline(); console.setPrompt(); ! String strErrorMessage = control.evalString(strCommand); ! if (strErrorMessage != null) ! console.outputError(strErrorMessage); ! } ! ! public void actionPerformed(ActionEvent e) { ! ! if (e.getSource() == closeButton) { ! hide(); ! } else { ! String command = input.getText(); ! console.appendCommand(command); ! input.setText(null); ! ! String strErrorMessage = control.evalString(command); ! if (strErrorMessage != null) { console.outputError(strErrorMessage); ! console.setPrompt(); } } } ! public void hide() { ! // eval.haltExecution(); ! super.hide(); } } --- 100,137 ---- console.outputError(strMsg); } + runButton.setEnabled(true); + haltButton.setEnabled(false); } public void enterPressed() { ! runButton.doClick(100); ! // executeCommand(); } void executeCommand() { ! String strCommand = console.getCommandString().trim(); console.appendNewline(); console.setPrompt(); ! if (strCommand.length() > 0) { ! String strErrorMessage = control.evalString(strCommand); ! if (strErrorMessage != null) console.outputError(strErrorMessage); ! else { ! runButton.setEnabled(false); ! haltButton.setEnabled(true); } } + console.grabFocus(); } ! public void actionPerformed(ActionEvent e) { ! Object source = e.getSource(); ! if (source == closeButton) { ! hide(); ! } else if (source == runButton) { ! executeCommand(); ! } else if (source == haltButton) { ! control.haltScriptExecution(); ! } } } *************** *** 208,212 **** void setPrompt() { try { ! super.insertString(getLength(), "# ", attPrompt); offsetAfterPrompt = getLength(); positionBeforePrompt = createPosition(offsetAfterPrompt - 2); --- 218,222 ---- void setPrompt() { try { ! super.insertString(getLength(), "$ ", attPrompt); offsetAfterPrompt = getLength(); positionBeforePrompt = createPosition(offsetAfterPrompt - 2); |