use of org.netxms.client.ScriptCompilationResult in project netxms by netxms.
the class ScriptEditorView method saveScript.
/**
* Save script
*/
private void saveScript() {
final String source = editor.getText();
editor.getTextWidget().setEditable(false);
new ConsoleJob(Messages.get().ScriptEditorView_SaveJobTitle, this, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().ScriptEditorView_SaveJobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final ScriptCompilationResult result = session.compileScript(source, false);
if (result.success) {
getDisplay().syncExec(new Runnable() {
@Override
public void run() {
editorMessageBar.hideMessage();
}
});
} else {
getDisplay().syncExec(new Runnable() {
@Override
public void run() {
if (MessageDialogHelper.openQuestion(getSite().getShell(), Messages.get().ScriptEditorView_CompilationErrors, String.format(Messages.get().ScriptEditorView_ScriptCompilationFailed, result.errorMessage)))
result.success = true;
editorMessageBar.showMessage(CompositeWithMessageBar.WARNING, result.errorMessage);
}
});
}
if (result.success) {
doScriptSave(source, monitor);
} else {
runInUIThread(new Runnable() {
@Override
public void run() {
editor.getTextWidget().setEditable(true);
}
});
}
}
}.start();
}
use of org.netxms.client.ScriptCompilationResult in project netxms by netxms.
the class ScriptEditorView method compileScript.
/**
* Compile script
*/
private void compileScript() {
final String source = editor.getText();
editor.getTextWidget().setEditable(false);
new ConsoleJob(Messages.get().ScriptEditorView_CompileScript, this, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().ScriptEditorView_CannotCompileScript;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final ScriptCompilationResult result = session.compileScript(source, false);
runInUIThread(new Runnable() {
@Override
public void run() {
if (result.success) {
editorMessageBar.showMessage(CompositeWithMessageBar.INFORMATION, Messages.get().ScriptEditorView_ScriptCompiledSuccessfully);
} else {
editorMessageBar.showMessage(CompositeWithMessageBar.WARNING, result.errorMessage);
}
editor.getTextWidget().setEditable(true);
}
});
}
}.start();
}
Aggregations