TUP-2219 : refactored the "install aditional package" runtime : removed
ExtraFeatureFactory unnecessary APIs.
This commit is contained in:
@@ -19,7 +19,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.updates.runtime.engine.factory.AbstractExtraUpdatesFactory;
|
||||
import org.talend.updates.runtime.model.ExtraFeature;
|
||||
import org.talend.updates.runtime.model.StatusException;
|
||||
|
||||
/**
|
||||
* created by ggu on Jul 17, 2014 Detailled comment
|
||||
@@ -55,30 +54,4 @@ public class ExtraFeaturesUpdatesFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeInstall() throws StatusException {
|
||||
AbstractExtraUpdatesFactory[] updatesFactories = updatesFactoryReader.getUpdatesFactories();
|
||||
if (updatesFactories != null) {
|
||||
for (AbstractExtraUpdatesFactory factory : updatesFactories) {
|
||||
factory.beforeInstall();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void afterInstall() throws StatusException {
|
||||
AbstractExtraUpdatesFactory[] updatesFactories = updatesFactoryReader.getUpdatesFactories();
|
||||
if (updatesFactories != null) {
|
||||
for (AbstractExtraUpdatesFactory factory : updatesFactories) {
|
||||
factory.afterInstall();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void afterCompleteInstall() throws Exception {
|
||||
AbstractExtraUpdatesFactory[] updatesFactories = updatesFactoryReader.getUpdatesFactories();
|
||||
if (updatesFactories != null) {
|
||||
for (AbstractExtraUpdatesFactory factory : updatesFactories) {
|
||||
factory.afterCompleteInstall();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.talend.updates.runtime.i18n.Messages;
|
||||
import org.talend.updates.runtime.model.ExtraFeature;
|
||||
import org.talend.updates.runtime.model.FeatureRepositories;
|
||||
import org.talend.updates.runtime.model.StatusException;
|
||||
|
||||
/**
|
||||
* created by sgandon on 28 févr. 2013 Detailled comment
|
||||
@@ -52,41 +51,24 @@ public class InstallNewFeatureJob extends Job {
|
||||
*/
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor progress) {
|
||||
SubMonitor subMon = SubMonitor.convert(progress,
|
||||
Messages.getString("InstallNewFeatureJob.installing.talend.new.features"), featuresToInstall.size()); //$NON-NLS-1$
|
||||
SubMonitor subMon = SubMonitor.convert(progress, featuresToInstall.size());
|
||||
subMon.setTaskName(Messages.getString("InstallNewFeatureJob.installing.talend.new.features")); //$NON-NLS-1$
|
||||
MultiStatus multiStatus = new MultiStatus(Messages.getPlugiId(), IStatus.OK, null, null);
|
||||
try {
|
||||
ExtraFeaturesUpdatesFactory updatesFactory = new ExtraFeaturesUpdatesFactory();
|
||||
updatesFactory.beforeInstall();
|
||||
// back the config.ini cause the p2 update will modify it but we do not want that
|
||||
for (ExtraFeature newFeature : featuresToInstall) {
|
||||
try {
|
||||
// back the config.ini cause the p2 update will modify it but we do not want that
|
||||
for (ExtraFeature newFeature : featuresToInstall) {
|
||||
try {
|
||||
// launch the update
|
||||
multiStatus.merge(newFeature.install(subMon.newChild(1), featureRepositories.getAllRepoUris(newFeature)));
|
||||
if (subMon.isCanceled()) {// user canceled so stop the loop and return
|
||||
multiStatus.add(Messages.createCancelStatus(
|
||||
"InstallNewFeatureJob.user.cancel.installation.of.feature", //$NON-NLS-1$
|
||||
newFeature.getName()));
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
multiStatus.add(Messages.createErrorStatus(e,
|
||||
"InstallNewFeatureJob.failed.to.install", newFeature.getName())); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
updatesFactory.afterInstall();
|
||||
} catch (StatusException e) {
|
||||
multiStatus.add(e.getStatus());
|
||||
// launch the update
|
||||
multiStatus.merge(newFeature.install(subMon.newChild(1), featureRepositories.getAllRepoUris(newFeature)));
|
||||
if (subMon.isCanceled()) {// user canceled so stop the loop and return
|
||||
multiStatus.add(Messages.createCancelStatus("InstallNewFeatureJob.user.cancel.installation.of.feature", //$NON-NLS-1$
|
||||
newFeature.getName()));
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
multiStatus.add(Messages.createErrorStatus(e, "InstallNewFeatureJob.failed.to.install", newFeature.getName())); //$NON-NLS-1$
|
||||
}
|
||||
} catch (StatusException e) {
|
||||
multiStatus.add(e.getStatus());
|
||||
|
||||
}
|
||||
return multiStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import java.util.Set;
|
||||
import org.eclipse.core.databinding.observable.IObservable;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.updates.runtime.model.ExtraFeature;
|
||||
import org.talend.updates.runtime.model.StatusException;
|
||||
|
||||
/**
|
||||
* created by ggu on Jul 17, 2014 Detailled comment
|
||||
@@ -50,27 +49,4 @@ public abstract class AbstractExtraUpdatesFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* before install, will call this.
|
||||
*/
|
||||
public void beforeInstall() throws StatusException {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* after install, will call this.
|
||||
*/
|
||||
public void afterInstall() throws StatusException {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called once all the different features of different types have all been installed. This is only called if
|
||||
* there is at least one feature successfully installed, even if this current feature failed to be installed.
|
||||
*/
|
||||
public void afterCompleteInstall() throws Exception {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.MultiStatus;
|
||||
@@ -139,13 +138,7 @@ public class TalendWebServiceUpdateExtraFeature implements ExtraFeature {
|
||||
});
|
||||
return accepted.get();
|
||||
} else {// should ask the user to agree on license.
|
||||
throw new NotImplementedException("User should be able to accept licences when downloading missing jars");
|
||||
// new DownloadModuleRunnable(modulesToBeInstalled) {
|
||||
//
|
||||
// @Override
|
||||
// protected boolean acceptLicence(ModuleToInstall module) {
|
||||
// }
|
||||
// };
|
||||
throw new RuntimeException("Unable to get the default Display to show the license agreement, should never appear."); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ public class SelectExtraFeaturesToInstallWizardPage extends WizardPage {
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
Composite container = new Composite(parent, SWT.NULL);
|
||||
@@ -198,7 +199,6 @@ public class SelectExtraFeaturesToInstallWizardPage extends WizardPage {
|
||||
/**
|
||||
* DOC sgandon Comment method "updateEnabledStatus".
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void updatePageStatus() {
|
||||
// tell the user when no feature is to be installed.
|
||||
if (updateWizardModel.availableExtraFeatures.isEmpty()) {
|
||||
|
||||
@@ -112,12 +112,6 @@ public class UpdateStudioWizard extends Wizard {
|
||||
// display message in case of any success
|
||||
String firstPartOfMessage = Messages.getString("UpdateStudioWizard.all.feautures.installed.successfully"); //$NON-NLS-1$
|
||||
if (hasAnySuccess) {
|
||||
ExtraFeaturesUpdatesFactory updatesFactory = new ExtraFeaturesUpdatesFactory();
|
||||
try {
|
||||
updatesFactory.afterCompleteInstall();
|
||||
} catch (Exception e) {
|
||||
hasAnyFailure = true;
|
||||
}
|
||||
if (hasAnyFailure) {
|
||||
firstPartOfMessage = Messages.getString("UpdateStudioWizard.some.feautures.installed.sucessfully"); //$NON-NLS-1$
|
||||
}// else only success to keep initial message
|
||||
|
||||
@@ -47,6 +47,7 @@ public class UpdateWizardModel {
|
||||
return ValidationStatus.error(Messages
|
||||
.getString("SelectExtraFeaturesToInstallWizardPage.one.feature.must.be.selected")); //$NON-NLS-1$
|
||||
} else if (!selectedExtraFeatures.isEmpty() && !canConfigureUpdateSiteLocation()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ExtraFeature extraFeature = getFirstExtraFeatureNotAllowingUpdateSiteConfig(selectedExtraFeatures);
|
||||
return ValidationStatus.warning(Messages.getString("no.dowload.location.to.configure", extraFeature.getName())); //$NON-NLS-1$
|
||||
}
|
||||
@@ -153,6 +154,7 @@ public class UpdateWizardModel {
|
||||
* @return true is all of the selected feature can have a customisable remote update site, and false otherwise
|
||||
*/
|
||||
public boolean canConfigureUpdateSiteLocation() {
|
||||
@SuppressWarnings("unchecked")
|
||||
ExtraFeature firstExtraFeatureNotAllowingUpdateSiteConfig = getFirstExtraFeatureNotAllowingUpdateSiteConfig(selectedExtraFeatures);
|
||||
return firstExtraFeatureNotAllowingUpdateSiteConfig == null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user