Search in sources :

Example 16 with ParameterOption

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;
}
Also used : ParameterOption(org.eclipse.smarthome.config.core.ParameterOption) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

ParameterOption (org.eclipse.smarthome.config.core.ParameterOption)16 ArrayList (java.util.ArrayList)9 URI (java.net.URI)8 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)5 Test (org.junit.Test)5 List (java.util.List)4 ConfigDescriptionParameter (org.eclipse.smarthome.config.core.ConfigDescriptionParameter)4 BigDecimal (java.math.BigDecimal)2 FilterCriteria (org.eclipse.smarthome.config.core.FilterCriteria)2 AudioSink (org.eclipse.smarthome.core.audio.AudioSink)2 TTSServiceStub (org.eclipse.smarthome.core.voice.internal.TTSServiceStub)2 File (java.io.File)1 URISyntaxException (java.net.URISyntaxException)1 ZoneId (java.time.ZoneId)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 Locale (java.util.Locale)1 TimeZone (java.util.TimeZone)1 TimeUnit (java.util.concurrent.TimeUnit)1