All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.izforge.izpack.installer.util.SummaryProcessor Maven / Gradle / Ivy

The newest version!
/*
 * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
 *
 * http://izpack.org/
 * http://izpack.codehaus.org/
 *
 * Copyright 2005 Klaus Bartz
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.izforge.izpack.installer.util;

import com.izforge.izpack.api.installer.ISummarisable;
import com.izforge.izpack.installer.data.GUIInstallData;

/**
 * A helper class which creates a summary from all panels. This class calls all declared panels for
 * a summary To differ between caption and message, HTML is used to draw caption in bold and indent
 * messaged a little bit.
 *
 * @author Klaus Bartz
 */
public class SummaryProcessor
{

    private static String HTML_HEADER;

    private static String HTML_FOOTER = "\n\n";

    private static String BODY_START = "
"; private static String BODY_END = "
"; private static String HEAD_START = "

"; private static String HEAD_END = "

\n"; static { // Initialize HTML header and footer. StringBuilder buffer = new StringBuilder(256); buffer.append("\n").append( "\n" + "" + "\n\n\n\n"); HTML_HEADER = buffer.toString(); } /** * Returns a HTML formated string which contains the summary of all panels. To get the summary, * the methods * {@link com.izforge.izpack.api.installer.ISummarisable#getSummaryCaption} and {@link com.izforge.izpack.api.installer.ISummarisable#getSummaryBody()} of all * panels are called. * * @param idata AutomatedInstallData which contains the panel references * @return a HTML formated string with the summary of all panels */ public static String getSummary(GUIInstallData idata) { StringBuilder buffer = new StringBuilder(2048); buffer.append(HTML_HEADER); for (ISummarisable panel : idata.getPanels()) { if (panel.isVisited()) { String caption = panel.getSummaryCaption(); String msg = panel.getSummaryBody(); // If no caption or/and message, ignore it. if (caption == null || msg == null) { continue; } buffer.append(HEAD_START).append(caption).append(HEAD_END); buffer.append(BODY_START).append(msg).append(BODY_END); } } buffer.append(HTML_FOOTER); return (buffer.toString()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy