Search in sources :

Example 1 with Language

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);
}
Also used : Language(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog.Language) SyntaxHighlightedMultiLineInputDialog(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog)

Example 2 with Language

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);
    }
}
Also used : Language(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog.Language) SyntaxHighlightedMultiLineInputDialog(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog) BackingStoreException(java.util.prefs.BackingStoreException)

Aggregations

SyntaxHighlightedMultiLineInputDialog (org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog)2 Language (org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog.Language)2 BackingStoreException (java.util.prefs.BackingStoreException)1