Search in sources :

Example 1 with PluginInfo

use of org.syncany.operations.plugin.PluginInfo in project syncany by syncany.

the class PluginCommand method printResultList.

private void printResultList(PluginOperationResult operationResult) {
    if (operationResult.getResultCode() == PluginResultCode.OK) {
        List<String[]> tableValues = new ArrayList<String[]>();
        tableValues.add(new String[] { "Id", "Name", "Local Version", "Type", "Remote Version", "Updatable", "Provided By" });
        int outdatedCount = 0;
        int updatableCount = 0;
        int thirdPartyCount = 0;
        for (ExtendedPluginInfo extPluginInfo : operationResult.getPluginList()) {
            PluginInfo pluginInfo = (extPluginInfo.isInstalled()) ? extPluginInfo.getLocalPluginInfo() : extPluginInfo.getRemotePluginInfo();
            String localVersionStr = (extPluginInfo.isInstalled()) ? extPluginInfo.getLocalPluginInfo().getPluginVersion() : "";
            String installedStr = extPluginInfo.isInstalled() ? (extPluginInfo.canUninstall() ? "User" : "Global") : "";
            String remoteVersionStr = (extPluginInfo.isRemoteAvailable()) ? extPluginInfo.getRemotePluginInfo().getPluginVersion() : "";
            String thirdPartyStr = (pluginInfo.isPluginThirdParty()) ? "Third Party" : "Syncany Team";
            String updatableStr = "";
            if (extPluginInfo.isInstalled() && extPluginInfo.isOutdated()) {
                if (extPluginInfo.canUninstall()) {
                    updatableStr = "Auto";
                    updatableCount++;
                } else {
                    updatableStr = "Manual";
                }
                outdatedCount++;
            }
            if (pluginInfo.isPluginThirdParty()) {
                thirdPartyCount++;
            }
            tableValues.add(new String[] { pluginInfo.getPluginId(), pluginInfo.getPluginName(), localVersionStr, installedStr, remoteVersionStr, updatableStr, thirdPartyStr });
        }
        CliTableUtil.printTable(out, tableValues, "No plugins found.");
        if (outdatedCount > 0) {
            String isAre = (outdatedCount == 1) ? "is" : "are";
            String pluginPlugins = (outdatedCount == 1) ? "plugin" : "plugins";
            out.printf("\nUpdates:\nThere %s %d outdated %s, %d of them %s automatically updatable.\n", isAre, outdatedCount, pluginPlugins, updatableCount, isAre);
        }
        if (thirdPartyCount > 0) {
            String pluginPlugins = (thirdPartyCount == 1) ? "plugin" : "plugins";
            out.printf("\nThird party plugins:\nPlease note that the Syncany Team does not review or maintain the third-party %s\nlisted above. Please report issues to the corresponding plugin site.\n", pluginPlugins);
        }
    } else {
        out.printf("Listing plugins failed. No connection? Try -d to get more details.\n");
        out.println();
    }
}
Also used : ExtendedPluginInfo(org.syncany.operations.plugin.ExtendedPluginInfo) ArrayList(java.util.ArrayList) PluginInfo(org.syncany.operations.plugin.PluginInfo) ExtendedPluginInfo(org.syncany.operations.plugin.ExtendedPluginInfo)

Aggregations

ArrayList (java.util.ArrayList)1 ExtendedPluginInfo (org.syncany.operations.plugin.ExtendedPluginInfo)1 PluginInfo (org.syncany.operations.plugin.PluginInfo)1