001/*
002 * IzPack - Copyright 2001-2005 Julien Ponge, All Rights Reserved.
003 * 
004 * http://www.izforge.com/izpack/
005 * http://developer.berlios.de/projects/izpack/
006 * 
007 * Copyright 2004 Klaus Bartz
008 * 
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *     http://www.apache.org/licenses/LICENSE-2.0
014 *     
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 */
021
022package com.izforge.izpack.event;
023
024import com.izforge.izpack.installer.AutomatedInstallData;
025import com.izforge.izpack.util.AbstractUIProgressHandler;
026import com.izforge.izpack.util.Debug;
027import com.izforge.izpack.util.ExtendedUIProgressHandler;
028
029/**
030 * Installer listener for reset the progress bar and initialize the simple installer listener to
031 * support progress bar interaction. To support progress bar interaction add this installer listener
032 * as first listener.
033 * 
034 * @author Klaus Bartz
035 * 
036 */
037public class ProgressBarInstallerListener extends SimpleInstallerListener
038{
039
040    /**
041     * 
042     */
043    public ProgressBarInstallerListener()
044    {
045        super(false);
046        // TODO Auto-generated constructor stub
047    }
048
049    /*
050     * (non-Javadoc)
051     * 
052     * @see com.izforge.izpack.compiler.InstallerListener#afterPacks(com.izforge.izpack.installer.AutomatedInstallData,
053     * com.izforge.izpack.util.AbstractUIProgressHandler)
054     */
055    public void afterPacks(AutomatedInstallData idata, AbstractUIProgressHandler handler)
056            throws Exception
057    {
058        if (handler instanceof ExtendedUIProgressHandler && getProgressBarCallerCount() > 0)
059        {
060            String progress = getMsg("CustomActions.progress");
061            String tip = getMsg("CustomActions.tip");
062            if (tip.equals("CustomActions.tip") || progress.equals("CustomActions.progress"))
063            {
064                Debug
065                        .trace("No messages found for custom action progress bar interactions; skiped.");
066                return;
067            }
068            ((ExtendedUIProgressHandler) handler).restartAction("Configure", progress, tip,
069                    getProgressBarCallerCount());
070            SimpleInstallerListener.doInformProgressBar = true;
071        }
072    }
073
074}