TUP-2844 : fixed Optional and Required libs download from maven

This commit is contained in:
Sebastien Gandon
2015-06-03 15:02:29 +02:00
parent 93e8867a46
commit 6d54abb459
8 changed files with 531 additions and 660 deletions

View File

@@ -28,6 +28,7 @@ import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
import org.talend.commons.utils.VersionUtils;
import org.talend.core.model.general.ModuleToInstall;
import org.talend.core.runtime.maven.MavenConstants;
import org.talend.librariesmanager.ui.dialogs.ModuleLicenseDialog;
import org.talend.librariesmanager.utils.DownloadModuleRunnable;
import org.talend.librariesmanager.utils.RemoteModulesHelper;
@@ -41,11 +42,11 @@ public class TalendWebServiceUpdateExtraFeature implements ExtraFeature {
private final List<ModuleToInstall> modulesToBeInstalled;
private String name;
private String name;
private String description;
private String description;
private boolean mustBeInstalled;
private boolean mustBeInstalled;
/**
* DOC sgandon TalendWebServiceUpdate constructor comment.
@@ -65,10 +66,10 @@ public class TalendWebServiceUpdateExtraFeature implements ExtraFeature {
* @return
*/
public static ArrayList<ModuleToInstall> filterAllAutomaticInstallableModules(ArrayList<ModuleToInstall> modules) {
ArrayList<ModuleToInstall> modulesForAutomaticInstall = new ArrayList<ModuleToInstall>(modules.size());
ArrayList<ModuleToInstall> modulesForAutomaticInstall = new ArrayList<ModuleToInstall>( modules.size() );
for (ModuleToInstall module : modules) {
if (module.getUrl_download() != null) {
modulesForAutomaticInstall.add(module);
if (!MavenConstants.DOWNLOAD_MANUAL.equals( module.getDistribution() )) {
modulesForAutomaticInstall.add( module );
}// else not automatic so ignor
}
return modulesForAutomaticInstall;
@@ -85,28 +86,28 @@ public class TalendWebServiceUpdateExtraFeature implements ExtraFeature {
// license
// and I do not have the time to use a delegate pattern.
DownloadModuleRunnable downloadModule = new DownloadModuleRunnable(modulesToBeInstalled) {
DownloadModuleRunnable downloadModule = new DownloadModuleRunnable( modulesToBeInstalled ) {
@Override
protected boolean acceptLicence(ModuleToInstall module) {
return TalendWebServiceUpdateExtraFeature.acceptLicence(module);
return TalendWebServiceUpdateExtraFeature.acceptLicence( module );
}
};
downloadModule.run(progress);
downloadModule.run( progress );
// compute the dowload status
Set<String> jarsFailedToDownload = downloadModule.getDownloadFailed();
if (jarsFailedToDownload.isEmpty()) {
return Messages.createOkStatus("UpdateStudioWizard.missing.jar.download.ok"); //$NON-NLS-1$
return Messages.createOkStatus( "UpdateStudioWizard.missing.jar.download.ok" ); //$NON-NLS-1$
} else {
Status errorStatus = Messages.createErrorStatus(null, "UpdateStudioWizard.missing.jar.download.failed", //$NON-NLS-1$
Arrays.toString(jarsFailedToDownload.toArray(new String[jarsFailedToDownload.size()])));
MultiStatus multiStatus = new MultiStatus(errorStatus.getPlugin(), errorStatus.getSeverity(),
errorStatus.getMessage(), null);
multiStatus.add(errorStatus);
Status errorStatus = Messages.createErrorStatus( null, "UpdateStudioWizard.missing.jar.download.failed", //$NON-NLS-1$
Arrays.toString( jarsFailedToDownload.toArray( new String[jarsFailedToDownload.size()] ) ) );
MultiStatus multiStatus = new MultiStatus( errorStatus.getPlugin(), errorStatus.getSeverity(),
errorStatus.getMessage(), null );
multiStatus.add( errorStatus );
Set<String> installedModules = downloadModule.getInstalledModules();
if (!installedModules.isEmpty()) {
multiStatus.add(Messages.createOkStatus("UpdateStudioWizard.some.jars.sucessfully.installed", //$NON-NLS-1$
Arrays.toString(jarsFailedToDownload.toArray(new String[jarsFailedToDownload.size()]))));
multiStatus.add( Messages.createOkStatus( "UpdateStudioWizard.some.jars.sucessfully.installed", //$NON-NLS-1$
Arrays.toString( jarsFailedToDownload.toArray( new String[jarsFailedToDownload.size()] ) ) ) );
}
return multiStatus;
}
@@ -121,24 +122,24 @@ public class TalendWebServiceUpdateExtraFeature implements ExtraFeature {
protected static boolean acceptLicence(final ModuleToInstall module) {
Display defaultDisplay = Display.getDefault();
if (defaultDisplay != null) {
final AtomicBoolean accepted = new AtomicBoolean(false);// just use atomic to have a final object.
Display.getDefault().syncExec(new Runnable() {
final AtomicBoolean accepted = new AtomicBoolean( false );// just use atomic to have a final object.
Display.getDefault().syncExec( new Runnable() {
@Override
public void run() {
String license = RemoteModulesHelper.getInstance().getLicenseUrl(module.getLicenseType());
ModuleLicenseDialog licenseDialog = new ModuleLicenseDialog(Display.getDefault().getActiveShell(), module
.getLicenseType(), license, module.getName());
String license = RemoteModulesHelper.getInstance().getLicenseUrl( module.getLicenseType() );
ModuleLicenseDialog licenseDialog = new ModuleLicenseDialog( Display.getDefault().getActiveShell(), module
.getLicenseType(), license, module.getName() );
if (licenseDialog.open() != Window.OK) {
accepted.set(false);
accepted.set( false );
} else {
accepted.set(true);
accepted.set( true );
}
}
});
} );
return accepted.get();
} else {// should ask the user to agree on license.
throw new RuntimeException("Unable to get the default Display to show the license agreement, should never appear."); //$NON-NLS-1$
throw new RuntimeException( "Unable to get the default Display to show the license agreement, should never appear." ); //$NON-NLS-1$
}
}
@@ -159,7 +160,7 @@ public class TalendWebServiceUpdateExtraFeature implements ExtraFeature {
*/
@Override
public String getName() {
return name;
return name + " (" + modulesToBeInstalled.size() + ")";
}
/*
@@ -216,7 +217,7 @@ public class TalendWebServiceUpdateExtraFeature implements ExtraFeature {
if (other.name != null) {
return false;
}
} else if (!this.name.equals(other.name)) {
} else if (!this.name.equals( other.name )) {
return false;
}
return true;
@@ -229,7 +230,7 @@ public class TalendWebServiceUpdateExtraFeature implements ExtraFeature {
*/
@Override
public EnumSet<UpdateSiteLocationType> getUpdateSiteCompatibleTypes() {
return EnumSet.of(UpdateSiteLocationType.DEFAULT_REPO);
return EnumSet.of( UpdateSiteLocationType.DEFAULT_REPO );
}
/*