001 import data.*;
002 import sale.*;
003
004 import javax.swing.*;
005
006 /**
007 * FormSheetContentCreator, der den Inhalt der Standard-FormSheets von
008 * Office erzeugt
009 */
010 public class DefaultOfficeFormCreator extends FormSheetContentCreator
011 {
012
013 //// attributes ////////////////////////////////////////////////////////////
014
015 private Office officeOwner;
016
017
018 //// constructor ///////////////////////////////////////////////////////////
019
020 /**
021 * Konstruktor. Erzeugt ein neues Objekt vom Typ
022 * <CODE>DefaultOfficeFormCreator</CODE>.
023 */
024 public DefaultOfficeFormCreator(Office officeOwner)
025 {
026 super();
027 this.officeOwner = officeOwner;
028 }
029
030
031 //// public methods ///////////////////////////////////////////////////////
032
033 /**
034 * Erzeugt den Inhalt des übergebenen FormSheets.
035 */
036 public void createFormSheetContent (FormSheet fsToCreate)
037 {
038 // JPanel erzeugen und vertikales BoxLayout setzen
039 JPanel jpFSComponent = new JPanel();
040
041 jpFSComponent.setLayout (new BoxLayout (jpFSComponent, BoxLayout.Y_AXIS));
042
043 // Label mit der aktuellen Zeit ins JPanel einfuegen
044 jpFSComponent.add(new JLabel("Turn : " +
045 Shop.getTheShop().getTimer().getTime()));
046
047 // Geldbestand holen
048 Stock coinSlot = Shop.getTheShop().getStock("coin slot");
049
050 // verwendete Waehrung holen
051 Currency currency = (Currency)Shop.getTheShop().getCatalog("DM");
052
053 // Geldbestand aufsummieren und Label mit der Summe ins JPanel einfuegen
054 IntegerValue money = (IntegerValue)coinSlot.sumStock(null,
055 new CatalogItemValue(), new IntegerValue (0));
056
057 jpFSComponent.add (new JLabel("Money : " + currency.toString(money)));
058
059 // Komponente ins FormSheet einfuegen
060 fsToCreate.setComponent (jpFSComponent);
061
062 // Alle vorhandenen Buttons entfernen
063 fsToCreate.removeAllButtons();
064
065 // Button zum Schliessen eibauen
066 fsToCreate.addButton ("Close", 1, new sale.Action() {
067 public void doAction (SaleProcess p, SalesPoint sp) {
068 officeOwner.quit();
069 }
070 });
071 }
072
073 }