use of org.eclipse.smarthome.automation.type.ConditionType in project smarthome by eclipse.
the class ModuleTypeRegistryMockup method createConditionType.
private ConditionType createConditionType() {
List<Input> inputs = new ArrayList<Input>(3);
// no connection, missing condition tag
inputs.add(createInput("in0", new String[] { "tagE" }));
// conflict in2 -> out1 or in2 -> out3
inputs.add(createInput("in1", new String[] { "tagA" }));
// in2 -> out3
inputs.add(createInput("in2", new String[] { "tagA", "tagB" }));
ConditionType t = new ConditionType(CONDITION_TYPE, null, inputs);
return t;
}
use of org.eclipse.smarthome.automation.type.ConditionType in project smarthome by eclipse.
the class ModuleTypeResourceBundleProvider method createLocalizedConditionType.
/**
* Utility method for localization of ConditionTypes.
*
* @param ct is a ConditionType for localization.
* @param bundle the bundle providing localization resources.
* @param moduleTypeUID is a ConditionType uid.
* @param locale represents a specific geographical, political, or cultural region.
* @param lconfigDescriptions are ConditionType localized config descriptions.
* @param llabel is a ConditionType localized label.
* @param ldescription is a ConditionType localized description.
* @return localized ConditionType.
*/
private ConditionType createLocalizedConditionType(ConditionType ct, Bundle bundle, String moduleTypeUID, Locale locale, List<ConfigDescriptionParameter> lconfigDescriptions, String llabel, String ldescription) {
List<Input> inputs = ModuleTypeI18nUtil.getLocalizedInputs(i18nProvider, ct.getInputs(), bundle, moduleTypeUID, locale);
ConditionType lct = null;
if (ct instanceof CompositeConditionType) {
List<Condition> modules = ModuleI18nUtil.getLocalizedModules(i18nProvider, ((CompositeConditionType) ct).getChildren(), bundle, moduleTypeUID, ModuleTypeI18nUtil.MODULE_TYPE, locale);
lct = new CompositeConditionType(moduleTypeUID, lconfigDescriptions, llabel, ldescription, ct.getTags(), ct.getVisibility(), inputs, modules);
} else {
lct = new ConditionType(moduleTypeUID, lconfigDescriptions, llabel, ldescription, ct.getTags(), ct.getVisibility(), inputs);
}
return lct;
}
use of org.eclipse.smarthome.automation.type.ConditionType 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.automation.type.ConditionType in project smarthome by eclipse.
the class ModuleTypeGSONParser method createMapByType.
private Map<String, List<? extends ModuleType>> createMapByType(Set<ModuleType> dataObjects) {
Map<String, List<? extends ModuleType>> map = new HashMap<String, List<? extends ModuleType>>();
List<TriggerType> triggers = new ArrayList<TriggerType>();
List<ConditionType> conditions = new ArrayList<ConditionType>();
List<ActionType> actions = new ArrayList<ActionType>();
for (ModuleType moduleType : dataObjects) {
if (moduleType instanceof TriggerType) {
triggers.add((TriggerType) moduleType);
} else if (moduleType instanceof ConditionType) {
conditions.add((ConditionType) moduleType);
} else if (moduleType instanceof ActionType) {
actions.add((ActionType) moduleType);
}
}
map.put("triggers", triggers);
map.put("conditions", conditions);
map.put("actions", actions);
return map;
}
Aggregations