Beispiel #1
0
 @Override
 public void actionPerformed(ActionEvent e) {
   ID = (Integer) hashRoomType.get(boxRoomTypeID.getSelectedItem().toString());
   IDSTATUS = (Integer) hashRoomStatus.get(boxRoomStatusID.getSelectedItem().toString());
   if (e.getSource() == buttonInsert) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       RoomsController.roomsController.save(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "ok");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonUpdate) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       rooms.setRoomID(IDROOM);
       RoomsController.roomsController.update(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "Update to succeed !");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonDelete) {
     try {
       List<CheckIn> temp = CheckInController.checkInController.all();
       for (int i = 0; i < temp.size(); i++) {
         if (IDROOM == temp.get(i).getRoomID()) {
           this.error = 0;
         } else {
           this.error = 0;
           RoomsController.roomsController.delete(IDROOM);
           int c = model.getRowCount();
           for (int ii = c - 1; ii >= 0; ii--) {
             model.removeRow(ii);
             jRoom.revalidate();
           }
           all();
         }
       }
       JOptionPane.showMessageDialog(this, "Delete to succeed !");
     } catch (Exception ex) {
       JOptionPane.showMessageDialog(this, "can't delete row bcause check still !");
     }
   }
   if (e.getSource() == buttonRefresh) {}
 }
Beispiel #2
0
  public void update() {
    infoPanel.update();

    Object[][] history = new Object[account.getHistory().size()][5];
    int i = 0;
    for (Transaction t : account.getHistory()) {
      history[i][0] = t.getType();
      BigDecimal amount;
      BigDecimal balance;
      if (account.getType().isLoan()) {
        amount = (t.getType().isPositive() ? t.getAmount().negate() : t.getAmount());
        balance = t.getBalance().negate();
      } else {
        amount = (t.getType().isPositive() ? t.getAmount() : t.getAmount().negate());
        balance = t.getBalance();
      }
      history[i][1] = FORMATTER.valueToString(amount);
      history[i][2] = FORMATTER.valueToString(balance);
      history[i][3] = t.getTimestamp();
      history[i][4] = t.getFraudStatus();
      i++;
    }
    historyTable.setModel(
        new javax.swing.table.DefaultTableModel(
            history, new String[] {"Type", "Amount", "Balance", "Month", "Flag"}) {
          @Override
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        });
    historyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    historyTable.revalidate();
  }
Beispiel #3
0
  /** Sets the call stack with the given vector of method names. */
  public void setContents(Vector newMethodNames) {
    methodNames = (Vector) newMethodNames.clone();
    callStackTable.revalidate();

    Rectangle r = callStackTable.getCellRect(newMethodNames.size() - 1, 0, true);
    callStackTable.scrollRectToVisible(r);
    repaint();
  }
  private void setSizeAndDimensions(
      @NotNull JTable table,
      @NotNull JBPopup popup,
      @NotNull RelativePoint popupPosition,
      @NotNull List<UsageNode> data) {
    JComponent content = popup.getContent();
    Window window = SwingUtilities.windowForComponent(content);
    Dimension d = window.getSize();

    int width = calcMaxWidth(table);
    width = (int) Math.max(d.getWidth(), width);
    Dimension headerSize = ((AbstractPopup) popup).getHeaderPreferredSize();
    width = Math.max((int) headerSize.getWidth(), width);
    width = Math.max(myWidth, width);

    if (myWidth == -1) myWidth = width;
    int newWidth = Math.max(width, d.width + width - myWidth);

    myWidth = newWidth;

    int rowsToShow = Math.min(30, data.size());
    Dimension dimension = new Dimension(newWidth, table.getRowHeight() * rowsToShow);
    Rectangle rectangle = fitToScreen(dimension, popupPosition, table);
    dimension = rectangle.getSize();
    Point location = window.getLocation();
    if (!location.equals(rectangle.getLocation())) {
      window.setLocation(rectangle.getLocation());
    }

    if (!data.isEmpty()) {
      TableScrollingUtil.ensureSelectionExists(table);
    }
    table.setSize(dimension);
    // table.setPreferredSize(dimension);
    // table.setMaximumSize(dimension);
    // table.setPreferredScrollableViewportSize(dimension);

    Dimension footerSize = ((AbstractPopup) popup).getFooterPreferredSize();

    int newHeight =
        (int) (dimension.height + headerSize.getHeight() + footerSize.getHeight())
            + 4 /* invisible borders, margins etc*/;
    Dimension newDim = new Dimension(dimension.width, newHeight);
    window.setSize(newDim);
    window.setMinimumSize(newDim);
    window.setMaximumSize(newDim);

    window.validate();
    window.repaint();
    table.revalidate();
    table.repaint();
  }
Beispiel #5
0
 /** Resets the contents of this CallStackComponent. */
 public void reset() {
   methodNames.removeAllElements();
   callStackTable.revalidate();
   callStackTable.clearSelection();
 }
Beispiel #6
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()));
  }
 /** Called when revalidate is required. */
 public void revalidateChange() {
   segmentTable.revalidate();
   repaint();
 }
 /** Sets the start address. */
 public void setStartAddress(int index) {
   startAddress = index;
   segmentTable.revalidate();
 }