use of org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog.Language in project org.csstudio.display.builder by kasemir.
the class ScriptsDialog method add.
private void add(final String file, final String text) {
final ScriptItem newItem = new ScriptItem(file, text, true, new ArrayList<>());
script_items.add(newItem);
scripts_table.getSelectionModel().select(newItem);
final int newRow = scripts_table.getSelectionModel().getSelectedIndex();
ModelThreadPool.getTimer().schedule(() -> {
if (ScriptInfo.isEmbedded(file)) {
Platform.runLater(() -> {
final Language language = ScriptInfo.isJython(selected_script_item.getScriptInfo().getPath()) ? Language.Python : Language.JavaScript;
final SyntaxHighlightedMultiLineInputDialog dlg = new SyntaxHighlightedMultiLineInputDialog(scripts_table, selected_script_item.text, language);
DialogHelper.positionDialog(dlg, btn_edit, -300, -200);
dlg.showAndWait().ifPresent(result -> selected_script_item.text = result);
});
} else
Platform.runLater(() -> scripts_table.edit(newRow, scripts_name_col));
}, 123, TimeUnit.MILLISECONDS);
}
use of org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog.Language in project org.csstudio.display.builder by kasemir.
the class ScriptsDialog method editOrSelect.
private void editOrSelect() {
if (Messages.Select.equals(btn_edit.getText())) {
try {
// Use the script file name, except if that's the example name,
// because it doesn't exist and file dialog will then start
// in some random directory instead of the display file's dir.
String initial = selected_script_item.file.get();
if (Messages.ScriptsDialog_DefaultScriptFile.equals(initial))
initial = "";
final String path = FilenameSupport.promptForRelativePath(widget, initial);
if (path != null) {
selected_script_item.file.set(path);
selected_script_item.text = null;
}
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot prompt for filename", ex);
}
FilenameSupport.performMostAwfulTerribleNoGoodHack(scripts_table);
} else {
final Language language = ScriptInfo.isJython(selected_script_item.getScriptInfo().getPath()) ? Language.Python : Language.JavaScript;
final SyntaxHighlightedMultiLineInputDialog dlg = new SyntaxHighlightedMultiLineInputDialog(btn_edit, selected_script_item.text, language);
DialogHelper.positionDialog(dlg, btn_edit, -300, -200);
dlg.showAndWait().ifPresent(result -> selected_script_item.text = result);
}
}
Aggregations