boolean speaking = NbPreferences.forModule(TextToSpeechPanel.class).getBoolean(TextToSpeechOptions.SPEECH_ENABLED, true);
setSpeakingVisually(speaking);
// Fill out the "engines" combo box.
Iterator<TextToSpeechEngine> engines = speech.getAvailableEngines();
TextToSpeechEngine currentEngine = speech.getTextToSpeechEngine();
DefaultComboBoxModel oldModel = (DefaultComboBoxModel) enginesComboBox.getModel();
oldModel.removeAllElements();
int i = 0;
while(engines.hasNext()) {
TextToSpeechEngine next = engines.next();
if ((next == TextToSpeechEngine.JAWS && !TextToSpeechFactory.jawsScriptExists(SODBEANS_SCRIPT_NAME))
|| (next == TextToSpeechEngine.NVDA && !TextToSpeechFactory.nvdaScriptExists(SODBEANS_SCRIPT_NAME))
|| (next != TextToSpeechEngine.JAWS && next != TextToSpeechEngine.NVDA))
{
oldModel.addElement(lookupEngineObject(next));
if (currentEngine.equals(next)) {
enginesComboBox.setSelectedIndex(i);
}
i++;
}
}
// Fill in the "available voices" combobox.
populateVoices();
Iterator<SpeechVoice> voices = speech.getAvailableVoices();
SpeechVoice currentVoice = speech.getCurrentVoice();
voiceComboBox.setSelectedIndex(0); // Select default voice first.
if (currentVoice != null) {
i = 0;
while(voices.hasNext()) {
SpeechVoice next = voices.next();
if(currentVoice.getName().equals(next.getName())) {
voiceComboBox.setSelectedIndex(i);
}
i++;
}
}