use of org.eclipse.smarthome.config.core.ParameterOption in project smarthome by eclipse.
the class MediaActionTypeProvider method getSoundOptions.
/**
* This method creates one option for every file that is found in the sounds directory.
* As a label, the file extension is removed and the string is capitalized.
*
* @return a list of parameter options representing the sound files
*/
private List<ParameterOption> getSoundOptions() {
List<ParameterOption> options = new ArrayList<>();
File soundsDir = Paths.get(ConfigConstants.getConfigFolder(), AudioManager.SOUND_DIR).toFile();
if (soundsDir.isDirectory()) {
for (String fileName : soundsDir.list()) {
if (fileName.contains(".") && !fileName.startsWith(".")) {
String soundName = StringUtils.capitalize(fileName.substring(0, fileName.lastIndexOf(".")));
options.add(new ParameterOption(fileName, soundName));
}
}
}
return options;
}
Aggregations