Search in sources :

Example 16 with ScriptEngineFactory

use of javax.script.ScriptEngineFactory in project intellij-community by JetBrains.

the class Jsr223IdeScriptEngineManagerImpl method getFileExtensions.

@NotNull
@Override
public List<String> getFileExtensions(@Nullable String language) {
    List<String> extensions = ContainerUtil.newArrayList();
    List<ScriptEngineFactory> factories = getScriptEngineManager().getEngineFactories();
    for (ScriptEngineFactory factory : factories) {
        if (language == null || factory.getLanguageName().equals(language)) {
            extensions.addAll(factory.getExtensions());
        }
    }
    return extensions;
}
Also used : ScriptEngineFactory(javax.script.ScriptEngineFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with ScriptEngineFactory

use of javax.script.ScriptEngineFactory in project JMRI by JMRI.

the class ScriptFileChooser method init.

private void init() {
    List<String> allExtensions = new ArrayList<>();
    HashMap<String, FileFilter> filters = new HashMap<>();
    List<String> filterNames = new ArrayList<>();
    JmriScriptEngineManager.getDefault().getManager().getEngineFactories().stream().forEach((ScriptEngineFactory factory) -> {
        List<String> extensions = factory.getExtensions();
        allExtensions.addAll(extensions);
        String name = this.fileForLanguage(factory.getLanguageName());
        filterNames.add(name);
        filters.put(name, new FileNameExtensionFilter(name, extensions.toArray(new String[extensions.size()])));
    });
    FileFilter allScripts = new FileNameExtensionFilter(Bundle.getMessage("allScripts"), allExtensions.toArray(new String[allExtensions.size()]));
    this.addChoosableFileFilter(allScripts);
    filterNames.stream().sorted().forEach((filter) -> {
        this.addChoosableFileFilter(filters.get(filter));
    });
    this.setFileFilter(allScripts);
    this.setFileSelectionMode(JFileChooser.FILES_ONLY);
}
Also used : HashMap(java.util.HashMap) ScriptEngineFactory(javax.script.ScriptEngineFactory) ArrayList(java.util.ArrayList) FileFilter(javax.swing.filechooser.FileFilter) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter)

Example 18 with ScriptEngineFactory

use of javax.script.ScriptEngineFactory in project binnavi by google.

the class LanguageBox method fillLanguageBox.

private void fillLanguageBox(final ScriptEngineManager manager) {
    final List<ScriptEngineFactory> factories = manager.getEngineFactories();
    final List<ScriptingLanguage> languages = new ArrayList<ScriptingLanguage>();
    for (final ScriptEngineFactory factory : factories) {
        // Disable Rhino scripting engine for JavaScript / ECMAScript.
        if (factory.getLanguageName().equals("python")) {
            languages.add(new ScriptingLanguage(factory.getLanguageName(), factory.getLanguageVersion()));
        }
    }
    Collections.sort(languages);
    for (final ScriptingLanguage language : languages) {
        addItem(language);
    }
}
Also used : ScriptEngineFactory(javax.script.ScriptEngineFactory) ArrayList(java.util.ArrayList)

Example 19 with ScriptEngineFactory

use of javax.script.ScriptEngineFactory in project hazelcast by hazelcast.

the class HazelcastOSGiScriptEngineFactoryTest method registerAndGetScriptEngineByMimeTypeSuccessfully.

@Test
public void registerAndGetScriptEngineByMimeTypeSuccessfully() {
    ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
    GroovyScriptEngineFactory groovyScriptEngineFactory = new GroovyScriptEngineFactory();
    scriptEngineManager.registerEngineMimeType("application/x-groovy", groovyScriptEngineFactory);
    ScriptEngine scriptEngine = scriptEngineManager.getEngineByMimeType("application/x-groovy");
    assertNotNull(scriptEngine);
    ScriptEngineFactory scriptEngineFactory = scriptEngine.getFactory();
    verifyScriptEngineFactory(scriptEngineFactory);
}
Also used : GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineFactory(javax.script.ScriptEngineFactory) GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineManager(javax.script.ScriptEngineManager) ScriptEngine(javax.script.ScriptEngine) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 20 with ScriptEngineFactory

use of javax.script.ScriptEngineFactory in project hazelcast by hazelcast.

the class HazelcastOSGiScriptEngineFactoryTest method registerAndGetScriptEngineByNameSuccessfully.

@Test
public void registerAndGetScriptEngineByNameSuccessfully() {
    ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
    GroovyScriptEngineFactory groovyScriptEngineFactory = new GroovyScriptEngineFactory();
    scriptEngineManager.registerEngineName("groovy", groovyScriptEngineFactory);
    ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("groovy");
    assertNotNull(scriptEngine);
    ScriptEngineFactory scriptEngineFactory = scriptEngine.getFactory();
    verifyScriptEngineFactory(scriptEngineFactory);
}
Also used : GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineFactory(javax.script.ScriptEngineFactory) GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineManager(javax.script.ScriptEngineManager) ScriptEngine(javax.script.ScriptEngine) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ScriptEngineFactory (javax.script.ScriptEngineFactory)30 ScriptEngineManager (javax.script.ScriptEngineManager)11 ScriptEngine (javax.script.ScriptEngine)9 Test (org.junit.Test)9 QuickTest (com.hazelcast.test.annotation.QuickTest)8 GroovyScriptEngineFactory (org.codehaus.groovy.jsr223.GroovyScriptEngineFactory)8 ArrayList (java.util.ArrayList)4 URL (java.net.URL)2 HashMap (java.util.HashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 JSONWriter (org.apache.felix.utils.json.JSONWriter)2 Result (com.buschmais.jqassistant.core.analysis.api.Result)1 RuleExecutorException (com.buschmais.jqassistant.core.rule.api.executor.RuleExecutorException)1 OSQLScriptEngineFactory (com.orientechnologies.orient.core.sql.OSQLScriptEngineFactory)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1