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 * Constructs a new SaleProcessAdmin.
021 *
022 */
023 public SaleProcessAdmin() {
024 super("SaleProcessAdmin");
025 }
026
027 /**
028 * Implementation of the inherited abstract method. At this <code>Gate</code> the user will see the content of
029 * the global logfile.
030 *
031 * @return the <code>Gate</code> this process will first switch to.
032 *
033 * @see sale.SaleProcess#getInitialGate()
034 */
035 protected Gate getInitialGate() {
036
037 // generate the initial gate
038 UIGate uig_logfile = new UIGate(null, null);
039
040 try
041 {
042 FileInputStream fis = new FileInputStream(VideoShop.FILENAME);
043 LogInputStream lis = new LogInputStream(fis, new LogEntryFilterImpl());
044 LogTableForm ltf_log = new LogTableForm("Logged information", lis);
045 ltf_log.addContentCreator(new AdminLTFContentCreator());
046 uig_logfile.setFormSheet(ltf_log);
047 }
048 catch(FileNotFoundException e)
049 {
050 getStopGate();
051 e.printStackTrace();
052 }
053 catch(IOException e)
054 {
055 MsgForm msf_ioexc = new MsgForm(
056 "Empty-LogFile!",
057 "The log file was found empty.\nNothing to administrate here.");
058 msf_ioexc.addContentCreator(new AdminMFContentCreator());
059 uig_logfile.setFormSheet(msf_ioexc);
060 }
061 return uig_logfile;
062 }
063 }