Ejemplo n.º 1
0
    public void actionPerformed(ActionEvent evt) {
      JTable table = selectOrderWindow.getTable();
      CustomTableModel model = selectOrderWindow.getModel();
      int selectedRow = table.getSelectedRow();
      if (selectedRow >= 0) {

        // start by reading order id from screen
        // String id = (String)table.getValueAt(selectedRow, 0);

        selectOrderWindow.setVisible(false);
        @SuppressWarnings("unused")
        String selOrderId = (String) model.getValueAt(selectedRow, 0);
        // String selOrderId = "1";
        SessionContext context = SessionContext.getInstance();
        ICustomerSubsystem customer = (ICustomerSubsystem) context.get(CustomerConstants.CUSTOMER);
        viewOrderDetailsWindow = new ViewOrderDetailsWindow();
        if (customer != null) {
          List<IOrder> orderList = null;
          orderList = customer.getOrderHistory();
          List<IOrderItem> orderitems = OrderUtil.getOrderItemsFromOrder(selOrderId, orderList);
          List<String[]> displayableList = OrderUtil.extractOrderItemData(orderitems);
          viewOrderDetailsWindow.updateModel(displayableList);
        }

        mainFrame.getDesktop().add(viewOrderDetailsWindow);
        viewOrderDetailsWindow.setVisible(true);
      } else {
        JOptionPane.showMessageDialog(
            selectOrderWindow, ERROR_MESSAGE, ERROR, JOptionPane.ERROR_MESSAGE);
      }
    }
Ejemplo n.º 2
0
 public void doUpdate() {
   if (selectOrderWindow != null) {
     SessionContext context = SessionContext.getInstance();
     ICustomerSubsystem customer = (ICustomerSubsystem) context.get(CustomerConstants.CUSTOMER);
     if (customer != null) {
       List<IOrder> orderList = null;
       orderList = customer.getOrderHistory();
       List<String[]> displayableList = OrderUtil.extractOrderData(orderList);
       selectOrderWindow.updateModel(displayableList);
       mainFrame.getDesktop().add(selectOrderWindow);
       selectOrderWindow.setVisible(true);
     }
   }
 }
Ejemplo n.º 3
0
    public void actionPerformed(ActionEvent e) {
      SessionContext context = SessionContext.getInstance();
      selectOrderWindow = new SelectOrderWindow();
      Boolean loggedIn = (Boolean) context.get(CustomerConstants.LOGGED_IN);
      ICustomerSubsystem customer = null;
      List<IOrder> orderList = null;
      // needs to log in
      if (!loggedIn.booleanValue()) {
        LoginControl loginControl = new LoginControl(selectOrderWindow, mainFrame, this);
        loginControl.startLogin();

      } else { // already logged in

        customer = (ICustomerSubsystem) context.get(CustomerConstants.CUSTOMER);
        if (customer != null) orderList = customer.getOrderHistory();
        List<String[]> displayableList = OrderUtil.extractOrderData(orderList);

        selectOrderWindow.updateModel(displayableList);
        mainFrame.getDesktop().add(selectOrderWindow);
        selectOrderWindow.setVisible(true);
      }
    }