use of org.eclipse.smarthome.automation.type.TriggerType in project smarthome by eclipse.
the class ModuleTypeResourceBundleProvider method createLocalizedTriggerType.
/**
* Utility method for localization of TriggerTypes.
*
* @param ct is a TriggerType for localization.
* @param bundle the bundle providing localization resources.
* @param moduleTypeUID is a TriggerType uid.
* @param locale represents a specific geographical, political, or cultural region.
* @param lconfigDescriptions are TriggerType localized config descriptions.
* @param llabel is a TriggerType localized label.
* @param ldescription is a TriggerType localized description.
* @return localized TriggerType.
*/
private TriggerType createLocalizedTriggerType(TriggerType tt, Bundle bundle, String moduleTypeUID, Locale locale, List<ConfigDescriptionParameter> lconfigDescriptions, String llabel, String ldescription) {
List<Output> outputs = ModuleTypeI18nUtil.getLocalizedOutputs(i18nProvider, tt.getOutputs(), bundle, moduleTypeUID, locale);
TriggerType ltt = null;
if (tt instanceof CompositeTriggerType) {
List<Trigger> modules = ModuleI18nUtil.getLocalizedModules(i18nProvider, ((CompositeTriggerType) tt).getChildren(), bundle, moduleTypeUID, ModuleTypeI18nUtil.MODULE_TYPE, locale);
ltt = new CompositeTriggerType(moduleTypeUID, lconfigDescriptions, llabel, ldescription, tt.getTags(), tt.getVisibility(), outputs, modules);
} else {
ltt = new TriggerType(moduleTypeUID, lconfigDescriptions, llabel, ldescription, tt.getTags(), tt.getVisibility(), outputs);
}
return ltt;
}
use of org.eclipse.smarthome.automation.type.TriggerType in project smarthome by eclipse.
the class ModuleTypeRegistryMockup method createTriggerType.
private TriggerType createTriggerType() {
List<Output> outputs = new ArrayList<Output>(3);
outputs.add(createOutput("out1", new String[] { "tagA" }));
outputs.add(createOutput("out2", new String[] { "tagB", "tagC" }));
outputs.add(createOutput("out3", new String[] { "tagA", "tagB", "tagC" }));
TriggerType t = new TriggerType(TRIGGER_TYPE, null, outputs);
return t;
}
use of org.eclipse.smarthome.automation.type.TriggerType 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.TriggerType 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