Ejemplo n.º 1
0
  public void redrawCommande() {
    itemPanel.removeAll();
    OrderedItem orders[] = commande.getOrders();
    GridBagConstraints c = new GridBagConstraints();
    c.gridy = GridBagConstraints.RELATIVE;
    c.fill = GridBagConstraints.BOTH;
    for (int i = 0; i < orders.length; i++) {
      c.gridx = 0;

      JPanel itemLabelHolder = new JPanel();
      itemLabelHolder.add(new JLabel(orders[i].getItem().getNom()));
      itemLabelHolder.setBackground(Color.WHITE);
      itemLabelHolder.setBorder(BorderFactory.createLineBorder(Color.BLUE));

      itemPanel.add(itemLabelHolder, c);
      c.gridx = 1;
      itemPanel.add(new OrderedItemPanel(orders[i]), c);
      c.gridx = 2;
      JButton killButton = new JButton("\u2716");
      killButton.setBackground(Color.RED);
      killButton.setForeground(Color.WHITE);
      killButton.addActionListener(getHandler());
      killButton.setActionCommand("CDelete" + i);
      JPanel buttonHolder = new JPanel();
      buttonHolder.add(killButton);

      itemPanel.add(buttonHolder, c);
    }
    validate();
    repaint();
  }
Ejemplo n.º 2
0
  CommandPanel(Commande c) {
    super(new BorderLayout());
    commande = c;
    commande.addActionEventListener(this);

    JPanel text = new JPanel();
    text.addMouseListener(this);
    text.add(new JLabel(commande.getName()));
    add(text, BorderLayout.PAGE_START);

    itemList = new JPanel(new GridBagLayout());
    itemList.addMouseListener(this);
    itemList.setBackground(Color.WHITE);

    JScrollPane pane = new JScrollPane(itemList);
    pane.setPreferredSize(new Dimension(95, 100));
    add(pane, BorderLayout.CENTER);
    drawItems();
  }
Ejemplo n.º 3
0
 public void drawItems() {
   itemList.removeAll();
   OrderedItem orders[] = commande.getOrders();
   for (int i = 0; i < orders.length; i++) {
     GridBagConstraints constraintLeft = new GridBagConstraints(),
         constraintRight = new GridBagConstraints();
     constraintLeft.gridx = 0;
     constraintLeft.gridy = GridBagConstraints.RELATIVE;
     constraintLeft.fill = GridBagConstraints.HORIZONTAL;
     constraintRight.gridx = 1;
     constraintRight.gridy = GridBagConstraints.RELATIVE;
     constraintRight.fill = GridBagConstraints.HORIZONTAL;
     String itemText = orders[i].getItem().getNom();
     if (itemText.length() > 15) {
       itemText = itemText.substring(0, 12) + "...";
     }
     JLabel item = new JLabel(itemText);
     JPanel itemTextHolder = new JPanel();
     itemTextHolder.setBorder(BorderFactory.createLineBorder(Color.BLUE));
     itemTextHolder.setBackground(Color.WHITE);
     itemTextHolder.add(item);
     itemList.add(itemTextHolder, constraintLeft);
     Color bg = Color.WHITE;
     String statusIcon = "";
     JLabel itemStatus = new JLabel();
     JPanel statusHolder = new JPanel();
     switch (orders[i].getStatus()) {
       case 0:
         bg = Color.RED;
         statusIcon = "\u2718";
         break;
       case 1:
         bg = Color.YELLOW;
         statusIcon = "\u2718";
         break;
       case 2:
         bg = Color.GREEN;
         statusIcon = "\u2718";
         break;
       case 3:
         bg = Color.GRAY;
         statusIcon = "\u2713";
         break;
     }
     itemStatus.setText(statusIcon);
     statusHolder.setBackground(bg);
     statusHolder.setBorder(BorderFactory.createLineBorder(Color.BLUE));
     statusHolder.add(itemStatus);
     itemList.add(statusHolder, constraintRight);
   }
   validate();
   repaint();
 }
Ejemplo n.º 4
0
  public UICommande(Tablette handler, Commande commande) {
    super(handler);

    this.commande = commande;
    itemPanel = new JPanel(new GridBagLayout());
    JPanel nameHolder = new JPanel();
    nameHolder.add(new JLabel(commande.getName()));
    add(nameHolder);
    JScrollPane itemPanelView = new JScrollPane(itemPanel);
    itemPanelView.setPreferredSize(new Dimension(320, 420));
    itemPanelView.setBorder(null);
    add(itemPanelView);
    JButton addItem = new JButton("Ajouter Item");
    addItem.setActionCommand("CAdd");
    addItem.addActionListener(getHandler());
    JPanel addItemHolder = new JPanel();
    addItemHolder.add(addItem);
    add(addItemHolder);
    redrawCommande();
  }