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