use of org.syncany.plugins.transfer.NestedTransferPluginOption in project syncany by syncany.
the class AbstractInitCommand method askConreteChildPluginSettings.
/**
* Asks the user for all of the child plugin's settings.
*
* <p>This case is triggered by a field looking like this:
* <tt>private LocalTransferSettings localChildPluginSettings;</tt>
*/
private void askConreteChildPluginSettings(TransferSettings settings, NestedTransferPluginOption option, Map<String, String> knownPluginSettings, String nestPrefix) throws StorageException, IllegalAccessException, InstantiationException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
TransferPluginOptionCallback optionCallback = createOptionCallback(settings, option.getCallback());
if (isInteractive) {
callAndPrintPreQueryCallback(optionCallback);
out.println();
out.println(option.getDescription() + ":");
}
for (TransferPluginOption nestedPluginOption : option.getOptions()) {
Class<?> nestedTransferSettingsClass = ReflectionUtil.getClassFromType(option.getType());
if (nestedTransferSettingsClass == null) {
throw new RuntimeException("No class found for type: " + option.getType());
}
TransferSettings nestedSettings = (TransferSettings) nestedTransferSettingsClass.newInstance();
settings.setField(option.getField().getName(), nestedSettings);
nestPrefix = nestPrefix + option.getName() + NESTED_OPTIONS_SEPARATOR;
askPluginSettings(nestedSettings, nestedPluginOption, knownPluginSettings, nestPrefix);
}
if (isInteractive) {
callAndPrintPostQueryCallback(optionCallback, null);
}
}
use of org.syncany.plugins.transfer.NestedTransferPluginOption in project syncany by syncany.
the class PluginOptionsTest method askNestedPluginSettings.
private void askNestedPluginSettings(TransferSettings settings, TransferPluginOption option, int wrap) throws Exception {
if (option instanceof NestedTransferPluginOption) {
assertNotNull(ReflectionUtil.getClassFromType(option.getType()));
System.out.println(new String(new char[wrap]).replace("\0", "\t") + ReflectionUtil.getClassFromType(option.getType()) + "#" + option.getField().getName() + " (nested)");
TransferSettings nestedSettings = (TransferSettings) ReflectionUtil.getClassFromType(option.getType()).newInstance();
settings.setField(option.getField().getName(), nestedSettings);
for (TransferPluginOption nItem : ((NestedTransferPluginOption) option).getOptions()) {
askNestedPluginSettings(nestedSettings, nItem, ++wrap);
}
} else {
System.out.println(new String(new char[wrap]).replace("\0", "\t") + settings.getClass() + "#" + option.getField().getName());
settings.setField(option.getField().getName(), String.valueOf(settings.hashCode()));
}
}
Aggregations