001 package videoautomat; 002 import java.io.FileInputStream; 003 import java.io.FileNotFoundException; 004 import java.io.IOException; 005 006 import log.LogInputStream; 007 import log.stdforms.LogTableForm; 008 import sale.Gate; 009 import sale.SaleProcess; 010 import sale.UIGate; 011 import sale.stdforms.MsgForm; 012 import videoautomat.contentcreator.AdminLTFContentCreator; 013 import videoautomat.contentcreator.AdminMFContentCreator; 014 /** 015 * This class implements a <code>SaleProcess</code> for the administrative work. 016 * 017 */ 018 public class SaleProcessAdmin extends SaleProcess { 019 /** 020 * ID for Serialization. 021 */ 022 private static final long serialVersionUID = 6011358722747463461L; 023 024 /** 025 * Constructs a new SaleProcessAdmin. 026 * 027 */ 028 public SaleProcessAdmin() { 029 super("SaleProcessAdmin"); 030 } 031 032 /** 033 * Implementation of the inherited abstract method. At this <code>Gate</code> the user will see the content of 034 * the global logfile. 035 * 036 * @return the <code>Gate</code> this process will first switch to. 037 * 038 * @see sale.SaleProcess#getInitialGate() 039 */ 040 protected Gate getInitialGate() { 041 042 // generate the initial gate 043 UIGate uig_logfile = new UIGate(null, null); 044 045 try 046 { 047 FileInputStream fis = new FileInputStream(VideoShop.FILENAME); 048 LogInputStream lis = new LogInputStream(fis, new LogEntryFilterImpl()); 049 LogTableForm ltf_log = new LogTableForm("Logged information", lis); 050 ltf_log.addContentCreator(new AdminLTFContentCreator()); 051 uig_logfile.setFormSheet(ltf_log); 052 } 053 catch(FileNotFoundException e) 054 { 055 getStopGate(); 056 e.printStackTrace(); 057 } 058 catch(IOException e) 059 { 060 MsgForm msf_ioexc = new MsgForm( 061 "Empty-LogFile!", 062 "The log file was found empty.\nNothing to administrate here."); 063 msf_ioexc.addContentCreator(new AdminMFContentCreator()); 064 uig_logfile.setFormSheet(msf_ioexc); 065 } 066 return uig_logfile; 067 } 068 }