示例#1
0
  private void showUnrequired(boolean show) {
    supplierLabel.setVisible(show);
    supplierCombo.setVisible(show);

    ponumLabel.setVisible(show);
    po_no.setVisible(show);

    termsLabel.setVisible(show);
    terms.setVisible(show);

    deliveryNumLabel.setVisible(show);
    delivery_no.setVisible(show);

    supplierFwd.setVisible(show);
  }
示例#2
0
  private void setupTable(int y, boolean shownFields) {
    LABEL_Y = y;

    addRow.setBounds(12, LABEL_Y + 5, 16, 16);

    quantitySACKlabel.setBounds(30, LABEL_Y, 77, LABEL_HEIGHT);
    quantityKGLabel.setBounds(107, LABEL_Y, 77, LABEL_HEIGHT);
    kgpersack.setBounds(184, LABEL_Y, 50, LABEL_HEIGHT);
    priceSACK.setBounds(234, LABEL_Y, 85, LABEL_HEIGHT);
    priceKG.setBounds(319, LABEL_Y, 77, LABEL_HEIGHT);
    productLabel.setBounds(396, LABEL_Y, 167, LABEL_HEIGHT);
    deleteLabel.setBounds(563, LABEL_Y, 32, LABEL_HEIGHT);

    productFwd.setBounds(512, LABEL_Y + 5, 16, 16);

    if (shownFields) {
      productsPane.setBounds(31, ITEMS_PANE_Y, ROW_WIDTH, 140);
    } else {
      productsPane.setBounds(31, 75, ROW_WIDTH, 175);
    }
  }
示例#3
0
  private void init() {

    supplierFwd = new SBButton("forward.png", "forward.png", "Add new supplier");
    productFwd = new SBButton("forward.png", "forward.png", "Add new product");
    addRow = new SBButton("add_row.png", "add_row.png", "Add Row");

    supplierFwd.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            // TODO Auto-generated method stub
            Values.addEntryPanel.linkPanel(Values.SUPPLIERS);
          }
        });

    productFwd.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            // TODO Auto-generated method stub
            Values.addEntryPanel.linkPanel(Values.PRODUCTS);
          }
        });

    panel = new JPanel();
    panel.setLayout(null);
    panel.setOpaque(false);

    scrollPane = new JScrollPane();

    showRequired = new FormCheckbox("Show required fields only");

    icon = new ImageIcon("images/util.png");

    date = new SpinnerDate(Values.dateFormat);

    error = new ErrorLabel();
    dateStatus = new IconLabel(new ImageIcon("images/valid_date.png"), Values.VALID_DATE);
    determineDateStatus();

    date.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent arg0) {
            // TODO Auto-generated method stub
            // <<<<<<< HEAD
            // // System.out.println("Date: "+((SpinnerDateModel)
            // // date.getModel()).getDate());
            // validDate = !((SpinnerDateModel)
            // date.getModel()).getDate().after(new Date());
            // if (validDate)
            // dateStatus.setIconToolTip(new ImageIcon("images/valid_date.png"),
            // "This date is valid", true);
            // else
            // dateStatus.setIconToolTip(new
            // ImageIcon("images/invalid_date2.png"), "Future date not allowed",
            // false);
            // System.out.println("Date: "+((SpinnerDateModel)
            // date.getModel()).getDate());
            determineDateStatus();
          }
        });

    termsLabel = new MainFormLabel("Terms:");
    ponumLabel = new MainFormLabel("PO_No:");
    deliveryNumLabel = new MainFormLabel("Delivery No.:");
    dateLabel = new MainFormLabel("Date:");

    receivedByLabel = new MainFormLabel("Received by:");
    supplierLabel = new MainFormLabel("Supplier:");

    receivedBy = new JLabel(Manager.loggedInAccount.getFirstPlusLastName());
    receivedBy.setOpaque(false);
    receivedBy.setFont(new Font("Lucida Grande", Font.ITALIC, 12));
    receivedBy.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, Color.BLACK));
    receivedBy.setHorizontalAlignment(JLabel.CENTER);

    terms = new MainFormField(200);
    po_no = new MainFormField(20);
    delivery_no = new MainFormField(30);

    quantityKGLabel = new TableHeaderLabel("Qtty (kg)");
    productLabel = new TableHeaderLabel("Products");
    quantitySACKlabel = new TableHeaderLabel("Qtty (sack)");
    kgpersack = new TableHeaderLabel("kg / sk");
    priceKG = new TableHeaderLabel("Price (kg)");
    priceSACK = new TableHeaderLabel("Price (sack)");
    deleteLabel = new TableHeaderLabel(icon);

    refreshSupplier(false);

    productsPanel = new JPanel();
    productsPanel.setLayout(null);
    productsPanel.setOpaque(false);

    productsPane = new JScrollPane(productsPanel);

    productsPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    productsPane.setOpaque(false);
    productsPane.getViewport().setOpaque(false);

    showRequired.setBounds(500, 12, 160, 20);
    showRequired.setSelected(true);
    showRequired.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            // TODO Auto-generated method stub
            if (showRequired.isSelected()) {
              showUnrequired(false);
              setupTable(50, false);
            } else {
              showUnrequired(true);
              setupTable(91, true);
            }
          }
        });

    dateLabel.setBounds(49, 12, 40, 20); // 15
    date.setBounds(88, 10, 150, 20);
    dateStatus.setBounds(243, 12, 16, 16);

    receivedByLabel.setBounds(305, 12, 85, 20); // 260
    receivedBy.setBounds(378, 10, 200, 20);

    ponumLabel.setBounds(36, 35, 50, 20);
    po_no.setBounds(86, 32, 70, 20);

    deliveryNumLabel.setBounds(304, 35, 100, 20); // 260
    delivery_no.setBounds(386, 32, 140, 20);

    supplierLabel.setBounds(27, 58, 70, 20);
    supplierFwd.setBounds(308, 58, 16, 16);

    termsLabel.setBounds(335, 58, 50, 20);
    terms.setBounds(385, 56, 210, 20);

    setupTable(50, false);

    addRow.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            rowPanel.add(new RowPanel(productsPanel, Values.ADD));
            productsPanel.add(rowPanel.get(rowPanel.size() - 1));
            alternateRows();

            productsPanel.setPreferredSize(
                new Dimension(330, productsPanel.getComponentCount() * ROW_HEIGHT));
            productsPanel.updateUI();
            productsPanel.revalidate();

            Rectangle rect =
                new Rectangle(0, (int) productsPanel.getPreferredSize().getHeight(), 10, 10);
            productsPanel.scrollRectToVisible(rect);
          }
        });

    showUnrequired(false);

    add(showRequired);

    List<Supplier> suppliers = new ArrayList<Supplier>();
    try {
      suppliers = Manager.getInstance().getSupplierManager().getSuppliers();
      for (Supplier s : suppliers) {
        supplierCombo.addItem(s);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    supplierCombo.setSelectedIndex(-1);

    panel.add(dateLabel);
    panel.add(date);
    panel.add(dateStatus);

    panel.add(receivedByLabel);
    panel.add(receivedBy);

    panel.add(ponumLabel);
    panel.add(po_no);

    panel.add(deliveryNumLabel);
    panel.add(delivery_no);

    // panel.add(issuedOnLabel);
    // panel.add(issueDate);

    panel.add(supplierLabel);
    panel.add(supplierFwd);

    panel.add(termsLabel);
    panel.add(terms);

    panel.add(productFwd);
    panel.add(quantityKGLabel);
    panel.add(quantitySACKlabel);
    panel.add(kgpersack);
    panel.add(priceKG);
    panel.add(priceSACK);
    panel.add(productLabel);
    panel.add(deleteLabel);

    panel.add(addRow);

    panel.add(productsPane);

    scrollPane.setViewportView(panel);
    scrollPane.setOpaque(false);
    scrollPane.getViewport().setOpaque(false);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());

    scrollPane.setBounds(20, 42, 630, 310);

    add(error);
    add(scrollPane);
  }