Beispiel #1
0
 // Создать клиентский заказ
 private void openClientOrderForm() {
   productItemMap
       .entrySet()
       .stream()
       .forEach(
           productItem -> {
             TypeComboBox.addItem(productItem.getValue().getType());
           });
   TypeComboBox.revalidate();
   DataTextField.setText(clientFacade.getCurrentDate());
   FormOrderPanel.setVisible(true);
   productItemList = new HashMap<>();
 }
Beispiel #2
0
 public void generateOrdersTree() {
   clientFacade
       .getSTreeNodeList(NameLabel.getText())
       .stream()
       .forEach(
           sTreeNode -> {
             sTreeNode
                 .getClientOrders()
                 .stream()
                 .forEach(
                     clientOrder -> {
                       Date date = new Date(clientOrder.getData());
                       SimpleDateFormat df2 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
                       String dateText = df2.format(date);
                       root.add(new DefaultMutableTreeNode(dateText));
                     });
           });
 }
Beispiel #3
0
  private ClientWindow(String name) {
    setTitle("ClientWindow");
    setContentPane(WindowPanel);
    pack();

    clientFacade = ClientFacade.getClientFacadeByClientName(name);
    NameLabel.setText(clientFacade.getClientName());

    productItemMap = clientFacade.getProductList();
    FormOrderPanel.setVisible(false);

    tableModel = new ProductsTableModel();
    ProductsTable.setModel(tableModel);

    root = new DefaultMutableTreeNode("ClientOrders");

    generateOrdersTree();

    OrdersTree.setModel(new DefaultTreeModel(root));
    OrdersTree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
              TreePath pathSelected = OrdersTree.getSelectionPath();
              if (OrdersTree.isPathSelected(pathSelected)
                  && OrdersTree.getModel().isLeaf(pathSelected.getLastPathComponent())) {
                ManagerPopupMenu managerPopupMenu = new ManagerPopupMenu();
                managerPopupMenu.getJPopupMenu().show(e.getComponent(), e.getX(), e.getY());
              }
            }
          }
        });
    OrdersTree.setShowsRootHandles(true);
    OrdersTree.setRootVisible(true);

    OrdersTree.getSelectionModel()
        .addTreeSelectionListener(
            e -> {
              DefaultMutableTreeNode selectedNode =
                  (DefaultMutableTreeNode) OrdersTree.getLastSelectedPathComponent();
              if (selectedNode.isLeaf()) {
                if (!((String) selectedNode.getUserObject()).equals("ClientOrders")) {
                  List<ProductRow> productRowList =
                      clientFacade.getProductRowsByOrder(
                          clientFacade.getValidDate((String) selectedNode.getUserObject()));
                  productRowList
                      .stream()
                      .forEach(
                          productRow ->
                              ClientWindow.this.tableModel.addRow(
                                  productRow.getId(),
                                  productRow.getType(),
                                  productRow.getPrice(),
                                  productRow.getNumber()));

                  ProductsTable.revalidate();
                }
              }
            });

    Font font = new Font("Verdana", Font.PLAIN, 12);
    jMenuBar = new JMenuBar();
    jMenu = new JMenu("Actions");

    JMenuItem jCreateProviderOrderItem = new JMenuItem("Создать заказ");
    jCreateProviderOrderItem.setFont(font);
    jCreateProviderOrderItem.addActionListener(e -> openClientOrderForm());
    jMenu.add(jCreateProviderOrderItem);

    jMenu.addSeparator();

    JMenuItem jCloseItem = new JMenuItem("Закрыть");
    jCloseItem.setFont(font);
    jCloseItem.addActionListener(e -> close());
    jMenu.add(jCloseItem);

    jMenuBar.add(jMenu);
    MenuPanel.add(jMenuBar);

    OrderOkButton.addActionListener(e -> createClientOrder());
    OrderCancelButton.addActionListener(e -> closeClientOrderForm());
    TypeComboBox.addItemListener(e -> setPriceByType());
    AddProductButton.addActionListener(
        e -> {
          if (productItemList == null) {
            productItemList = new HashMap<String, ProductItem>();
          }
          productItemList.put(
              TypeComboBox.getSelectedItem().toString(),
              new ProductItem(
                  TypeComboBox.getSelectedItem().toString(),
                  PriceTextField.getText(),
                  AmountTextField.getText()));
        });

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);

    BurgerButton.addActionListener(e -> FastFoodTextArea.append(clientFacade.getBurger()));

    RunServerButton.addActionListener(e -> InfoTextArea.append(clientFacade.runServer()));

    StopServerButton.addActionListener(e -> InfoTextArea.append(clientFacade.stopServer()));
  }
Beispiel #4
0
 // Отменить заказ
 private void cancelClientOrder() {
   InfoTextArea.append(clientFacade.cancelOrder());
 }
Beispiel #5
0
 // Оплатить 25 процентов заказа
 private void pay25Order(String s) {
   InfoTextArea.append(clientFacade.payFullOrder());
 }
Beispiel #6
0
 // Создать клиентский заказ
 private void createClientOrder() {
   InfoTextArea.append(clientFacade.createClientOrder(DataTextField.getText(), productItemList));
 }