public void populate() { productLines = model.getProductLines(); suppliers = model.getSuppliers(); createMap(); products = model.getProducts(); if (iProductLineList.getItemCount() != 0) { iProductLineList.removeAllItems(); } iProductLineList.addItem(" "); for (ProductLine productLine : productLines) { iProductLineList.addItem(productLine.getProductLineName()); } if (iSupplierList.getItemCount() != 0) { iSupplierList.removeAllItems(); } iSupplierList.addItem(" "); for (Supplier supplier : suppliers) { iSupplierList.addItem(supplier.getSupplierName()); } populateTable(); }
private void createMap() { productLineMap = new HashMap<Integer, String>(); supplierMap = new HashMap<Integer, String>(); for (ProductLine productLine : productLines) { productLineMap.put(productLine.getProductLineID(), productLine.getProductLineName()); } for (Supplier supplier : suppliers) { supplierMap.put(supplier.getSupplierID(), supplier.getSupplierName()); } }
private void showProductDetails(int ID) { List<Products> productWithID = products.stream().filter((p) -> p.getProductID() == ID).collect(Collectors.toList()); List<Supplier> supplierWithID = suppliers .stream() .filter((p) -> p.getSupplierID() == p.getSupplierID()) .collect(Collectors.toList()); Products product = productWithID.get(0); Supplier supplier = supplierWithID.get(0); String productName_ = (productLineMap.get(product.getProductLineID()) + " " + product.getDescription() + " " + product.getCharacteristics() + " " + product.getMotors()) .replaceAll("\\s+", " "); String productDescription_ = (product.getDescription() + " " + product.getCharacteristics() + " " + product.getMotors()) .replaceAll("\\s+", " "); iProductName.setText(productName_); iItemNumber.setText(String.valueOf(product.getProductID())); iAddMotoCode.setText(product.getAddmotoCode()); iProductLine.setText(productLineMap.get(product.getProductLineID())); iItemDescription.setText(productDescription_); iSellingPrice.setText(Formatter.format(product.getSellingPrice())); iUnitCost.setText(Formatter.format(product.getUnitPrice())); iOnHandQuantity.setText(String.valueOf(product.getCurrentQuantity())); iQtyThreshold.setText(String.valueOf(product.getThresholdCount())); iStatus.setText("Not Yet Implemented"); iSupplier.setText(supplier.getSupplierName()); iEditUpdateRSP.setEnabled(true); iEditUpdateUC.setEnabled(true); iEditUpdateQT.setEnabled(true); }