Commits

synthomat  committed 6ed25cd

Files umorganisiert, ViewLogin gebaut und eingebunden. CellEditor im ViewCustomer gefixt

  • Participants
  • Parent commits 0274ead

Comments (0)

Files changed (24)

 syntax: glob
 *.class
+bin

File products.ser

Binary file modified.

File src/controller/ControllerCustomer.java

 package controller;
 
 import fpt.com.Product;
-import hs.Order;
+import model.Order;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.io.BufferedReader;
 import java.io.IOException;
 import java.net.DatagramPacket;
 import java.net.DatagramSocket;
 import java.net.InetAddress;
 import java.net.SocketException;
 import java.net.UnknownHostException;
-import java.util.Iterator;
 
 import view.ViewCustomer;
+import view.ViewLogin;
 import model.ModelShop;
 
 public class ControllerCustomer implements ActionListener {
 		this.model = model;
 		this.view = view;
 
+		ViewLogin loginView = new ViewLogin(view);
+		ControllerLogin cl = new ControllerLogin(loginView);
+		
 		view.addActionListner(this);
 
 		new Thread(new TimeThread()).start();
 
 	public void order() {
 		Order order = new Order();
-		
-		for(int i=0; i<view.model.getProducts().size(); i++) {
+
+		for (int i = 0; i < view.model.getProducts().size(); i++) {
 			Product prod = view.model.getProducts().get(i);
 			prod.setQuantity((Integer) view.mod.getValueAt(i, 3));
-			
-			order.add(prod);		
-		}
-		System.out.println(order.getSum());
-		/*
-		while( iter.hasNext()) {
-			Product prod = (Product)iter.next();
-			
+			System.out.println(prod);
 			order.add(prod);
 		}
-		*/
 		
+		System.out.println("Gesammtpreis für Bestellung: " + order.getSum() + "€");
 	}
 
 	class TimeThread implements Runnable {
 		DatagramPacket packet;
 
 		TimeThread() {
-			
-			
+
 			try {
 				clientSocket = new DatagramSocket();
 				IPAddress = InetAddress.getByName("localhost");
 					buffer = "time".getBytes();
 					DatagramPacket dp = new DatagramPacket(buffer, buffer.length, IPAddress, 6667);
 					clientSocket.send(dp);
-					
+
 					// Uhrzeit empfangen und anzeigen
 					clientSocket.receive(packet);
 					view.setTimeLabel(new String(packet.getData()));

File src/controller/ControllerLogin.java

+package controller;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import view.ViewLogin;
+
+public class ControllerLogin implements ActionListener {
+	private ViewLogin view;
+
+	public ControllerLogin(ViewLogin view) {
+		this.view = view;
+	}
+	
+	@Override
+	public void actionPerformed(ActionEvent e) {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

File src/controller/ControllerShop.java

 package controller;
 
 import fpt.com.SerializableStrategy;
-import hs.Product;
-import hs.ProductList;
+import model.Product;
+import model.ProductList;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 		this.view = view;
 
 		view.addActionListner(this);
-		
-		
+
 		ActionListener openListener = new ActionListener() {
-			  public void actionPerformed(ActionEvent e) {
-				  deserializeData(e);
-			  }
+			public void actionPerformed(ActionEvent e) {
+				deserializeData(e);
+			}
 		};
-		
+
 		view.mi_open_binary.addActionListener(openListener);
 		view.mi_open_beans.addActionListener(openListener);
 		view.mi_open_xstream.addActionListener(openListener);
 		view.mi_readJDBC.addActionListener(openListener);
 		view.mi_readJPA.addActionListener(openListener);
-		
+
 		ActionListener saveListener = new ActionListener() {
-			  public void actionPerformed(ActionEvent e) {
-				  serializeData(e);
-			  }
+			public void actionPerformed(ActionEvent e) {
+				serializeData(e);
+			}
 		};
-		
+
 		view.mi_save_binary.addActionListener(saveListener);
 		view.mi_save_beans.addActionListener(saveListener);
 		view.mi_save_xstream.addActionListener(saveListener);
 
 	public void deserializeData(ActionEvent e) {
 		SerializableStrategy strategy = null;
-		
+
 		if (e.getSource() == view.mi_open_binary)
 			strategy = new BinaryStrategy();
 		else if (e.getSource() == view.mi_open_beans)
 			return;
 
 		try {
-			ProductList pl = (ProductList)strategy.readObject();
-			//pl.setProductIdCounter(pl.get(pl.size()-1).getId());
-			//System.out.println("Höchste ID: " + pl.getProductIdCounter());
+			ProductList pl = (ProductList) strategy.readObject();
+			// pl.setProductIdCounter(pl.get(pl.size()-1).getId());
+			// System.out.println("Höchste ID: " + pl.getProductIdCounter());
 			model.setProducts(pl);
 		} catch (IOException e1) {
 			// TODO Auto-generated catch block
 			e1.printStackTrace();
 		}
 	}
-	
+
 	public void serializeData(ActionEvent e) {
 		SerializableStrategy strategy = null;
-		
+
 		if (e.getSource() == view.mi_save_binary)
 			strategy = new BinaryStrategy();
 		else if (e.getSource() == view.mi_save_beans)
 			// TODO Auto-generated catch block
 			e1.printStackTrace();
 		}
-		
+
 	}
-	
-	
+
 	@Override
 	public void actionPerformed(ActionEvent e) {
 		String errors = "";

File src/controller/UDPTimeServer.java

-package controller;
-
-import java.io.*;
-import java.net.*;
-import java.nio.charset.Charset;
-import java.util.Date;
-
-public class UDPTimeServer {
-	public static void main(String[] Args) {
-		byte[] inhalt = new byte[1024];
-		DatagramPacket paket;
-		DatagramSocket dSocket = null;
-		try {
-			dSocket = new DatagramSocket(6667);
-			while (System.in.available() == 0) {
-
-				paket = new DatagramPacket(inhalt, inhalt.length);
-				dSocket.receive(paket);
-				String recv = new String(paket.getData()).substring(0,
-						paket.getLength());
-
-				// Kommando überprüfen. Wird die Uhrzeit abgefragt?
-				if (!recv.equals("time"))
-					continue;
-
-				// IP und Adresse des Clients ausgeben
-				System.out.println("[IP]: " + paket.getAddress()
-						+ " | [Port]: " + paket.getPort());
-
-				inhalt = (new Date(System.currentTimeMillis())).toString()
-						.getBytes();
-				paket = new DatagramPacket(inhalt, inhalt.length,
-						paket.getSocketAddress());
-				dSocket.send(paket);
-			}
-			//System.in.read(new byte[System.in.available()]);
-			dSocket.close();
-		} catch (Exception e) {
-		}
-	}
-}

File src/db/JDBCConnector.java

 package db;
 
-import hs.Product;
+import model.Product;
 
 import java.sql.*;
 import java.util.ArrayList;
 	Connection con;
 	Statement stmt;
 	PreparedStatement pstmt = null;
-	
-	
-//	String url = "jdbc:postgresql://is024sv.uni-duisburg.de/ws1011";
-//	String user = "ws1011";
-//	String password = "ftpw10";
-//	String query = "select * from products";	
-	
+
 	public JDBCConnector(String url, String user, String password) {
 		this.url = url;
 		this.user = user;
 			e.printStackTrace();
 		}
 	}
-	
+
 	public void test() {
-		
-		
+
 		String query = "select * from products";
 		try {
 			// Ein SQL-Anweisungsobjekt erzeugen
 			stmt = con.createStatement();
 
 			// Für Metadaten meta daklarieren
-			DatabaseMetaData meta = con.getMetaData();			
+			DatabaseMetaData meta = con.getMetaData();
 
 			// SQL-Anweisungsobjekt f�hrt die SQL-Anweisung aus und schreibt
 			// das Resultat in das ResultSet-Objekt
 			ResultSet rs = stmt.executeQuery(query);
-			System.out.println("Ergebnis folgender SQL-Anweisung \n" + query
-					+ ":\n");
+			System.out.println("Ergebnis folgender SQL-Anweisung \n" + query + ":\n");
 
 			// ResultSetMetaData-Objekt verwaltet Informationen �ber das
 			// Ergebnis
 
 			// ResultSet-Objekt wird verarbeitet und die Werte
 			// werden auf die Standardausgabe geschrieben
-			
+
 			while (rs.next()) {
 				for (int i = 1; i <= n; i++) {
 					if (i != n)
 						System.out.println(rs.getString(i));
 				}
 			}
-			
+
 			System.out.println(meta.getURL());
 			System.out.println(meta.getUserName());
-			ResultSet res = meta.getTables(null, null, null,
-					new String[] { "TABLE" });
+			ResultSet res = meta.getTables(null, null, null, new String[] { "TABLE" });
 			System.out.println("Tabellen: ");
 			while (res.next()) {
 				System.out.println(res.getString("TABLE_NAME"));
 
 	public void insert(String name, double price, int quantity) {
 		try {
-			pstmt = con.prepareStatement("INSERT INTO products (name, price, quantity) VALUES (?, ?, ?)");
+			pstmt = con
+					.prepareStatement("INSERT INTO products (name, price, quantity) VALUES (?, ?, ?)");
 			pstmt.setString(1, name);
 			pstmt.setDouble(2, price);
 			pstmt.setInt(3, quantity);
 			e.printStackTrace();
 		}
 	}
-	
+
 	public void insert(Product product) {
 		insert(product.getName(), product.getPrice(), product.getQuantity());
 	}
-	
+
 	public Product read(long productId) {
 		Product product = new Product();
 		try {
 			ResultSet rs = stmt.executeQuery("SELECT * FROM products WHERE id = " + productId);
 
 			while (rs.next()) {
-				
+
 				// neues Product anlegen
-				product = new Product(
-						rs.getString("name"),
-						rs.getInt("quantity"),
+				product = new Product(rs.getString("name"), rs.getInt("quantity"),
 						rs.getDouble("price"));
 				break;
 			}
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
-		
+
 		return product;
 	}
-	
+
 	public ArrayList<Product> readLast(int count) {
 		ArrayList<Product> list = new ArrayList<Product>();
-		
+
 		try {
 			Statement stmt = con.createStatement();
 			// Alles oberhalb 41.000 wegfiltern -.-
-			ResultSet rs = stmt.executeQuery("SELECT * FROM products WHERE id < 41000 ORDER BY id DESC LIMIT " + count);
-			
+			ResultSet rs = stmt
+					.executeQuery("SELECT * FROM products WHERE id < 41000 ORDER BY id DESC LIMIT "
+							+ count);
+
 			while (rs.next()) {
 				// neues Product anlegen
-				list.add(new Product(
-						rs.getString("name"),
-						rs.getInt("quantity"),
-						rs.getDouble("price")));
+				list.add(new Product(rs.getString("name"), rs.getInt("quantity"), rs
+						.getDouble("price")));
 			}
 			stmt.close();
 		} catch (SQLException e) {
 		}
 		return list;
 	}
-	
+
 	public void close() {
 		if (con != null) {
 			try {

File src/hs/HardwareShop.java

 
 import controller.ControllerCustomer;
 import controller.ControllerShop;
-import db.JDBCConnector;
 import view.ViewCustomer;
 import view.ViewShop;
 import model.ModelShop;
 	 */
 	public static void main(String[] args) {
 		ModelShop model = new ModelShop();
-		
+
 		ViewShop viewShop = new ViewShop(model);
-		ViewCustomer viewCustomer = new ViewCustomer(model);
-		
+		ViewCustomer viewCustomer = new ViewCustomer(model, viewShop);
+
 		ControllerShop controllerShop = new ControllerShop(model, viewShop);
 		ControllerCustomer controllerCustomer = new ControllerCustomer(model, viewCustomer);
 	}

File src/hs/Order.java

-package hs;
-
-import fpt.com.Product;
-
-public class Order extends ProductList implements fpt.com.Order  {
-
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 1L;
-	
-	double sum = 0;
-	
-	@Override
-	public boolean add(Product e) {
-		if (super.add(e)) {
-			sum+=e.getPrice();
-			return true;
-		}
-
-		return false;
-	}
-
-	@Override
-	public double getSum() {
-		return sum;
-	}
-	
-	public void setSum(double sum) {
-		this.sum = sum;
-	}
-
-	@Override
-	public fpt.com.ProductList getProducts() {
-		return getProducts();
-	}
-
-	@Override
-	public int getQuantity() {
-		return size();
-	}
-}

File src/hs/Product.java

-package hs;
-
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-
-import javax.persistence.*;
-import javax.persistence.SequenceGenerator;
-
-@Entity()
-@Table(name = "products")
-public class Product implements fpt.com.Product{
-	
-	/**
-	 * 
-	 */
-
-	private static final long serialVersionUID = 1L;
-
-	private String name;
-	private int quantity;
-	private double price;
-
-	@Id
-	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "products_SEQ")
-	@SequenceGenerator(name = "products_SEQ", sequenceName ="products_id_seq", allocationSize = 1) 
-	private long id; // Artikelnummer???
-	
-	public Product() {}
-	
-	public Product(String name, int quantity, double price){
-		this.name = name;
-		this.quantity = quantity;
-		this.price = price;
-	}
-
-	@Override
-	public long getId() {
-		return this.id;
-	}
-	
-	public void setId(long id) {
-		this.id = id;
-	}
-
-	@Override
-	public double getPrice() {
-		return this.price;
-	}
-	
-	public String getPriceAsString() {
-		return new DecimalFormat(".00").format(getPrice());	
-	}
-
-	@Override
-	public void setPrice(double price) {
-		this.price = price;
-	}
-
-	@Override
-	public int getQuantity() {
-		return this.quantity;
-	}
-
-	@Override
-	public void setQuantity(int quantity) {
-		this.quantity = quantity;
-	}
-
-	@Override
-	public void stepQuantityUp(int amount) {
-		this.quantity += amount;
-	}
-
-	@Override
-	public void stepQuantityDown(int amount) {
-		
-		if (this.quantity >= amount)
-			this.quantity -= amount;
-		else
-			this.quantity -= this.quantity;
-	}
-
-	@Override
-	public String getName() {
-		return this.name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-	
-	// String-Repräsentation des Produkts
-	public String toString() {
-		return "[Product]: " + this.name + " (" + this.price + ") - Quantity: " + this.quantity;
-	}
-	
-	public String getIdAsString() { 
-		return new DecimalFormat("000000").format(getId());		
-	}
-}

File src/hs/ProductList.java

-package hs;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-public class ProductList extends ArrayList<fpt.com.Product> implements fpt.com.ProductList {
-
-
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 1L;
-	
-	
-	public ProductList() {}
-
-	private transient long productIdCounter = 0;
-	
-	public long getProductIdCounter() {
-		return productIdCounter;
-	}
-		
-	public void setProductIdCounter(long productIdCounter) {
-		this.productIdCounter = productIdCounter;
-	}
-	
-	public long getNextProductId() throws Exception {
-		if (productIdCounter == 999999)
-			throw new Exception("Anzahl maximaler Produkte erreicht!");
-
-		return ++productIdCounter;
-	}
-
-	@Override
-	public boolean add(fpt.com.Product product) {
-		return super.add(product);
-	}
-
-	@Override
-	public void add(int index, fpt.com.Product product) {
-		super.add(index, product);	
-	}
-
-	@Override
-	public boolean addAll(Collection<? extends fpt.com.Product> products) {
-		return super.addAll(products);
-	}
-
-	@Override
-	public boolean addAll(int index, Collection<? extends fpt.com.Product> products) {
-		return super.addAll(index, products);
-	}
-
-	@Override
-	public fpt.com.Product set(int index, fpt.com.Product product) {
-		return super.set(index, product);
-	}
-
-	@Override
-	public fpt.com.Product findProductById(long id) {
-		// Iterator
-		Iterator<fpt.com.Product> iter = super.iterator();
-		
-		while (iter.hasNext()) {
-			fpt.com.Product prod = iter.next();
-			// Produkt gefunden?
-			if ( prod.getId() == id)
-				return prod;
-		}
-
-		// nichts gefunden!
-		return null;
-	}
-
-	@Override
-	public fpt.com.Product findProductByName(String name) {
-		// Iterator
-		Iterator<fpt.com.Product> iter = super.iterator();
-		
-		while (iter.hasNext()) {
-			fpt.com.Product prod = iter.next();
-			// Produkt gefunden?
-			if ( prod.getName().equals(name))
-				return prod;
-		}
-
-		// nichts gefunden!
-		return null;
-	}
-}

File src/hs/UDPTimeServer.java

+package hs;
+
+import java.net.*;
+import java.util.Date;
+
+public class UDPTimeServer {
+	public static void main(String[] Args) {
+		byte[] inhalt = new byte[1024];
+		DatagramPacket paket;
+		DatagramSocket dSocket = null;
+		try {
+			dSocket = new DatagramSocket(6667);
+			while (System.in.available() == 0) {
+
+				paket = new DatagramPacket(inhalt, inhalt.length);
+				dSocket.receive(paket);
+				String recv = new String(paket.getData()).substring(0, paket.getLength());
+
+				// Kommando überprüfen. Wird die Uhrzeit abgefragt?
+				if (!recv.equals("time"))
+					continue;
+
+				// IP und Adresse des Clients ausgeben
+				System.out.println("[IP]: " + paket.getAddress() + " | [Port]: " + paket.getPort());
+
+				inhalt = (new Date(System.currentTimeMillis())).toString().getBytes();
+				paket = new DatagramPacket(inhalt, inhalt.length, paket.getSocketAddress());
+				dSocket.send(paket);
+			}
+			// System.in.read(new byte[System.in.available()]);
+			dSocket.close();
+		} catch (Exception e) {
+		}
+	}
+}

File src/model/ModelShop.java

 
 import java.io.Serializable;
 
-import hs.ProductList;
-import hs.Product;
+import model.ProductList;
+import model.Product;
 
 public class ModelShop extends java.util.Observable implements Serializable {
 
 
 	private ProductList productList;
 	private long productIdCounter = 0;
-	
+
 	public ModelShop() {
 		super();
 		productList = new ProductList();
 	public long getProductIdCounter() {
 		return productIdCounter;
 	}
-		
+
 	public void setProductIdCounter(long productIdCounter) {
 		this.productIdCounter = productIdCounter;
-	}	
+	}
 
 	public void addProduct(Product product) {
 		// Produkt der Produkt-Liste hinzufügen
 		try {
-			//product.setId(productList.getNextProductId());
-			System.out.println("neue ID: " + product.getIdAsString());
+			// product.setId(productList.getNextProductId());
+			// System.out.println("neue ID: " + product.getIdAsString());
 			productList.add(product);
 			this.setChanged();
 			this.notifyObservers();
 	public ProductList getProducts() {
 		return productList;
 	}
-	
+
 	public void setProducts(ProductList productList) {
 		this.productList = productList;
 		this.setChanged();
 		this.notifyObservers();
 	}
-	
+
 }

File src/model/Order.java

+package model;
+
+import fpt.com.Product;
+
+public class Order extends ProductList implements fpt.com.Order {
+
+	private static final long serialVersionUID = 1L;
+
+	double sum = 0;
+
+	@Override
+	public boolean add(Product e) {
+		if (super.add(e)) {
+			// Gesamtpreis aufsummieren
+			sum += e.getQuantity() * e.getPrice();
+			return true;
+		}
+
+		return false;
+	}
+
+	@Override
+	public double getSum() {
+		return sum;
+	}
+
+	public void setSum(double sum) {
+		this.sum = sum;
+	}
+
+	@Override
+	public fpt.com.ProductList getProducts() {
+		return getProducts();
+	}
+
+	@Override
+	public int getQuantity() {
+		return size();
+	}
+}

File src/model/Product.java

+package model;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+import javax.persistence.*;
+import javax.persistence.SequenceGenerator;
+
+@Entity()
+@Table(name = "products")
+public class Product implements fpt.com.Product {
+
+	/**
+	 * 
+	 */
+
+	private static final long serialVersionUID = 1L;
+
+	private String name;
+	private int quantity;
+	private double price;
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "products_SEQ")
+	@SequenceGenerator(name = "products_SEQ", sequenceName = "products_id_seq", allocationSize = 1)
+	private long id; // Artikelnummer???
+
+	public Product() {
+	}
+
+	public Product(String name, int quantity, double price) {
+		this.name = name;
+		this.quantity = quantity;
+		this.price = price;
+	}
+
+	@Override
+	public long getId() {
+		return this.id;
+	}
+
+	public void setId(long id) {
+		this.id = id;
+	}
+
+	@Override
+	public double getPrice() {
+		return this.price;
+	}
+
+	public String getPriceAsString() {
+		return new DecimalFormat(".00").format(getPrice());
+	}
+
+	@Override
+	public void setPrice(double price) {
+		this.price = price;
+	}
+
+	@Override
+	public int getQuantity() {
+		return this.quantity;
+	}
+
+	@Override
+	public void setQuantity(int quantity) {
+		this.quantity = quantity;
+	}
+
+	@Override
+	public void stepQuantityUp(int amount) {
+		this.quantity += amount;
+	}
+
+	@Override
+	public void stepQuantityDown(int amount) {
+
+		if (this.quantity >= amount)
+			this.quantity -= amount;
+		else
+			this.quantity -= this.quantity;
+	}
+
+	@Override
+	public String getName() {
+		return this.name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	// String-Repräsentation des Produkts
+	public String toString() {
+		return "[Product]: " + this.name + " (" + this.price + ") - Quantity: "
+				+ this.quantity;
+	}
+
+	public String getIdAsString() {
+		return new DecimalFormat("000000").format(getId());
+	}
+}

File src/model/ProductList.java

+package model;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+public class ProductList extends ArrayList<fpt.com.Product> implements
+		fpt.com.ProductList {
+
+	private static final long serialVersionUID = 1L;
+
+	public ProductList() {
+	}
+
+	private transient long productIdCounter = 0;
+
+	public long getProductIdCounter() {
+		return productIdCounter;
+	}
+
+	public void setProductIdCounter(long productIdCounter) {
+		this.productIdCounter = productIdCounter;
+	}
+
+	public long getNextProductId() throws Exception {
+		if (productIdCounter == 999999)
+			throw new Exception("Anzahl maximaler Produkte erreicht!");
+
+		return ++productIdCounter;
+	}
+
+	@Override
+	public boolean add(fpt.com.Product product) {
+		return super.add(product);
+	}
+
+	@Override
+	public void add(int index, fpt.com.Product product) {
+		super.add(index, product);
+	}
+
+	@Override
+	public boolean addAll(Collection<? extends fpt.com.Product> products) {
+		return super.addAll(products);
+	}
+
+	@Override
+	public boolean addAll(int index,
+			Collection<? extends fpt.com.Product> products) {
+		return super.addAll(index, products);
+	}
+
+	@Override
+	public fpt.com.Product set(int index, fpt.com.Product product) {
+		return super.set(index, product);
+	}
+
+	@Override
+	public fpt.com.Product findProductById(long id) {
+		// Iterator
+		Iterator<fpt.com.Product> iter = super.iterator();
+
+		while (iter.hasNext()) {
+			fpt.com.Product prod = iter.next();
+			// Produkt gefunden?
+			if (prod.getId() == id)
+				return prod;
+		}
+
+		// nichts gefunden!
+		return null;
+	}
+
+	@Override
+	public fpt.com.Product findProductByName(String name) {
+		// Iterator
+		Iterator<fpt.com.Product> iter = super.iterator();
+
+		while (iter.hasNext()) {
+			fpt.com.Product prod = iter.next();
+			// Produkt gefunden?
+			if (prod.getName().equals(name))
+				return prod;
+		}
+
+		// nichts gefunden!
+		return null;
+	}
+}

File src/strategies/JDBCStrategy.java

 package strategies;
-import hs.Product;
-import hs.ProductList;
+
+import model.Product;
+import model.ProductList;
 
 import java.io.IOException;
 import java.io.Serializable;
 
 public class JDBCStrategy implements SerializableStrategy {
 
-	private JDBCConnector c;
+    private JDBCConnector c;
 
-	public JDBCStrategy() {
-		
-		try {
-			open(Type.READ_WRITE);
-			// c.test();
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		
-	}
-	@Override
-	public Object readObject() throws IOException, ClassNotFoundException {
-		ProductList pl = new ProductList();
+    public JDBCStrategy() {
 
-		try {
-			open(Type.READ_WRITE);
-
-			// Produktliste befüllen
-            for ( Product p : c.readLast(50)) {
-            	pl.add(p);
-            }
-
-		} finally { // Make sure to close
-			close(Type.READ_WRITE);
-		}
-
-		return pl;
+	try {
+	    open(Type.READ_WRITE);
+	    // c.test();
+	} catch (IOException e) {
+	    // TODO Auto-generated catch block
+	    e.printStackTrace();
 	}
 
-	@Override
-	public void writeObject(Serializable obj) throws IOException {
-		ProductList pl = (ProductList)obj;
-		try {
-			open(Type.READ_WRITE);
-		
-			Iterator<fpt.com.Product> iter = pl.iterator();
-			
-			while( iter.hasNext()) {
-				Product prod = (Product)iter.next();
-				c.insert(prod);				
-			}
-		} finally {
-			close(Type.READ_WRITE);
-		}
+    }
+
+    @Override
+    public Object readObject() throws IOException, ClassNotFoundException {
+	ProductList pl = new ProductList();
+
+	try {
+	    open(Type.READ_WRITE);
+
+	    // Produktliste befüllen
+	    for (Product p : c.readLast(50)) {
+		pl.add(p);
+	    }
+
+	} finally { // Make sure to close
+	    close(Type.READ_WRITE);
 	}
 
-	@Override
-	public boolean isOpen() {
-		return false;
+	return pl;
+    }
+
+    @Override
+    public void writeObject(Serializable obj) throws IOException {
+	ProductList pl = (ProductList) obj;
+	try {
+	    open(Type.READ_WRITE);
+
+	    Iterator<fpt.com.Product> iter = pl.iterator();
+
+	    while (iter.hasNext()) {
+		Product prod = (Product) iter.next();
+		c.insert(prod);
+	    }
+	} finally {
+	    close(Type.READ_WRITE);
 	}
+    }
 
-	@Override
-	public void close(Type type) throws IOException {
-		c.close();
-	}
+    @Override
+    public boolean isOpen() {
+	return false;
+    }
 
-	@Override
-	public void open(Type type) throws IOException {
-		c = new JDBCConnector(
-				"jdbc:postgresql://is024sv.uni-duisburg.de/ws1011",
-				"ws1011",
-				"ftpw10");
-	}
+    @Override
+    public void close(Type type) throws IOException {
+	c.close();
+    }
 
-	@Override
-	public void restart(Type type) throws IOException {
-		close(Type.READ_WRITE);
-		open(Type.READ_WRITE);
-	}
+    @Override
+    public void open(Type type) throws IOException {
+	c = new JDBCConnector(
+		"jdbc:postgresql://is024sv.uni-duisburg.de/ws1011", "ws1011",
+		"ftpw10");
+    }
+
+    @Override
+    public void restart(Type type) throws IOException {
+	close(Type.READ_WRITE);
+	open(Type.READ_WRITE);
+    }
 }

File src/strategies/OpenJPA.java

 package strategies;
 
-import hs.Product;
-import hs.ProductList;
+import model.Product;
+import model.ProductList;
 
 import java.io.IOException;
 import java.io.Serializable;
 
 public class OpenJPA implements fpt.com.SerializableStrategy {
 
-	EntityManagerFactory fac = null;
-	EntityManager e;
-	EntityTransaction t;
+    EntityManagerFactory fac = null;
+    EntityManager e;
+    EntityTransaction t;
 
-	public OpenJPA() {
-		// Verbindung OHNE persistence.xml
-		// fac = getWithoutConfig();
-		
-		// Verbindung MIT persistence.xml
-		fac = getWithConfig();
-		
-		e = fac.createEntityManager();
+    public OpenJPA() {
+	// Verbindung OHNE persistence.xml
+	// fac = getWithoutConfig();
+
+	// Verbindung MIT persistence.xml
+	fac = getWithConfig();
+
+	e = fac.createEntityManager();
+    }
+
+    public static EntityManagerFactory getWithConfig() {
+	EntityManagerFactory fac = Persistence.createEntityManagerFactory(
+		"openjpa", System.getProperties());
+
+	return fac;
+    }
+
+    public static EntityManagerFactory getWithoutConfig() {
+
+	Map<String, String> map = new HashMap<String, String>();
+
+	map.put("openjpa.ConnectionURL",
+		"jdbc:postgresql://is024sv.uni-duisburg.de/ws1011");
+	map.put("openjpa.ConnectionDriverName", "org.postgresql.Driver");
+	map.put("openjpa.ConnectionUserName", "ws1011");
+	map.put("openjpa.ConnectionPassword", "ftpw10");
+	map.put("openjpa.RuntimeUnenhancedClasses", "supported");
+	map.put("openjpa.jdbc.SynchronizeMappings", "false");
+
+	// find all classes to registrate them
+	List<Class<?>> types = new ArrayList<Class<?>>();
+	types.add(Product.class);
+
+	if (!types.isEmpty()) {
+	    StringBuffer buf = new StringBuffer();
+	    for (Class<?> c : types) {
+		if (buf.length() > 0)
+		    buf.append(";");
+		buf.append(c.getName());
+	    }
+	    // <class>Product</class>
+	    map.put("openjpa.MetaDataFactory", "jpa(Types=" + buf.toString()
+		    + ")");
 	}
 
-	public static EntityManagerFactory getWithConfig() {
-		EntityManagerFactory fac = Persistence.createEntityManagerFactory(
-				"openjpa", System.getProperties());
+	return OpenJPAPersistence.getEntityManagerFactory(map);
+    }
 
-		return fac;
+    @Override
+    public Object readObject() throws IOException, ClassNotFoundException {
+	t = e.getTransaction();
+
+	ProductList readProducts = new ProductList();
+
+	// Abfrage mit id < 41000
+	Query q = e
+		.createQuery("SELECT p FROM Product p WHERE p.id < 41000 ORDER BY p.id DESC");
+
+	// Anzahl beschränken
+	q.setMaxResults(50);
+
+	// Ergebnisliste aus der Abfrage
+	List<Product> results = q.getResultList();
+
+	for (Product p : results)
+	    readProducts.add(p);
+
+	return readProducts;
+    }
+
+    @Override
+    public void writeObject(Serializable obj) throws IOException {
+	t = e.getTransaction();
+	/*
+	 * Durchl�uft die ProductList
+	 */
+	Iterator<fpt.com.Product> iter = ((ProductList) obj).iterator();
+
+	t.begin();
+	while (iter.hasNext()) {
+	    Product p = (Product) iter.next();
+	    e.persist(p); // schreibt das Product weg
 	}
+	t.commit();
+	// all ok commit
+	// all Data is saved in database now
+    }
 
-	public static EntityManagerFactory getWithoutConfig() {
+    @Override
+    public boolean isOpen() {
+	// TODO Auto-generated method stub
+	return false;
+    }
 
-		Map<String, String> map = new HashMap<String, String>();
+    @Override
+    public void close(Type type) throws IOException {
+	// TODO Auto-generated method stub
 
-		map.put("openjpa.ConnectionURL",
-				"jdbc:postgresql://is024sv.uni-duisburg.de/ws1011");
-		map.put("openjpa.ConnectionDriverName", "org.postgresql.Driver");
-		map.put("openjpa.ConnectionUserName", "ws1011");
-		map.put("openjpa.ConnectionPassword", "ftpw10");
-		map.put("openjpa.RuntimeUnenhancedClasses", "supported");
-		map.put("openjpa.jdbc.SynchronizeMappings", "false");
+    }
 
-		// find all classes to registrate them
-		List<Class<?>> types = new ArrayList<Class<?>>();
-		types.add(Product.class);
+    @Override
+    public void open(Type type) throws IOException {
+	// TODO Auto-generated method stub
 
-		if (!types.isEmpty()) {
-			StringBuffer buf = new StringBuffer();
-			for (Class<?> c : types) {
-				if (buf.length() > 0)
-					buf.append(";");
-				buf.append(c.getName());
-			}
-			// <class>Product</class>
-			map.put("openjpa.MetaDataFactory", "jpa(Types=" + buf.toString()
-					+ ")");
-		}
+    }
 
-		return OpenJPAPersistence.getEntityManagerFactory(map);
-	}
+    @Override
+    public void restart(Type type) throws IOException {
+	// TODO Auto-generated method stub
 
-	@Override
-	public Object readObject() throws IOException, ClassNotFoundException {
-		t = e.getTransaction();
-		
-		ProductList readProducts = new ProductList();
-
-		// Abfrage mit id < 41000
-		Query q = e.createQuery("SELECT p FROM Product p WHERE p.id < 41000 ORDER BY p.id DESC");
-
-		// Anzahl beschränken
-		q.setMaxResults(50);
-
-		// Ergebnisliste aus der Abfrage
-		List<Product> results = q.getResultList();
-
-		for (Product p : results )				
-			readProducts.add(p);
-
-		return readProducts;
-	}
-
-	@Override
-	public void writeObject(Serializable obj) throws IOException {
-		t = e.getTransaction();
-		/*
-		 * Durchl�uft die ProductList
-		 */
-		Iterator<fpt.com.Product> iter = ((ProductList) obj).iterator();
-		
-		t.begin();
-		while (iter.hasNext()) {
-			Product p = (Product) iter.next();
-			e.persist(p); // schreibt das Product weg
-		}
-		t.commit();
-		// all ok commit
-		// all Data is saved in database now
-	}
-
-	@Override
-	public boolean isOpen() {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public void close(Type type) throws IOException {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void open(Type type) throws IOException {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void restart(Type type) throws IOException {
-		// TODO Auto-generated method stub
-
-	}
+    }
 
 }

File src/strategies/XStreamConverters/ProductConverter.java

 package strategies.XStreamConverters;
 
-import hs.Product;
+import model.Product;
 
 import com.thoughtworks.xstream.converters.Converter;
 import com.thoughtworks.xstream.converters.MarshallingContext;
 
 public class ProductConverter implements Converter {
 
-	public boolean canConvert(Class clazz) {
-		return clazz.equals(Product.class);
-	}
+    public boolean canConvert(Class clazz) {
+	return clazz.equals(Product.class);
+    }
 
-	public void marshal(Object value, HierarchicalStreamWriter writer,
-			MarshallingContext context) {
-		 
-		Product product = (Product) value;
+    public void marshal(Object value, HierarchicalStreamWriter writer,
+	    MarshallingContext context) {
 
-		// ID-Attribut hinzufügen
-		writer.addAttribute("id", product.getIdAsString());
-		
-		// NODES
-		writer.startNode("name");
-			writer.setValue(product.getName());
-		writer.endNode();
-		writer.startNode("preis");
-			writer.setValue(product.getPriceAsString());
-		writer.endNode();
-		writer.startNode("quantity");
-			writer.setValue(Integer.toString(product.getQuantity()));
-		writer.endNode();
-	}
+	Product product = (Product) value;
 
-	public Object unmarshal(HierarchicalStreamReader reader,
-			UnmarshallingContext context) {
-		Product product = new Product();
-		
-		// Attribut auslesen
-		product.setId(new Integer(reader.getAttribute("id")));
-		
-		// NODES
-		reader.moveDown();
-			product.setName(reader.getValue());
-		reader.moveUp();
-		reader.moveDown();
-			product.setPrice(new Double(reader.getValue()));
-		reader.moveUp();
-		reader.moveDown();
-			product.setQuantity(new Integer(reader.getValue()));
-		reader.moveUp();
+	// ID-Attribut hinzufügen
+	writer.addAttribute("id", product.getIdAsString());
 
-		return product;
-	}
+	// NODES
+	writer.startNode("name");
+	writer.setValue(product.getName());
+	writer.endNode();
+	writer.startNode("preis");
+	writer.setValue(product.getPriceAsString());
+	writer.endNode();
+	writer.startNode("quantity");
+	writer.setValue(Integer.toString(product.getQuantity()));
+	writer.endNode();
+    }
+
+    public Object unmarshal(HierarchicalStreamReader reader,
+	    UnmarshallingContext context) {
+	Product product = new Product();
+
+	// Attribut auslesen
+	product.setId(new Integer(reader.getAttribute("id")));
+
+	// NODES
+	reader.moveDown();
+	product.setName(reader.getValue());
+	reader.moveUp();
+	reader.moveDown();
+	product.setPrice(new Double(reader.getValue()));
+	reader.moveUp();
+	reader.moveDown();
+	product.setQuantity(new Integer(reader.getValue()));
+	reader.moveUp();
+
+	return product;
+    }
 }

File src/strategies/XStreamStrategy.java

 package strategies;
-import hs.Product;
-import hs.ProductList;
+
+import model.Product;
+import model.ProductList;
 
 import java.io.FileReader;
 import java.io.FileWriter;
 
 import strategies.XStreamConverters.ProductConverter;
 
-
 import com.thoughtworks.xstream.XStream;
 import com.thoughtworks.xstream.io.xml.DomDriver;
 
 
 public class XStreamStrategy implements SerializableStrategy {
 
-	private XStream xstream = new XStream(new DomDriver());
-	private String fileName = "poducts.xstream.xml";
+    private XStream xstream = new XStream(new DomDriver());
+    private String fileName = "poducts.xstream.xml";
 
-	private FileReader fr = null;
-	private FileWriter fw = null;
-	
-	public XStreamStrategy() {
-		xstream.setMode(XStream.NO_REFERENCES);
+    private FileReader fr = null;
+    private FileWriter fw = null;
 
-		/*
-		 * MAPPINGS
-		 */
-		
-		// "waren" statt "hs.ProductList"
-		xstream.alias("waren", ProductList.class);
-		// "ware" statt "Product"
-		xstream.alias("ware", Product.class);
-		xstream.registerConverter(new ProductConverter());
+    public XStreamStrategy() {
+	xstream.setMode(XStream.NO_REFERENCES);
+
+	/*
+	 * MAPPINGS
+	 */
+
+	// "waren" statt "hs.ProductList"
+	xstream.alias("waren", ProductList.class);
+	// "ware" statt "Product"
+	xstream.alias("ware", Product.class);
+	xstream.registerConverter(new ProductConverter());
+    }
+
+    @Override
+    public Object readObject() throws IOException, ClassNotFoundException {
+	Object readProductList = null;
+
+	try {
+	    open(Type.READ);
+
+	    readProductList = xstream.fromXML(fr); // Read Object
+	} finally { // Make sure to close
+	    close(Type.READ);
 	}
 
-	@Override
-	public Object readObject() throws IOException, ClassNotFoundException {
-		Object readProductList = null;
+	return readProductList;
+    }
 
-		try {
-			open(Type.READ);
-            
-			readProductList = xstream.fromXML(fr); // Read Object
-		} finally { // Make sure to close
-			close(Type.READ);
-		}
+    @Override
+    public void writeObject(Serializable obj) throws IOException {
+	try {
+	    open(Type.WRITE);
+	    xstream.toXML(obj, fw);
+	} finally {
+	    close(Type.WRITE);
+	}
+    }
 
-		return readProductList;
+    @Override
+    public boolean isOpen() {
+	return false;
+    }
+
+    @Override
+    public void close(Type type) throws IOException {
+	// FileReader schliessen
+	if (type == Type.READ && fr != null) {
+	    fr.close();
+	    return;
 	}
 
-	@Override
-	public void writeObject(Serializable obj) throws IOException {
-		try {
-			open(Type.WRITE);
-			xstream.toXML(obj, fw);
-		} finally {
-			close(Type.WRITE);
-		}
+	// FileWriter schliessen
+	if (type == Type.WRITE && fw != null)
+	    fw.close();
+    }
+
+    @Override
+    public void open(Type type) throws IOException {
+	if (!isOpen() && type == Type.READ) {
+	    fr = new FileReader(fileName); // Open file
+	    return;
 	}
 
-	@Override
-	public boolean isOpen() {
-		return false;
-	}
+	if (!isOpen() && type == Type.WRITE)
+	    fw = new FileWriter(fileName);
+    }
 
-	@Override
-	public void close(Type type) throws IOException {
-		// FileReader schliessen
-		if (type == Type.READ && fr != null) {
-			fr.close();
-			return;
-		}
-
-		// FileWriter schliessen
-		if (type == Type.WRITE && fw != null)
-			fw.close();
-	}
-
-	@Override
-	public void open(Type type) throws IOException {
-		if (!isOpen() && type == Type.READ) {
-			fr = new FileReader(fileName); // Open file
-			return;
-		}
-
-		if (!isOpen() && type == Type.WRITE)
-			fw = new FileWriter(fileName);
-	}
-
-	@Override
-	public void restart(Type type) throws IOException {
-		close(type);
-		open(type);
-	}
+    @Override
+    public void restart(Type type) throws IOException {
+	close(type);
+	open(type);
+    }
 }

File src/view/BuyCellEditor.java

 import javax.swing.JTable;
 import javax.swing.table.TableCellEditor;
 
+import model.ModelShop;
+
 public class BuyCellEditor extends AbstractCellEditor implements
 		TableCellEditor {
 
 	 */
 	private static final long serialVersionUID = 1L;
 	JComboBox cb;
+	ModelShop model;
+
+	BuyCellEditor(ModelShop model) {
+		this.model = model;
+	}
 
 	@Override
 	public Component getTableCellEditorComponent(JTable table, Object value,
 		cb = new JComboBox();
 
 		// Select the current value
-		for (int i = 0; i <= (Integer) value; i++)
+		for (int i = 0; i <= (Integer) model.getProducts().get(row)
+				.getQuantity(); i++)
 			cb.addItem(i);
 
-		cb.setSelectedItem(0);
+		cb.setSelectedItem((Integer)table.getModel().getValueAt(row, column));
 		return cb;
 	}
 

File src/view/ViewCustomer.java

 import java.util.Observable;
 import java.util.Vector;
 
+import javax.swing.BorderFactory;
 import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
 
 import model.ModelShop;
 
+public class ViewCustomer extends JFrame implements java.util.Observer {
 
-public class ViewCustomer extends JFrame implements java.util.Observer {
-	/**
-	 * 
-	 */
 	private static final long serialVersionUID = -3432763193496943765L;
+
 	JPanel panel;
 	JPanel panel2;
 	JTable table;
 	public JButton button;
-	
+
 	public ModelShop model;
 	JLabel l_time;
 	public DefaultTableModel mod;
-	
-	public ViewCustomer(ModelShop model){
-			super("View Customer");
-			
-			this.model = model;
-			model.addObserver(this);
-			
-			initUI();
-			setSize(350,250);
-			setVisible(true);
+
+	public ViewCustomer(ModelShop model, JFrame parent) {
+		super("View Customer");
+
+		this.model = model;
+		model.addObserver(this);
+
+		initUI();
+		setSize(350, 250);
+		setLocationRelativeTo(parent);
+		setLocation(parent.getSize().width + 20, 0);
+		setVisible(true);
 	}
+
+	private void initUI() {
 		
-		private void initUI() {
-			
-			
-			panel = new JPanel();
-			panel.setLayout(new BorderLayout());
-			this.add(panel);
+		panel = new JPanel();
+		panel.setLayout(new BorderLayout());
+		panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+		this.add(panel);
 
-			table = new JTable();
+		table = new JTable();
 
-			table.setFillsViewportHeight(true);
-			JScrollPane scrollpane = new JScrollPane(table);
-			panel.add(scrollpane,BorderLayout.CENTER);
-			
-			// Behilfslayout
-			panel2 = new JPanel();
-			panel2.setLayout(new BorderLayout());
-			
-			button = new JButton("Bestellen");
-			panel2.add(button, BorderLayout.EAST);
-			l_time = new JLabel("warte auf Serverzeit...");
-			panel2.add(l_time, BorderLayout.WEST);
-			panel.add(panel2,BorderLayout.SOUTH);
+		table.setFillsViewportHeight(true);
+		JScrollPane scrollpane = new JScrollPane(table);
+		panel.add(scrollpane, BorderLayout.CENTER);
 
-			// update aufrufen um die Spalten darzustellen (noch keine Daten!)
-			this.update(new Observable(), new Object());
-		}
-	
-		
+		// Behilfslayout
+		panel2 = new JPanel();
+		panel2.setLayout(new BorderLayout());
+
+		button = new JButton("Bestellen");
+		panel2.add(button, BorderLayout.EAST);
+		l_time = new JLabel("warte auf Serverzeit...");
+		panel2.add(l_time, BorderLayout.WEST);
+		panel.add(panel2, BorderLayout.SOUTH);
+
+		// update aufrufen um die Spalten darzustellen (noch keine Daten!)
+		this.update(new Observable(), new Object());
+	}
+
 	@Override
 	public void update(Observable arg0, Object arg1) {
 		// Temporäres Model erstellen
 		mod.addColumn("Buy");
 
 		table.setModel(mod);
-		
+
 		// ComboBox als Bestellmengen-Editor
 		TableColumn quantityColumn = table.getColumnModel().getColumn(3);
-		quantityColumn.setCellEditor(new BuyCellEditor());
+		quantityColumn.setCellEditor(new BuyCellEditor(model));
 
 		Iterator<Product> iter = model.getProducts().iterator();
-		while( iter.hasNext()) {
+		while (iter.hasNext()) {
 			Product prod = iter.next();
 			Vector<Object> zeile = new Vector<Object>();
 			zeile.add(prod.getName());
 			zeile.add(prod.getQuantity());
 			zeile.add(prod.getPrice() + "€");
-			// TODO: Initialwert muss auf 0 stehen!
-			zeile.add(prod.getQuantity());
+			
+			// zeile.add(prod.getQuantity());
+			// Initialwert immer auf 0
+			zeile.add(0);
 
+			// Produkt zum Tabellen(!)-Model hinzufügen
 			mod.addRow(zeile);
-			//mod.setValueAt(arg0, arg1, arg2)
 		}
-			
-	}	
-	
+
+	}
+
 	public void addActionListner(ActionListener e) {
 		button.addActionListener(e);
-		
+
 	}
-	
+
 	public void setTimeLabel(String time) {
 		l_time.setText("Zeit: " + time);
 	}

File src/view/ViewLogin.java

+package view;
+
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Observable;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JPasswordField;
+import javax.swing.JTextField;
+
+public class ViewLogin extends JDialog implements java.util.Observer {
+
+	private static final long serialVersionUID = 1L;
+
+	JPanel panel;
+
+	JTextField tf_host, tf_user;
+	JPasswordField pf_password;
+	JButton btn_login;
+	
+	public ViewLogin(JFrame parent) {
+		super(parent, "Login", true);
+
+		initUI();
+
+		setSize(300,160);
+		setResizable(false);
+		setLocation(parent.getLocation().x+24,parent.getLocation().y+25);
+		setVisible(true);
+	}
+
+	private void initUI() {
+		panel = new JPanel();
+		panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+		
+		GridLayout lay = new GridLayout(0,2);
+		lay.setHgap(5);	lay.setVgap(5);
+		
+		panel.setLayout(lay);
+		this.add(panel);
+		
+			panel.add(new JLabel("Host:"));			
+			tf_host = new JTextField("localhost");
+			panel.add(tf_host);
+			
+			panel.add(new JLabel("User:"));
+			tf_user = new JTextField();
+			panel.add(tf_user);
+			
+			panel.add(new JLabel("Password:"));
+			pf_password = new JPasswordField();
+			panel.add(pf_password);
+
+			panel.add(new JLabel());
+			btn_login = new JButton("Login");
+			btn_login.addActionListener(new ActionListener() {
+				@Override
+				public void actionPerformed(ActionEvent e) { close(); }
+			});
+			panel.add(btn_login);
+
+		pack();
+	}
+
+	void close() {
+		dispose();
+	}
+	
+	@Override
+	public void update(Observable arg0, Object arg1) {
+		// TODO Auto-generated method stub
+
+	}
+
+}

File src/view/ViewShop.java

 package view;
 
-import hs.Product;
-import hs.ProductList;
+import model.Product;
+import model.ProductList;
 
 import java.awt.BorderLayout;
 import java.awt.GridBagConstraints;
 import java.util.Observable;
 import java.util.Vector;
 
+import javax.swing.BorderFactory;
 import javax.swing.ButtonGroup;
 import javax.swing.JButton;
 import javax.swing.JFileChooser;
 
 import model.ModelShop;
 
-
 public class ViewShop extends JFrame implements java.util.Observer {
 
 	private static final long serialVersionUID = -7872210279724795089L;
 	// TextFields zur Eingabe der Produkt
 	JTextField tf_name, tf_quantity, tf_price;
 	JButton btn_addProduct;
-	
+
 	// Menüs
 	JMenuBar menuBar;
 	JMenu menu_file;
 	JMenu menu_onOf;
-	JMenu menu_open, menu_save; 
-	public JMenuItem mi_open_binary, mi_open_beans, mi_open_xstream, mi_readJDBC, mi_readJPA;
-	public JMenuItem mi_save_binary, mi_save_beans, mi_save_xstream, mi_writeJDBC, mi_writeJPA;
+	JMenu menu_open, menu_save;
+	public JMenuItem mi_open_binary, mi_open_beans, mi_open_xstream,
+			mi_readJDBC, mi_readJPA;
+	public JMenuItem mi_save_binary, mi_save_beans, mi_save_xstream,
+			mi_writeJDBC, mi_writeJPA;
 	JMenuItem mi_exit;
-	
+
 	JRadioButtonMenuItem mi_online, mi_offline;
 
 	// Model fürs Table
 	ModelShop model;
-	
+
 	public ViewShop(ModelShop model) {
 		super("View Shop");
-		
+
 		// Applikation beim Schließen des Fensters beenden
 		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
 
 		this.model = model;
 		model.addObserver(this);
-		
+
 		initUI();
 		setVisible(true);
-        setSize(700, 500);
-        
-    }
-	
+		setSize(700, 500);
+	}
+
 	private void initUI() {
 		// Hauptpanel für alle Elemente
 		panel = new JPanel();
 		panel.setLayout(new BorderLayout());
+		panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
 		this.add(panel);
-		
+
 		table = new JTable();
 		JScrollPane scrollPane = new JScrollPane(table);
 		table.setFillsViewportHeight(true);
-		
+
 		// update aufrufen um die Spalten darzustellen (noch keine Daten!)
 		this.update(new Observable(), new Object());
 
 		 * SPÄTER ERSETZEN!
 		 */
 		JTextArea ta1 = new JTextArea();
-        JSplitPane top_panel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPane, ta1);
+		JSplitPane top_panel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
+				scrollPane, ta1);
 		panel.add(top_panel);
 
-
 		/*
-		 * CONTROLS 
+		 * CONTROLS
 		 */
 		JPanel controls = new JPanel();
 
 		// Hilfslayout für Eingabefelder / Beschriftungen
-		controls.setLayout(new GridLayout(2,2));
+		controls.setLayout(new GridLayout(2, 2));
 		panel.add(controls, BorderLayout.SOUTH);
 
-			GridBagConstraints c = new GridBagConstraints();
+		GridBagConstraints c = new GridBagConstraints();
 
-			controls.add(new JLabel("Name:"), c);
-			controls.add(new JLabel("Quantity:"), c);
-			controls.add(new JLabel("Price:"), c);
-			// dummy
-			controls.add(new JPanel());
-		
-			// Eingabefelder
-			tf_name = new JTextField();
-			controls.add(tf_name, c);
+		controls.add(new JLabel("Name:"), c);
+		controls.add(new JLabel("Quantity:"), c);
+		controls.add(new JLabel("Price:"), c);
+		// dummy
+		controls.add(new JPanel());
 
-			tf_quantity = new JTextField();
-			controls.add(tf_quantity, c);
+		// Eingabefelder
+		tf_name = new JTextField();
+		controls.add(tf_name, c);
 
-			tf_price = new JTextField();
-			controls.add(tf_price, c);
+		tf_quantity = new JTextField();
+		controls.add(tf_quantity, c);
 
-			// Produkt Hinzufügen
-			btn_addProduct = new JButton("Add Product");