Search in sources :

Example 1 with BasicTitleSettingSpecifier

use of net.solarnetwork.settings.support.BasicTitleSettingSpecifier in project solarnetwork-node by SolarNetwork.

the class RegisterBlockConfig method settings.

/**
 * Get settings suitable for configuring an instance of this class.
 *
 * @param prefix
 *        a setting key prefix to use
 * @param messageSource
 *        the message source to use, or {@literal null}
 * @return the settings, never {@literal null}
 * @since 2.1
 */
public List<SettingSpecifier> settings(String prefix, MessageSource messageSource) {
    List<SettingSpecifier> result = new ArrayList<>(6);
    String info = registerInfo(messageSource);
    if (info != null) {
        result.add(new BasicTitleSettingSpecifier("addressInfo", info, true, messageSource != null));
    }
    result.add(new BasicTextFieldSettingSpecifier(prefix + "startAddress", "0"));
    // drop-down menu for block type
    BasicMultiValueSettingSpecifier propTypeSpec = new BasicMultiValueSettingSpecifier(prefix + "blockTypeKey", String.valueOf(DEFAULT_BLOCK_TYPE.getCode()));
    Map<String, String> propTypeTitles = new LinkedHashMap<>(3);
    for (RegisterBlockType e : RegisterBlockType.values()) {
        propTypeTitles.put(String.valueOf(e.getCode()), e.toString());
    }
    propTypeSpec.setValueTitles(propTypeTitles);
    result.add(propTypeSpec);
    MeasurementConfig[] measConfs = getMeasurementConfigs();
    List<MeasurementConfig> measConfsList = (measConfs != null ? Arrays.asList(measConfs) : Collections.<MeasurementConfig>emptyList());
    result.add(SettingUtils.dynamicListSettingSpecifier(prefix + "measurementConfigs", measConfsList, new SettingUtils.KeyedListCallback<MeasurementConfig>() {

        @Override
        public Collection<SettingSpecifier> mapListSettingKey(MeasurementConfig value, int index, String key) {
            BasicGroupSettingSpecifier configGroup = new BasicGroupSettingSpecifier(MeasurementConfig.settings(key + "."));
            return Collections.<SettingSpecifier>singletonList(configGroup);
        }
    }));
    return result;
}
Also used : BasicMultiValueSettingSpecifier(net.solarnetwork.settings.support.BasicMultiValueSettingSpecifier) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) BasicGroupSettingSpecifier(net.solarnetwork.settings.support.BasicGroupSettingSpecifier) BasicGroupSettingSpecifier(net.solarnetwork.settings.support.BasicGroupSettingSpecifier) BasicTitleSettingSpecifier(net.solarnetwork.settings.support.BasicTitleSettingSpecifier) BasicMultiValueSettingSpecifier(net.solarnetwork.settings.support.BasicMultiValueSettingSpecifier) BasicTextFieldSettingSpecifier(net.solarnetwork.settings.support.BasicTextFieldSettingSpecifier) SettingSpecifier(net.solarnetwork.settings.SettingSpecifier) BasicTextFieldSettingSpecifier(net.solarnetwork.settings.support.BasicTextFieldSettingSpecifier) BasicTitleSettingSpecifier(net.solarnetwork.settings.support.BasicTitleSettingSpecifier)

Example 2 with BasicTitleSettingSpecifier

use of net.solarnetwork.settings.support.BasicTitleSettingSpecifier in project solarnetwork-node by SolarNetwork.

the class RfidSocketReaderService method getSettingSpecifiers.

@Override
public List<SettingSpecifier> getSettingSpecifiers() {
    RfidSocketReaderService defaults = new RfidSocketReaderService();
    List<SettingSpecifier> results = new ArrayList<SettingSpecifier>(8);
    results.add(new BasicTitleSettingSpecifier("info", getInfoMessage(Locale.getDefault()), true));
    results.add(new BasicTextFieldSettingSpecifier("uid", defaults.uid));
    results.add(new BasicTextFieldSettingSpecifier("groupUid", defaults.groupUid));
    results.add(new BasicTextFieldSettingSpecifier("host", defaults.host));
    results.add(new BasicTextFieldSettingSpecifier("port", String.valueOf(defaults.port)));
    return results;
}
Also used : BasicTitleSettingSpecifier(net.solarnetwork.settings.support.BasicTitleSettingSpecifier) BasicTextFieldSettingSpecifier(net.solarnetwork.settings.support.BasicTextFieldSettingSpecifier) SettingSpecifier(net.solarnetwork.settings.SettingSpecifier) ArrayList(java.util.ArrayList) BasicTextFieldSettingSpecifier(net.solarnetwork.settings.support.BasicTextFieldSettingSpecifier) BasicTitleSettingSpecifier(net.solarnetwork.settings.support.BasicTitleSettingSpecifier)

Example 3 with BasicTitleSettingSpecifier

use of net.solarnetwork.settings.support.BasicTitleSettingSpecifier in project solarnetwork-node by SolarNetwork.

the class YasdiMasterDeviceFactory method getSettingSpecifiers.

@Override
public List<SettingSpecifier> getSettingSpecifiers() {
    List<SettingSpecifier> results = getDefaultSettingSpecifiers();
    // add in read-only device UIDs
    Set<String> deviceNames = new TreeSet<String>();
    try {
        // call getObject() to initialize
        getObject();
        for (YasdiMasterDeviceFactory factory : FACTORIES.keySet()) {
            YasdiMaster master = factory.getObject();
            deviceNames.add(master.getName());
        }
        for (String deviceName : deviceNames) {
            results.add(0, new BasicTitleSettingSpecifier("availableDevice", deviceName, true));
        }
    } catch (RuntimeException e) {
        log.warn("Exception getting YASDI device names: {}", e.getMessage());
    }
    return results;
}
Also used : BasicTitleSettingSpecifier(net.solarnetwork.settings.support.BasicTitleSettingSpecifier) SettingSpecifier(net.solarnetwork.settings.SettingSpecifier) BasicTextFieldSettingSpecifier(net.solarnetwork.settings.support.BasicTextFieldSettingSpecifier) BasicToggleSettingSpecifier(net.solarnetwork.settings.support.BasicToggleSettingSpecifier) TreeSet(java.util.TreeSet) BasicTitleSettingSpecifier(net.solarnetwork.settings.support.BasicTitleSettingSpecifier)

Example 4 with BasicTitleSettingSpecifier

use of net.solarnetwork.settings.support.BasicTitleSettingSpecifier in project solarnetwork-node by SolarNetwork.

the class PowerGatePlusDatumDataSource method getSettingSpecifiers.

@Override
public List<SettingSpecifier> getSettingSpecifiers() {
    List<SettingSpecifier> results = new ArrayList<>(12);
    results.add(new BasicTitleSettingSpecifier("info", getInfoMessage(), true));
    results.add(new BasicTitleSettingSpecifier("sample", getSampleMessage(getSample()), true));
    results.addAll(getIdentifiableSettingSpecifiers());
    results.addAll(getModbusNetworkSettingSpecifiers());
    PowerGatePlusDatumDataSource defaults = new PowerGatePlusDatumDataSource();
    results.add(new BasicTextFieldSettingSpecifier("sampleCacheMs", String.valueOf(defaults.getSampleCacheMs())));
    results.add(new BasicTextFieldSettingSpecifier("sourceId", defaults.sourceId));
    return results;
}
Also used : BasicTitleSettingSpecifier(net.solarnetwork.settings.support.BasicTitleSettingSpecifier) BasicTextFieldSettingSpecifier(net.solarnetwork.settings.support.BasicTextFieldSettingSpecifier) SettingSpecifier(net.solarnetwork.settings.SettingSpecifier) ArrayList(java.util.ArrayList) BasicTextFieldSettingSpecifier(net.solarnetwork.settings.support.BasicTextFieldSettingSpecifier) BasicTitleSettingSpecifier(net.solarnetwork.settings.support.BasicTitleSettingSpecifier)

Example 5 with BasicTitleSettingSpecifier

use of net.solarnetwork.settings.support.BasicTitleSettingSpecifier in project solarnetwork-node by SolarNetwork.

the class SolarCfgWifiConfiguration method getSettingSpecifiers.

@Override
public List<SettingSpecifier> getSettingSpecifiers() {
    final Settings settings = currentSettings();
    final Status status = currentStatus();
    final List<SettingSpecifier> result = new ArrayList<>(4);
    result.add(new BasicTitleSettingSpecifier("status", statusMessage(status)));
    // note how all WiFi settings have transient = true; this prevents them from getting copied into
    // the settings database; thus we rely on the OS-configured values
    BasicTextFieldSettingSpecifier f = new BasicTextFieldSettingSpecifier("country", settings.country);
    f.setTransient(true);
    result.add(f);
    f = new BasicTextFieldSettingSpecifier("ssid", settings.ssid);
    f.setTransient(true);
    result.add(f);
    f = new BasicTextFieldSettingSpecifier("password", "", true);
    f.setTransient(true);
    result.add(f);
    return result;
}
Also used : InstructionStatus(net.solarnetwork.node.reactor.InstructionStatus) BasicTitleSettingSpecifier(net.solarnetwork.settings.support.BasicTitleSettingSpecifier) SettingSpecifier(net.solarnetwork.settings.SettingSpecifier) BasicTextFieldSettingSpecifier(net.solarnetwork.settings.support.BasicTextFieldSettingSpecifier) ArrayList(java.util.ArrayList) BasicTextFieldSettingSpecifier(net.solarnetwork.settings.support.BasicTextFieldSettingSpecifier) BasicTitleSettingSpecifier(net.solarnetwork.settings.support.BasicTitleSettingSpecifier)

Aggregations

BasicTitleSettingSpecifier (net.solarnetwork.settings.support.BasicTitleSettingSpecifier)77 SettingSpecifier (net.solarnetwork.settings.SettingSpecifier)76 BasicTextFieldSettingSpecifier (net.solarnetwork.settings.support.BasicTextFieldSettingSpecifier)68 ArrayList (java.util.ArrayList)64 BasicGroupSettingSpecifier (net.solarnetwork.settings.support.BasicGroupSettingSpecifier)19 BasicToggleSettingSpecifier (net.solarnetwork.settings.support.BasicToggleSettingSpecifier)18 LinkedHashMap (java.util.LinkedHashMap)10 BasicMultiValueSettingSpecifier (net.solarnetwork.settings.support.BasicMultiValueSettingSpecifier)9 LinkedHashSet (java.util.LinkedHashSet)5 BasicFileSettingSpecifier (net.solarnetwork.node.settings.support.BasicFileSettingSpecifier)5 IOException (java.io.IOException)3 Collection (java.util.Collection)3 BasicSetupResourceSettingSpecifier (net.solarnetwork.node.settings.support.BasicSetupResourceSettingSpecifier)3 ExpressionService (net.solarnetwork.service.ExpressionService)3 Locale (java.util.Locale)2 TreeSet (java.util.TreeSet)2 ExpressionConfig (net.solarnetwork.node.service.support.ExpressionConfig)2 ResourceSetupResource (net.solarnetwork.node.setup.ResourceSetupResource)2 SetupResource (net.solarnetwork.node.setup.SetupResource)2 SetupResourceProvider (net.solarnetwork.node.setup.SetupResourceProvider)2