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 java.io.File;
025
026import com.izforge.izpack.Pack;
027import com.izforge.izpack.PackFile;
028import com.izforge.izpack.installer.AutomatedInstallData;
029import com.izforge.izpack.util.AbstractUIProgressHandler;
030
031/**
032 * <p>
033 * Implementations of this class are used to handle customizing installation. The defined methods
034 * are called from the unpacker at different, well defined points of installation.
035 * </p>
036 * 
037 * @author Klaus Bartz
038 * 
039 */
040public interface InstallerListener
041{
042
043    // ------------------------------------------------------------------------
044    // Constant Definitions
045    // ------------------------------------------------------------------------
046    public static final int BEFORE_FILE = 1;
047
048    public static final int AFTER_FILE = 2;
049
050    public static final int BEFORE_DIR = 3;
051
052    public static final int AFTER_DIR = 4;
053
054    public static final int BEFORE_PACK = 5;
055
056    public static final int AFTER_PACK = 6;
057
058    public static final int BEFORE_PACKS = 7;
059
060    public static final int AFTER_PACKS = 8;
061
062    /**
063     * This method will be called from the unpacker before the installation of all packs will be
064     * performed.
065     * 
066     * @param idata object containing the current installation data
067     * @param npacks number of packs which are defined for this installation
068     * @param handler a handler to the current used UIProgressHandler
069     * @throws Exception
070     */
071    void beforePacks(AutomatedInstallData idata, Integer npacks, AbstractUIProgressHandler handler)
072            throws Exception;
073
074    /**
075     * This method will be called from the unpacker before the installation of one pack will be
076     * performed.
077     * 
078     * @param pack current pack object
079     * @param i current pack number
080     * @param handler a handler to the current used UIProgressHandler
081     * @throws Exception
082     */
083    void beforePack(Pack pack, Integer i, AbstractUIProgressHandler handler) throws Exception;
084
085    /**
086     * Returns true if this listener would be informed at every file and directory installation,
087     * else false. If it is true, the listener will be called two times (before and after) for every
088     * action. Handle carefully, else performance problems are possible.
089     * 
090     * @return true if this listener would be informed at every file and directory installation,
091     * else false
092     */
093    boolean isFileListener();
094
095    /**
096     * This method will be called from the unpacker before one directory should be created. If
097     * parent directories should be created also, this method will be called for every directory
098     * beginning with the base.
099     * 
100     * @param dir current File object of the just directory which should be created
101     * @param pf corresponding PackFile object
102     * @throws Exception
103     */
104    void beforeDir(File dir, PackFile pf) throws Exception;
105
106    /**
107     * This method will be called from the unpacker after one directory was created. If parent
108     * directories should be created, this method will be called for every directory beginning with
109     * the base.
110     * 
111     * @param dir current File object of the just created directory
112     * @param pf corresponding PackFile object
113     * @throws Exception
114     */
115    void afterDir(File dir, PackFile pf) throws Exception;
116
117    /**
118     * This method will be called from the unpacker before one file should be installed.
119     * 
120     * @param file current File object of the file which should be installed
121     * @param pf corresponding PackFile object
122     * @throws Exception
123     */
124    void beforeFile(File file, PackFile pf) throws Exception;
125
126    /**
127     * This method will be called from the unpacker after one file was installed.
128     * 
129     * @param file current File object of the just installed file
130     * @param pf corresponding PackFile object
131     * @throws Exception
132     */
133    void afterFile(File file, PackFile pf) throws Exception;
134
135    /**
136     * 
137     * This method will be called from the unpacker after the installation of one pack was
138     * performed.
139     * 
140     * @param pack current pack object
141     * @param i current pack number
142     * @param handler a handler to the current used UIProgressHandler
143     */
144    void afterPack(Pack pack, Integer i, AbstractUIProgressHandler handler) throws Exception;
145
146    /**
147     * This method will be called from the unpacker after the installation of all packs was
148     * performed.
149     * 
150     * @param idata object containing the current installation data
151     * @param handler a handler to the current used UIProgressHandler
152     * @throws Exception
153     */
154    void afterPacks(AutomatedInstallData idata, AbstractUIProgressHandler handler) throws Exception;
155}