blob: 43c686c4557d122897b4ae8b3d22ef23880e7220 [file] [log] [blame]
package org.eclipse.epp.installer.core.steps;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.epp.installer.core.InstallType;
import org.eclipse.epp.installer.core.Variables;
import org.eclipse.epp.installer.core.model.Context;
import org.eclipse.epp.installer.core.model.InstallStep;
import org.eclipse.epp.installer.core.model.Installer;
/**
* <p>
* Copyright (c) 2006, Instantiations, Inc.<br>
* All Rights Reserved
*/
public class SelectInstallTypeStep extends InstallStep {
private List types;
private String optionName;
public SelectInstallTypeStep(Installer installer) {
super(installer);
types = new ArrayList();
}
public void addInstallTypes(Collection types) {
types.addAll(types);
}
public void addInstallType(InstallType type) {
types.add(type);
}
public Collection getInstallTypes() {
return types;
}
public String getOptionName() {
return Variables.resolve(optionName, getOptions());
}
public void setOptionName(String optionName) {
this.optionName = optionName;
}
public void updateOption(InstallType entity) {
if (entity != null) {
getOptions().set(getOptionName(), entity.getName());
}
}
public void aboutToStep() {
super.aboutToStep();
// init selected install type
if (types != null && types.size() > 0) {
updateOption( (InstallType) types.get(0) );
}
}
public IStatus verifyStep() {
return validateProductString(getOptions().getString(
getOptionName()));
}
public static IStatus validateProductString(String productString) {
if (productString == null || productString.length() == 0)
return new Status(IStatus.ERROR, Context.PLUGIN_ID, 0,
"Empty IntallType string", null);
return Status.OK_STATUS;
}
}