blob: d958ec68acee5a7e6f3e7194f6fb8ae60273df01 [file] [log] [blame]
/**
*
*/
package org.eclipse.epp.installer.internal.console.steps;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.epp.installer.core.InstallType;
import org.eclipse.epp.installer.core.model.IInstallStep;
import org.eclipse.epp.installer.core.steps.SelectInstallTypeStep;
import org.eclipse.epp.installer.internal.console.Console;
import org.eclipse.epp.installer.internal.console.ConsoleStep;
/**
* @author kap
*
*/
public class SelectInstallTypeConsoleStep extends ConsoleStep{
public SelectInstallTypeConsoleStep(IInstallStep step) {
super(step);
}
public IStatus prompt(Console console) throws Exception {
SelectInstallTypeStep step = (SelectInstallTypeStep) getInstallStep();
step.aboutToStep();
Object[] types = step.getInstallTypes().toArray();
if(step.getTitle()!=null) console.writeln(step.getTitle());
if(step.getDescription()!=null)console.writeln(step.getDescription());
String[] responses = new String[types.length];
for(int i=0;i<types.length;i++)
{
console.writeln(String.valueOf(i+1)+" - "+((InstallType)types[i]).getName());
responses[i]=String.valueOf(i+1);
}
int typeId = Integer.parseInt(console.prompt("posible answers ",responses));
IStatus status = SelectInstallTypeStep.validateProductString(((InstallType)types[typeId]).getName());
step.updateOption(((InstallType)types[typeId]));
return status;
}
}