1 21 22 package com.izforge.izpack.event; 23 24 import java.io.File ; 25 import java.util.ArrayList ; 26 27 import com.izforge.izpack.LocaleDatabase; 28 import com.izforge.izpack.Pack; 29 import com.izforge.izpack.PackFile; 30 import com.izforge.izpack.installer.AutomatedInstallData; 31 import com.izforge.izpack.installer.ResourceManager; 32 import com.izforge.izpack.util.AbstractUIProgressHandler; 33 import com.izforge.izpack.util.SpecHelper; 34 35 47 public class SimpleInstallerListener implements InstallerListener 48 { 49 50 private static ArrayList progressBarCaller = new ArrayList (); 51 52 53 protected static final String LANG_FILE_NAME = "CustomActionsLang.xml"; 54 55 56 protected static LocaleDatabase langpack = null; 57 58 protected static boolean doInformProgressBar = false; 59 60 private AutomatedInstallData installdata = null; 61 62 private SpecHelper specHelper = null; 63 64 67 public SimpleInstallerListener() 68 { 69 this(false); 70 } 71 72 79 public SimpleInstallerListener(boolean useSpecHelper) 80 { 81 super(); 82 if (useSpecHelper) setSpecHelper(new SpecHelper()); 83 } 84 85 91 public void afterFile(File file, PackFile pf) throws Exception 92 { 93 } 95 96 102 public void afterDir(File dir, PackFile pf) throws Exception 103 { 104 } 106 107 113 public void afterPacks(AutomatedInstallData idata, AbstractUIProgressHandler handler) 114 throws Exception 115 { 116 117 } 119 120 126 public void afterPack(Pack pack, Integer i, AbstractUIProgressHandler handler) throws Exception 127 { 128 130 } 131 132 138 public void beforePacks(AutomatedInstallData idata, Integer npacks, 139 AbstractUIProgressHandler handler) throws Exception 140 { 141 if (installdata == null) installdata = idata; 142 if (installdata != null && SimpleInstallerListener.langpack == null) 143 { 144 try 146 { 147 String resource = LANG_FILE_NAME + "_" + installdata.localeISO3; 148 SimpleInstallerListener.langpack = new LocaleDatabase(ResourceManager.getInstance() 149 .getInputStream(resource)); 150 } 151 catch (Throwable exception) 152 {} 153 154 } 155 } 156 157 163 public void beforePack(Pack pack, Integer i, AbstractUIProgressHandler handler) 164 throws Exception 165 { 166 } 168 169 174 public boolean isFileListener() 175 { 176 return false; 178 } 179 180 186 public void beforeFile(File file, PackFile pf) throws Exception 187 { 188 } 190 191 197 public void beforeDir(File dir, PackFile pf) throws Exception 198 { 199 } 201 202 207 public SpecHelper getSpecHelper() 208 { 209 return specHelper; 210 } 211 212 217 public void setSpecHelper(SpecHelper helper) 218 { 219 specHelper = helper; 220 } 221 222 227 public AutomatedInstallData getInstalldata() 228 { 229 return installdata; 230 } 231 232 237 public void setInstalldata(AutomatedInstallData data) 238 { 239 installdata = data; 240 } 241 242 247 public static int getProgressBarCallerCount() 248 { 249 return (progressBarCaller.size()); 250 } 251 252 257 protected int getProgressBarCallerId() 258 { 259 for (int i = 0; i < progressBarCaller.size(); ++i) 260 { 261 if (progressBarCaller.get(i) == this) return (i + 1); 262 } 263 return (0); 264 } 265 266 269 protected void setProgressBarCaller() 270 { 271 progressBarCaller.add(this); 272 273 } 274 275 280 protected boolean informProgressBar() 281 { 282 return (doInformProgressBar); 283 } 284 285 292 protected String getMsg(String id) 293 { 294 String retval = id; 295 if (SimpleInstallerListener.langpack != null) 296 { 297 retval = SimpleInstallerListener.langpack.getString(id); 298 } 299 if (retval.equals(id) && getInstalldata() != null) 300 { 301 retval = getInstalldata().langpack.getString(id); 302 } 303 return (retval); 304 } 305 } 306 | Popular Tags |