public void propertyChange(PropertyChangeEvent pce) {
if (scriptPane == null)
return;
if (pce.getPropertyName().equals("state")) {
try {
Script source = (Script) pce.getSource();
if (source.getState() == ScriptState.RUNNING && originalCaret == -1) {
scriptPane.setEditable(false);
scriptPane.setHighlightCurrentLine(false);
originalCaret = scriptPane.getCaretPosition();
scriptPane.getCaret().setVisible(false);
scriptPane.getCaret().setSelectionVisible(false);
} else if (source.getState() == ScriptState.STOPPED) {
scriptPane.setHighlightCurrentLine(true);
unhighlightLastHighlightedBreakpoint();
scriptPane.setCaretPosition(originalCaret);
originalCaret = -1;
scriptPane.setEditable(true);