Search in sources :

Example 6 with TriggerType

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;
}
Also used : CompositeTriggerType(org.eclipse.smarthome.automation.type.CompositeTriggerType) TriggerType(org.eclipse.smarthome.automation.type.TriggerType) CompositeTriggerType(org.eclipse.smarthome.automation.type.CompositeTriggerType) Trigger(org.eclipse.smarthome.automation.Trigger) Output(org.eclipse.smarthome.automation.type.Output)

Example 7 with TriggerType

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;
}
Also used : TriggerType(org.eclipse.smarthome.automation.type.TriggerType) Output(org.eclipse.smarthome.automation.type.Output) ArrayList(java.util.ArrayList)

Example 8 with TriggerType

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;
}
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 9 with TriggerType

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;
}
Also used : CompositeTriggerType(org.eclipse.smarthome.automation.type.CompositeTriggerType) TriggerType(org.eclipse.smarthome.automation.type.TriggerType) ModuleType(org.eclipse.smarthome.automation.type.ModuleType) ActionType(org.eclipse.smarthome.automation.type.ActionType) CompositeActionType(org.eclipse.smarthome.automation.type.CompositeActionType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CompositeConditionType(org.eclipse.smarthome.automation.type.CompositeConditionType) ConditionType(org.eclipse.smarthome.automation.type.ConditionType)

Aggregations

TriggerType (org.eclipse.smarthome.automation.type.TriggerType)9 CompositeTriggerType (org.eclipse.smarthome.automation.type.CompositeTriggerType)7 ArrayList (java.util.ArrayList)4 ActionType (org.eclipse.smarthome.automation.type.ActionType)4 CompositeActionType (org.eclipse.smarthome.automation.type.CompositeActionType)4 CompositeConditionType (org.eclipse.smarthome.automation.type.CompositeConditionType)4 ConditionType (org.eclipse.smarthome.automation.type.ConditionType)4 ModuleType (org.eclipse.smarthome.automation.type.ModuleType)4 HashMap (java.util.HashMap)3 Trigger (org.eclipse.smarthome.automation.Trigger)3 Output (org.eclipse.smarthome.automation.type.Output)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 Action (org.eclipse.smarthome.automation.Action)1 Condition (org.eclipse.smarthome.automation.Condition)1 Input (org.eclipse.smarthome.automation.type.Input)1 ConfigDescriptionParameter (org.eclipse.smarthome.config.core.ConfigDescriptionParameter)1 Bundle (org.osgi.framework.Bundle)1