| package org.eclipse.epp.installer.core.steps; |
| |
| import java.util.ArrayList; |
| import java.util.List; |
| |
| import org.eclipse.core.runtime.Status; |
| import org.eclipse.epp.installer.core.model.InstallStep; |
| import org.eclipse.epp.installer.core.model.Installer; |
| |
| |
| /** |
| * Shows warning list if there were any during installation process. |
| */ |
| public class ShowWarningsStep extends InstallStep { |
| |
| /** |
| * Constructor for ShowWarningsStep. |
| * |
| * @param installer |
| * Installer |
| */ |
| public ShowWarningsStep(Installer installer) { |
| super(installer); |
| } |
| |
| /** |
| * Generate and return warning log text. |
| * |
| * @return String |
| */ |
| public String getWarningText() { |
| List log = new ArrayList(getInstaller().getWarnings()); |
| StringBuffer text = new StringBuffer(""); |
| for (int i = 0; i < log.size(); i++) { |
| Status status = (Status) log.get(i); |
| String message = status.getMessage(); |
| if (message != null && !message.equals("")) { |
| text.append(message); |
| text.append("\n"); |
| } |
| } |
| return text.toString(); |
| } |
| |
| /** |
| * Return execution condition. Step need to be executed if installer warning |
| * log is not empty. |
| * |
| * Used by installer to ensure step execution. |
| * |
| * @return <code>true</code> if step needed to be executed, and |
| * <code>false</code>othervise. |
| */ |
| public boolean canExecute() { |
| List log = new ArrayList(getInstaller().getWarnings()); |
| if (log == null || log.size() == 0) { |
| return false; |
| } |
| return true; |
| } |
| } |