Search in sources :

Example 1 with NestedTransferPluginOption

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);
    }
}
Also used : TransferPluginOptionCallback(org.syncany.plugins.transfer.TransferPluginOptionCallback) TransferPluginOption(org.syncany.plugins.transfer.TransferPluginOption) NestedTransferPluginOption(org.syncany.plugins.transfer.NestedTransferPluginOption) TransferSettings(org.syncany.plugins.transfer.TransferSettings)

Example 2 with NestedTransferPluginOption

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()));
    }
}
Also used : NestedTransferPluginOption(org.syncany.plugins.transfer.NestedTransferPluginOption) TransferPluginOption(org.syncany.plugins.transfer.TransferPluginOption) NestedTransferPluginOption(org.syncany.plugins.transfer.NestedTransferPluginOption) TransferSettings(org.syncany.plugins.transfer.TransferSettings) DummyTransferSettings(org.syncany.plugins.dummy.DummyTransferSettings)

Aggregations

NestedTransferPluginOption (org.syncany.plugins.transfer.NestedTransferPluginOption)2 TransferPluginOption (org.syncany.plugins.transfer.TransferPluginOption)2 TransferSettings (org.syncany.plugins.transfer.TransferSettings)2 DummyTransferSettings (org.syncany.plugins.dummy.DummyTransferSettings)1 TransferPluginOptionCallback (org.syncany.plugins.transfer.TransferPluginOptionCallback)1