Commit 249d31d2 authored by ThorbenQuast's avatar ThorbenQuast
Browse files

editor: check for running jobs before closing and really kill the job if wanted

parent 4781a822
......@@ -42,10 +42,10 @@ var CodeEditorExtension = vispa.Extension.extend({
var CodeEditorView = vispa.ExtensionView.Center.extend({
init: function(preferences, shortcuts, path, writable, showOutput) {
//writable: force the editor to turn on/off read-only mode (writable -> read-only off)
//if file not writable but writable === true --> appropriate message when trying to save shows up
//showOutput: if set to false --> complete right side is hidden at first
//(loaded but not shown because css properties are simply set to appropriate values)
//writable: force the editor to turn on/off read-only mode (writable -> read-only off)
//if file not writable but writable === true --> appropriate message when trying to save shows up
//showOutput: if set to false --> complete right side is hidden at first
//(loaded but not shown because css properties are simply set to appropriate values)
if (writable === undefined)
writable = null;
if (showOutput === undefined)
......@@ -195,28 +195,45 @@ var CodeEditorView = vispa.ExtensionView.Center.extend({
clearTimeout(self.editor.keyupMinTimeout);
clearTimeout(self.editor.keyupMaxTimeout);
};
var checkSave = function() {
if (doAskSave)
self.confirm("Save changes before closing?", function(b) {
var afterSave = function() {
self.forceClose = true;
cleanUp();
self.close(); //close the editor after saving
};
if (b) {
if (self.editor.writable)
self.editor.save(afterSave);
else
self.editor.saveAs(afterSave);
} else
afterSave();
});
else {
cleanUp();
self.forceClose = true;
self.close();
}
};
// ask for saving
var doAsk = !this.forceClose && this.isModified();
if (doAsk)
this.confirm("Save changes before closing?", function(b) {
var afterSave = function() {
self.forceClose = true;
cleanUp();
self.close(); //close the editor after saving
};
if (b) {
if (self.editor.writable)
self.editor.save(afterSave);
else
self.editor.saveAs(afterSave);
} else
afterSave();
});
else
cleanUp();
var doAskSave = !this.forceClose && this.isModified();
//ask if job is still running
var doAskRunning = !this.forceClose && this.output.running;
if (doAskRunning)
self.confirm("<html>A job is still running. <br />" +
"Abort and close anyway?</html>",
function(b) {
if (b)
checkSave();
else {
self.editor.setupAutoSave();
}
});
return !doAsk;
return !doAskSave && !doAskRunning;
},
openNew: function() {
......
......@@ -38,9 +38,8 @@ class CodeEditorRpc:
logger.debug("CodeEditorRpc created")
def close(self):
if self._popen and self._popen.poll() is None:
self._popen.kill()
#so far equivalent to abort (might be extended in the future)
def close(self):
self._abort = True
def _send(self, topic, data=None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment