示例#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
  public void refreshSupplier(boolean remove) {

    if (remove) panel.remove(supplierCombo);

    try {
      model =
          new DefaultComboBoxModel(
              Manager.getInstance().getSupplierManager().getSuppliers().toArray());
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    supplierCombo = new JComboBox(model);
    supplierCombo.setUI(ColorArrowUI.createUI(this));
    supplierCombo.setEditable(true);
    supplierComboField = (JTextField) supplierCombo.getEditor().getEditorComponent();
    supplierComboField.setText("");
    supplierComboField.setOpaque(false);
    supplierComboField.setBorder(BorderFactory.createEmptyBorder());
    supplierComboField.addKeyListener(new ComboKeyHandler(supplierCombo));

    supplierCombo.setFont(new Font("Arial Narrow", Font.PLAIN, 14));
    supplierCombo.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK));
    supplierCombo.setOpaque(false);

    supplierCombo.setSelectedIndex(-1);

    supplierCombo.setVisible(supplierLabel.isVisible());

    supplierCombo.setBounds(85, 56, 220, 20);

    panel.add(supplierCombo);
  }
示例#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);
  }