Example #1
0
  private void basketTableMousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_basketTableMousePressed
    /* When the selected row is double clicked. It is removed from the
    arraylist and the table is updated. */
    JTable selected = (JTable) evt.getSource();
    int row = selected.getSelectedRow();

    if (evt.getClickCount() == 2) {
      Inventory.remove(row);
      updateTable();
    } else if (evt.getClickCount() == 1) {
      Pipes[] specificPipe = Inventory.toArray(new Pipes[Inventory.size()]);
      pipe = specificPipe[row];
      getPipeInfo();
    }
  } // GEN-LAST:event_basketTableMousePressed
Example #2
0
  // ----------------------------------------------------------------------
  private boolean findValidPipe() {
    Pipes tempPipe = new TypeZero();
    double inLength = 0.0, inDiameter = 0.0;
    String selectedGrade, selectedColour;
    int inGrade, inColour;
    boolean inInsul, inReinforce, inChem, lengthVal = false, diameterVal = false;

    pipesInfoOutput.setText("");
    boolean pipeVal = false;

    try {
      inLength = Double.parseDouble(lengthTF.getText());
      if (inLength < 0.1 || inLength > 6.0) {
        // ERROR MESSAGES
        validationMessages("Length", 0.1, 6.0);
        lengthTF.setText("");
      } else {
        lengthVal = true;
      }
    } catch (NumberFormatException e) {
      System.err.println(e);
      validationMessages("LengthR", 0, 0);
      lengthTF.setText("");
    }

    try {
      inDiameter = Double.parseDouble(diameterTF.getText());
      if (inDiameter < 1.0 || inDiameter > 35.0) {
        // ERROR MESSAGES
        validationMessages("Diameter", 1.0, 35.0);
        diameterTF.setText("");
      } else {
        diameterVal = true;
      }
    } catch (NumberFormatException e) {
      System.err.println(e);
      validationMessages("DiameterR", 0, 0);
      diameterTF.setText("");
    }

    selectedGrade = gradeCB.getSelectedItem().toString();
    inGrade = Integer.parseInt(selectedGrade);

    selectedColour = colourCB.getSelectedItem().toString();
    if ("None".equals(selectedColour)) {
      inColour = 0;
    } else {
      inColour = Integer.parseInt(selectedColour);
    }

    inInsul = insulCheck.isSelected();

    inReinforce = reinforceCheck.isSelected();

    inChem = chemCheck.isSelected();

    if (lengthVal == true && diameterVal == true) {
      pipe =
          tempPipe.selectPipe(
              inLength, inDiameter, inGrade, inColour, inInsul, inReinforce, inChem);

      if (pipe.getPipeType() == "") {
        pipesInfoOutput.setText("Error: No pipe found in that " + "configuration.");
        pipesInfoOutput.append("\nPlease try a different " + "configuration.");
      } else {
        pipeVal = true;
        getPipeInfo();
      }
    }
    return pipeVal;
  }