protected void addButtonClicked() {
	try {
	    // if id exists
	    id = Long.parseLong(idField.getText());
	    model.getWarehouseTableModel().getItemById(id);

	    name = nameField.getText();
	    description = descriptionField.getText();

	    if (name.equals("")) {
		name = model.getWarehouseTableModel().getItemById(id).getName();
	    }

	    if (description.equals("")) {
		description = model.getWarehouseTableModel().getItemById(id).getDescription();
	    }

	    if (quantityField.getText().equals("")) {
		quantity = model.getWarehouseTableModel().getItemById(id).getQuantity();
	    } else {
		quantity = Integer.parseInt(quantityField.getText());
	    }

	    if (priceField.getText().equals("")) {
		price = model.getWarehouseTableModel().getItemById(id).getPrice();
	    } else {
		price = Double.parseDouble(priceField.getText().replace(",", "."));
		price = Math.round(price * 100.0) / 100.0;
	    }
	    StockItem newItem = new StockItem(id, name, description, price, quantity);
	    model.getDomainController().addStockItem(newItem);
	    model.getWarehouseTableModel().reload(model.getDomainController().loadWarehouseState());
	    this.dispose();

	} catch (NoSuchElementException e) {
	    try {
		id = Long.parseLong(idField.getText());
		name = nameField.getText();
		price = Double.parseDouble(priceField.getText().replace(",", "."));
		description = descriptionField.getText();
		quantity = Integer.parseInt(quantityField.getText());

		price = Math.round(price * 100.0) / 100.0;

		if ((name.equals("")) || (description.equals(""))) {
		    JOptionPane.showMessageDialog(null, "Undefined input!");
		} else {
		    StockItem newItem = new StockItem(id, name, description, price, quantity);
		    //model.getWarehouseTableModel().addItem(newItem);
		    model.getWarehouseTableModel().fireTableDataChanged();
		}
		this.dispose();
	    } catch (NumberFormatException f) {
		JOptionPane.showMessageDialog(null, "Undefiend input!");
	    }
	} catch (NumberFormatException d) {
	    JOptionPane.showMessageDialog(null, "Undefiend input!");
	}

    }