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;
}
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);
}
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);
}
}
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);
}
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);
}
Aggregations