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