Search in sources :

Example 26 with ConfigDescriptionParameter

use of org.eclipse.smarthome.config.core.ConfigDescriptionParameter in project smarthome by eclipse.

the class PersistentInboxTest method configureConfigDescriptionRegistryMock.

private void configureConfigDescriptionRegistryMock(String paramName, Type type) throws URISyntaxException {
    URI configDescriptionURI = new URI("thing-type:test:test");
    ThingType thingType = ThingTypeBuilder.instance(THING_TYPE_UID, "Test").withConfigDescriptionURI(configDescriptionURI).build();
    ConfigDescriptionParameter param = ConfigDescriptionParameterBuilder.create(paramName, type).build();
    ConfigDescription configDesc = new ConfigDescription(configDescriptionURI, Collections.singletonList(param));
    when(thingTypeRegistry.getThingType(THING_TYPE_UID)).thenReturn(thingType);
    when(configDescriptionRegistry.getConfigDescription(eq(configDescriptionURI))).thenReturn(configDesc);
}
Also used : ConfigDescription(org.eclipse.smarthome.config.core.ConfigDescription) ConfigDescriptionParameter(org.eclipse.smarthome.config.core.ConfigDescriptionParameter) URI(java.net.URI) ThingType(org.eclipse.smarthome.core.thing.type.ThingType)

Example 27 with ConfigDescriptionParameter

use of org.eclipse.smarthome.config.core.ConfigDescriptionParameter in project smarthome by eclipse.

the class ItemChannelLinkConfigDescriptionProvider method getConfigDescription.

@Override
public ConfigDescription getConfigDescription(URI uri, Locale locale) {
    if (SCHEME.equals(uri.getScheme())) {
        ItemChannelLink link = itemChannelLinkRegistry.get(uri.getSchemeSpecificPart());
        if (link == null) {
            return null;
        }
        Item item = itemRegistry.get(link.getItemName());
        if (item == null) {
            return null;
        }
        Thing thing = thingRegistry.get(link.getLinkedUID().getThingUID());
        if (thing == null) {
            return null;
        }
        Channel channel = thing.getChannel(link.getLinkedUID().getId());
        if (channel == null) {
            return null;
        }
        ConfigDescriptionParameter paramProfile = ConfigDescriptionParameterBuilder.create(PARAM_PROFILE, Type.TEXT).withLabel("Profile").withDescription("the profile to use").withRequired(false).withLimitToOptions(true).withOptions(getOptions(link, item, channel, locale)).build();
        return new ConfigDescription(uri, Collections.singletonList(paramProfile));
    }
    return null;
}
Also used : Item(org.eclipse.smarthome.core.items.Item) Channel(org.eclipse.smarthome.core.thing.Channel) ItemChannelLink(org.eclipse.smarthome.core.thing.link.ItemChannelLink) ConfigDescription(org.eclipse.smarthome.config.core.ConfigDescription) ConfigDescriptionParameter(org.eclipse.smarthome.config.core.ConfigDescriptionParameter) Thing(org.eclipse.smarthome.core.thing.Thing)

Example 28 with ConfigDescriptionParameter

use of org.eclipse.smarthome.config.core.ConfigDescriptionParameter in project smarthome by eclipse.

the class ModuleTypeResourceBundleProvider method getPerLocale.

/**
 * This method is used to localize the {@link ModuleType}s.
 *
 * @param element is the {@link ModuleType} that must be localized.
 * @param locale represents a specific geographical, political, or cultural region.
 * @return the localized {@link ModuleType}.
 */
private ModuleType getPerLocale(ModuleType defModuleType, Locale locale) {
    if (locale == null || defModuleType == null || i18nProvider == null) {
        return defModuleType;
    }
    String uid = defModuleType.getUID();
    Bundle bundle = getBundle(uid);
    String llabel = ModuleTypeI18nUtil.getLocalizedModuleTypeLabel(i18nProvider, bundle, uid, defModuleType.getLabel(), locale);
    String ldescription = ModuleTypeI18nUtil.getLocalizedModuleTypeDescription(i18nProvider, bundle, uid, defModuleType.getDescription(), locale);
    List<ConfigDescriptionParameter> lconfigDescriptions = getLocalizedConfigurationDescription(i18nProvider, defModuleType.getConfigurationDescriptions(), bundle, uid, ModuleTypeI18nUtil.MODULE_TYPE, locale);
    if (defModuleType instanceof ActionType) {
        return createLocalizedActionType((ActionType) defModuleType, bundle, uid, locale, lconfigDescriptions, llabel, ldescription);
    }
    if (defModuleType instanceof ConditionType) {
        return createLocalizedConditionType((ConditionType) defModuleType, bundle, uid, locale, lconfigDescriptions, llabel, ldescription);
    }
    if (defModuleType instanceof TriggerType) {
        return createLocalizedTriggerType((TriggerType) defModuleType, bundle, uid, locale, lconfigDescriptions, llabel, ldescription);
    }
    return null;
}
Also used : CompositeTriggerType(org.eclipse.smarthome.automation.type.CompositeTriggerType) TriggerType(org.eclipse.smarthome.automation.type.TriggerType) CompositeActionType(org.eclipse.smarthome.automation.type.CompositeActionType) ActionType(org.eclipse.smarthome.automation.type.ActionType) Bundle(org.osgi.framework.Bundle) ConfigDescriptionParameter(org.eclipse.smarthome.config.core.ConfigDescriptionParameter) CompositeConditionType(org.eclipse.smarthome.automation.type.CompositeConditionType) ConditionType(org.eclipse.smarthome.automation.type.ConditionType)

Example 29 with ConfigDescriptionParameter

use of org.eclipse.smarthome.config.core.ConfigDescriptionParameter in project smarthome by eclipse.

the class TemplateResourceBundleProvider method getPerLocale.

/**
 * This method is used to localize the {@link Template}s.
 *
 * @param element is the {@link Template} that must be localized.
 * @param locale represents a specific geographical, political, or cultural region.
 * @return the localized {@link Template}.
 */
private RuleTemplate getPerLocale(RuleTemplate defTemplate, Locale locale) {
    if (locale == null || defTemplate == null || i18nProvider == null) {
        return defTemplate;
    }
    String uid = defTemplate.getUID();
    Bundle bundle = getBundle(uid);
    if (defTemplate instanceof RuleTemplate) {
        String llabel = RuleTemplateI18nUtil.getLocalizedRuleTemplateLabel(i18nProvider, bundle, uid, defTemplate.getLabel(), locale);
        String ldescription = RuleTemplateI18nUtil.getLocalizedRuleTemplateDescription(i18nProvider, bundle, uid, defTemplate.getDescription(), locale);
        List<ConfigDescriptionParameter> lconfigDescriptions = getLocalizedConfigurationDescription(i18nProvider, defTemplate.getConfigurationDescriptions(), bundle, uid, RuleTemplateI18nUtil.RULE_TEMPLATE, locale);
        List<Action> lactions = ModuleI18nUtil.getLocalizedModules(i18nProvider, defTemplate.getActions(), bundle, uid, RuleTemplateI18nUtil.RULE_TEMPLATE, locale);
        List<Condition> lconditions = ModuleI18nUtil.getLocalizedModules(i18nProvider, defTemplate.getConditions(), bundle, uid, RuleTemplateI18nUtil.RULE_TEMPLATE, locale);
        List<Trigger> ltriggers = ModuleI18nUtil.getLocalizedModules(i18nProvider, defTemplate.getTriggers(), bundle, uid, RuleTemplateI18nUtil.RULE_TEMPLATE, locale);
        return new RuleTemplate(uid, llabel, ldescription, defTemplate.getTags(), ltriggers, lconditions, lactions, lconfigDescriptions, defTemplate.getVisibility());
    }
    return null;
}
Also used : Condition(org.eclipse.smarthome.automation.Condition) Action(org.eclipse.smarthome.automation.Action) Trigger(org.eclipse.smarthome.automation.Trigger) Bundle(org.osgi.framework.Bundle) RuleTemplate(org.eclipse.smarthome.automation.template.RuleTemplate) ConfigDescriptionParameter(org.eclipse.smarthome.config.core.ConfigDescriptionParameter)

Aggregations

ConfigDescriptionParameter (org.eclipse.smarthome.config.core.ConfigDescriptionParameter)29 ArrayList (java.util.ArrayList)13 ConfigDescription (org.eclipse.smarthome.config.core.ConfigDescription)9 URI (java.net.URI)7 Configuration (org.eclipse.smarthome.config.core.Configuration)5 ParameterOption (org.eclipse.smarthome.config.core.ParameterOption)4 Test (org.junit.Test)4 Bundle (org.osgi.framework.Bundle)4 BigDecimal (java.math.BigDecimal)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Action (org.eclipse.smarthome.automation.Action)3 Condition (org.eclipse.smarthome.automation.Condition)3 Trigger (org.eclipse.smarthome.automation.Trigger)3 ConfigDescriptionParameterGroup (org.eclipse.smarthome.config.core.ConfigDescriptionParameterGroup)3 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)3 URISyntaxException (java.net.URISyntaxException)2 HashSet (java.util.HashSet)2 Rule (org.eclipse.smarthome.automation.Rule)2 Input (org.eclipse.smarthome.automation.type.Input)2