コード例 #1
0
ファイル: Gutachten.java プロジェクト: jannyp/thera-pi-2
 private void doPdfStarten(int art) {
   int row = tabbericht.getSelectedRow();
   if (row < 0) {
     JOptionPane.showMessageDialog(null, "Kein Bericht für Datenübernahme ausgewählt");
     return;
   }
   new LadeProg(
       Reha.proghome
           + "PDFLoader.jar "
           + Integer.toString(art)
           + " "
           + tabbericht.getValueAt(row, 0).toString()
           + " "
           + SystemConfig.PDFformularPfad
           + " "
           + Reha.proghome
           + "ini/"
           + Reha.aktIK
           + "/fremdprog.ini"
           + " "
           + Reha.thisClass.patpanel.patDaten.get(29)
           + " "
           + Reha.proghome
           + "ini/"
           + Reha.aktIK
           + "/rehajava.ini");
 }
コード例 #2
0
ファイル: Gutachten.java プロジェクト: jannyp/thera-pi-2
 private void doBerichtEdit() {
   int row = tabbericht.getSelectedRow();
   // System.out.println("in doBerichtEdit");
   if (row < 0) {
     // System.out.println("keine Zeile vorhanden also return");
     return;
   }
   String bertyp = (String) tabbericht.getValueAt(row, 1);
   int berid = Integer.parseInt(tabbericht.getValueAt(row, 0).toString());
   String berempfaenger = (String) tabbericht.getValueAt(row, 4);
   Reha.thisClass.progLoader.GutachenFenster(
       1, Reha.thisClass.patpanel.aktPatID, berid, bertyp, false, berempfaenger, -1);
   // ProgLoader.GutachenFenster(1,Reha.thisClass.patpanel.aktPatID
   // ,berid,bertyp,false,berempfaenger );
   // ProgLoader.InternalGut2();
 }
コード例 #3
0
 private void forwardEventToButton(MouseEvent e) {
   if (e.getID() == e.MOUSE_CLICKED) {
     JXTable table = ((JXTable) e.getSource());
     Integer row = table.rowAtPoint(e.getPoint());
     table.getColumnExt("Parameter Object").setVisible(true);
     this.parent.actionHandler.goToParameter((Parameter) table.getValueAt(row, 5));
   }
   return;
 }
コード例 #4
0
  @Override
  public void valueChanged(ListSelectionEvent arg) {

    if (!arg.getValueIsAdjusting() && this.acceptListEvents) {
      int col = combinedRulesTable.getSelectedColumn();
      int row = combinedRulesTable.getSelectedRow();
      consoleLogger.debug("Selected ROW: " + row + " - COL: " + col);
      String rule =
          String.valueOf(
              combinedRulesTable.getValueAt(row, CombinedRulesTableColumns.RULE_NUMBER.ordinal()));
      //   System.out.println("rule:::::"+rule);
      this.firePropertyChange(FIRING_PROPERTY, this.selectedCombinedRule, rule);
      this.selectedCombinedRule = rule;
    }
  }
コード例 #5
0
  public void propertyChange(PropertyChangeEvent event) {
    String prop = event.getPropertyName();

    if (prop.equalsIgnoreCase(SequiturMessage.MAIN_CHART_CLICKED_MESSAGE)) {
      String rule = (String) event.getNewValue();
      System.out.println("CombinedRulesPanel.propertyChange.rule:     " + rule);
      for (int row = 0; row <= combinedRulesTable.getRowCount() - 1; row++) {
        for (int col = 0; col <= combinedRulesTable.getColumnCount() - 1; col++) {
          if (rule.equals(
              chartData.convert2OriginalSAXAlphabet(
                  '1', combinedRulesTable.getValueAt(row, col).toString()))) {
            combinedRulesTable.scrollRectToVisible(combinedRulesTable.getCellRect(row, 0, true));
            combinedRulesTable.setRowSelectionInterval(row, row);
          }
        }
      }
    }
  }
コード例 #6
0
  private void okActionPerformed(java.awt.event.ActionEvent evt) {
    if (smtp.getText().trim().isEmpty()) {
      CommonFunctions.showErrorMessage(this, "You must enter a SMTP server.");
      return;
    } else if (smtpUsername.getText().trim().isEmpty()) {
      CommonFunctions.showErrorMessage(this, "You must enter the SMTP username.");
      return;
    } else {
      try {
        int port = Integer.parseInt(smtpPort.getText());
        if (port <= 0) throw new NumberFormatException();

        new InternetAddress(email.getText()).validate();
      } catch (NumberFormatException e) {
        CommonFunctions.showErrorMessage(this, "You must enter a valid SMTP port.");
        return;
      } catch (AddressException e) {
        CommonFunctions.showErrorMessage(this, "You must enter a valid source email address.");
        return;
      }
    }

    retval = 0;

    List<Student> selectedStudents = new ArrayList();
    for (int i = 0; i < studentsTbl.getRowCount(); i++) {
      if ((boolean) studentsTbl.getValueAt(i, 0)) {
        selectedStudents.add(students.get(studentsTbl.convertRowIndexToModel(i)));
      }
    }

    output =
        new Object[] {
          email.getText(),
          smtp.getText(),
          smtpPort.getText(),
          smtpUsername.getText(),
          new String(smtpPassword.getPassword()),
          selectedStudents
        };

    setVisible(false);
  }
コード例 #7
0
ファイル: Gutachten.java プロジェクト: jannyp/thera-pi-2
  @Override
  public void actionPerformed(ActionEvent arg0) {
    String cmd = arg0.getActionCommand();
    if (cmd.equals("gutneu")) {
      if (!Rechte.hatRecht(Rechte.Gutachten_anlegen, true)) {
        return;
      }
      final JComponent comp = ((JComponent) arg0.getSource());
      new SwingWorker<Void, Void>() {
        @Override
        protected Void doInBackground() throws Exception {
          try {
            JRtaTextField tf = new JRtaTextField("nix", false);
            // System.out.println("in GutachtenWahl");
            GutachtenWahl gwahl =
                new GutachtenWahl(
                    (Point) comp.getLocationOnScreen(), tf, "Neues Gutachten erstellen");
            // System.out.println("Aufruf des Focus***********");
            gwahl.setzeFocus();
            gwahl.setVisible(true);
            // gwahl.setModal(true);

            // System.out.println("Der Rückgabewert der Auswahl = "+tf.getText() );
            if (tf.getText().equalsIgnoreCase("ebericht")) {
              Reha.thisClass.progLoader.GutachenFenster(
                  1, Reha.thisClass.patpanel.aktPatID, -1, "E-Bericht", true, "", -1);
              // ProgLoader.GutachenFenster(1,Reha.thisClass.patpanel.aktPatID
              // ,-1,"E-Bericht",true,"" );
              return null;
            }
            if (tf.getText().equalsIgnoreCase("nachsorge")) {
              Reha.thisClass.progLoader.GutachenFenster(
                  1, Reha.thisClass.patpanel.aktPatID, -1, "Nachsorge", true, "", -1);
              // ProgLoader.GutachenFenster(1,Reha.thisClass.patpanel.aktPatID
              // ,-1,"Nachsorge",true,"" );
              return null;
            }
            gwahl = null;
          } catch (Exception ex) {
            ex.printStackTrace();
          }

          return null;
        }
      }.execute();
      return;
    }
    if (cmd.equals("gutedit")) {
      if (!Rechte.hatRecht(Rechte.Gutachten_editvoll, true)) {
        return;
      }
      doBerichtEdit();
      return;
    }
    if (cmd.equals("gutdelete")) {
      if (aktPanel.equals("leerPanel")) {
        JOptionPane.showMessageDialog(
            null,
            "Oh Herr laß halten...\n\n"
                + "....und welches der nicht vorhandenen Gutachten möchten Sie bitteschön löschen....");
        return;
      }
      if (!Rechte.hatRecht(Rechte.Gutachten_delete, true)) {
        return;
      }
      int currow = tabbericht.getSelectedRow();
      // int anzrow = tabbericht.getRowCount();
      if (currow == -1) {
        JOptionPane.showMessageDialog(null, "Kein Gutachten zum -> löschen <- ausgewählt");
        return;
      }
      String berichtid = (String) tabbericht.getValueAt(currow, 0);
      int frage =
          JOptionPane.showConfirmDialog(
              null,
              "Wollen Sie das Gutachten mit der ID:" + berichtid + " wirklich löschen?",
              "Wichtige Benutzeranfrage",
              JOptionPane.YES_NO_OPTION);
      if (frage == JOptionPane.NO_OPTION) {
        return;
      }
      String sqlcmd = "delete from berhist where berichtid='" + berichtid + "'";
      new ExUndHop().setzeStatement(sqlcmd);
      sqlcmd = "delete from bericht2 where berichtid='" + berichtid + "'";
      new ExUndHop().setzeStatement(sqlcmd);
      sqlcmd = "delete from bericht2ktl where berichtid='" + berichtid + "'";
      new ExUndHop().setzeStatement(sqlcmd);

      currow = TableTool.loescheRow(tabbericht, Integer.valueOf(currow));
      int uebrig = tabbericht.getRowCount();

      anzahlGutachten.setText("Anzahl Gutachten: " + Integer.toString(uebrig));
      Reha.thisClass.patpanel.getTab().setTitleAt(4, macheHtmlTitel(uebrig, "Gutachten"));
      if (uebrig <= 0) {
        holeGutachten(Reha.thisClass.patpanel.patDaten.get(29), "");
      } else {
      }

      return;
    }
    if (cmd.equals("guttools")) {
      new ToolsDlgGutachten("", gutbut[3].getLocationOnScreen());
      return;
    }
  }
コード例 #8
0
  @Override
  public void setListeners() {
    iSearchField.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            isAddingRows = true;
            iSearchField.setText(Formatter.makeUpperCase(iSearchField.getText()));
            String input = iSearchField.getText();
            List<Products> productWithID =
                products
                    .stream()
                    .filter(
                        (p) ->
                            (p.getAddmotoCode().toUpperCase().contains(input.toUpperCase())
                                    || (p.getDescription()
                                            + " "
                                            + p.getCharacteristics()
                                            + p.getMotors())
                                        .replaceAll("\\s+", " ")
                                        .trim()
                                        .toUpperCase()
                                        .contains(input.toUpperCase()))
                                || getProductLineName(p.getProductLineID())
                                    .toUpperCase()
                                    .contains(input.toUpperCase()))
                    .collect(Collectors.toList());

            while (tableModel.getRowCount() > 0) {
              tableModel.removeRow(0);
            }
            for (Products product : productWithID) {
              tableModel.addRow(
                  new Object[] {
                    String.valueOf(product.getProductID()),
                    product.getAddmotoCode(),
                    productLineMap.get(product.getProductLineID()),
                    (product.getDescription()
                            + " "
                            + product.getCharacteristics()
                            + " "
                            + product.getMotors())
                        .replaceAll("\\s+", " ")
                        .trim(),
                    "PhP " + Formatter.format(product.getUnitPrice()),
                    "PhP " + Formatter.format(product.getSellingPrice())
                  });
            }
            isAddingRows = false;
          }
        });

    iAddNewPLine.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String newProductLine =
                JOptionPane.showInputDialog(
                    null, "Product Line Name:", "New Product Line", JOptionPane.QUESTION_MESSAGE);

            try {
              if (newProductLine.equals("")) {
                JOptionPane.showMessageDialog(
                    null,
                    "You cannot create an empty product line name.",
                    "Error",
                    JOptionPane.ERROR_MESSAGE);
              } else {
                int rows = model.insertNewProductLine(newProductLine);
                if (rows != 0) {
                  JOptionPane.showMessageDialog(
                      null,
                      "Product Line list updated.",
                      "Success",
                      JOptionPane.INFORMATION_MESSAGE);
                  populate();
                } else {
                  JOptionPane.showMessageDialog(
                      null,
                      "Product Line may be existing already!",
                      "Error",
                      JOptionPane.ERROR_MESSAGE);
                }
              }
            } catch (Exception ex) {

            }
          }
        });

    iShowHistory.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            JOptionPane.showMessageDialog(view, "Clicked");
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iShowHistory);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setWhiteForeground(iShowHistory);
          }
        });

    iSellingPrice.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            iSellingPrice.selectAll();
          }

          @Override
          public void focusLost(FocusEvent e) {}
        });

    iSellingPrice.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE)
                || (ch == '.'))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iUnitCost.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            iUnitCost.selectAll();
          }

          @Override
          public void focusLost(FocusEvent e) {}
        });

    iUnitCost.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE)
                || (ch == '.'))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iQtyThreshold.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            iQtyThreshold.selectAll();
          }

          @Override
          public void focusLost(FocusEvent e) {}
        });

    iSellingPrice.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE)
                || (ch == '.'))) {
              tk.beep();
              e.consume();
            } else if ((ch == '.' && iSellingPrice.getText().contains("."))
                || (ch == '.' && iSellingPrice.getText().equals(""))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iQtyThreshold.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iEditUpdateRSP.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (!iAddMotoCode.getText().equals("")) {
              if (iEditUpdateRSP.getText().equals("Edit")) {
                sellingPriceValue = iSellingPrice.getText();
                setToDefault(iSellingPrice, iEditUpdateRSP, iCancelRSP, false);
              } else if (iEditUpdateRSP.getText().equals("Update")) {
                if (iSellingPrice.getText().equals("")
                    || iUnitCost.getText().equals("")
                    || iSellingPrice.getText().split("\\.")[1].length() > 2
                    || iUnitCost.getText().split("\\.")[1].length() > 2) {
                  JOptionPane.showMessageDialog(
                      null,
                      "There are empty fields or number format is invalid",
                      "Error",
                      JOptionPane.ERROR_MESSAGE);
                  iSellingPrice.setText(String.valueOf(sellingPriceValue));
                } else {
                  double sellingPrice = Double.parseDouble(iSellingPrice.getText());
                  double unitPrice = Double.parseDouble(iUnitCost.getText());

                  if (sellingPrice >= unitPrice * 1.30) {
                    int option =
                        JOptionPane.showConfirmDialog(
                            null,
                            "Are you sure you want to proceed with the update?",
                            "Confirm",
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.QUESTION_MESSAGE);
                    if (option == JOptionPane.YES_OPTION) {
                      int itemID = Integer.parseInt(iItemNumber.getText());
                      int updatedRow = model.updateSellingPrice(itemID, sellingPrice);
                      if (updatedRow != 0) {
                        JOptionPane.showMessageDialog(
                            null,
                            "Product selling price updated!",
                            "Success",
                            JOptionPane.INFORMATION_MESSAGE);
                        setIndexZero();
                        setDefaultViews();
                        isAddingRows = true;
                        populate();
                        isAddingRows = false;
                      } else {
                        JOptionPane.showMessageDialog(
                            null,
                            "There is an error while updating item selling price.",
                            "Error",
                            JOptionPane.ERROR_MESSAGE);
                      }
                    }
                  } else {
                    JOptionPane.showMessageDialog(
                        null,
                        "You must have atleast 30% profit for this item.",
                        "Error",
                        JOptionPane.ERROR_MESSAGE);
                  }
                }
                setToDefault(iSellingPrice, iEditUpdateRSP, iCancelRSP, true);
              }
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iEditUpdateRSP);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iEditUpdateRSP);
          }
        });

    iUnitCost.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE))) {
              tk.beep();
              e.consume();
            } else if ((ch == '.' && iUnitCost.getText().contains("."))
                || (ch == '.' && iUnitCost.getText().equals(""))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iEditUpdateUC.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (!iAddMotoCode.getText().equals("")) {
              if (iEditUpdateUC.getText().equals("Edit")) {
                unitCostValue = iUnitCost.getText();
                setToDefault(iUnitCost, iEditUpdateUC, iCancelUC, false);
              } else if (iEditUpdateUC.getText().equals("Update")) {
                if (iSellingPrice.getText().equals("")
                    || iUnitCost.getText().equals("")
                    || iSellingPrice.getText().split("\\.")[1].length() > 2
                    || iUnitCost.getText().split("\\.")[1].length() > 2) {
                  JOptionPane.showMessageDialog(
                      null,
                      "There are empty fields or number format is invalid",
                      "Error",
                      JOptionPane.ERROR_MESSAGE);
                  iUnitCost.setText(String.valueOf(unitCostValue));
                } else {
                  double sellingPrice = Double.parseDouble(iSellingPrice.getText());
                  double unitPrice = Double.parseDouble(iUnitCost.getText());

                  if (sellingPrice >= unitPrice * 1.30) {
                    int option =
                        JOptionPane.showConfirmDialog(
                            null,
                            "Are you sure you want to proceed with the update?",
                            "Confirm",
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.QUESTION_MESSAGE);
                    if (option == JOptionPane.YES_OPTION) {
                      int itemID = Integer.parseInt(iItemNumber.getText());
                      int updatedRow = model.updateUnitPrice(itemID, unitPrice);
                      if (updatedRow != 0) {
                        JOptionPane.showMessageDialog(
                            null,
                            "Product unit price updated!",
                            "Success",
                            JOptionPane.INFORMATION_MESSAGE);
                        setIndexZero();
                        setDefaultViews();
                        isAddingRows = true;
                        populate();
                        isAddingRows = false;
                      } else {
                        JOptionPane.showMessageDialog(
                            null,
                            "There is an error while updating item unit price.",
                            "Error",
                            JOptionPane.ERROR_MESSAGE);
                      }
                    }
                  } else {
                    JOptionPane.showMessageDialog(
                        null,
                        "You must have atleast 30% profit for this item.",
                        "Error",
                        JOptionPane.ERROR_MESSAGE);
                  }
                }
                setToDefault(iUnitCost, iEditUpdateUC, iCancelUC, true);
              }
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iEditUpdateUC);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iEditUpdateUC);
          }
        });

    iQtyThreshold.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iEditUpdateQT.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (!iAddMotoCode.getText().equals("")) {
              if (iEditUpdateQT.getText().equals("Edit")) {
                qtyThresholdValue = iQtyThreshold.getText();
                setToDefault(iQtyThreshold, iEditUpdateQT, iCancelQT, false);
              } else if (iEditUpdateQT.getText().equals("Update")) {
                if (iQtyThreshold.getText().equals("")) {
                  JOptionPane.showMessageDialog(
                      null,
                      "There are empty fields or number format is invalid",
                      "Error",
                      JOptionPane.ERROR_MESSAGE);
                  iQtyThreshold.setText(String.valueOf(qtyThresholdValue));
                } else {
                  int threshold = Integer.parseInt(iQtyThreshold.getText());
                  int option =
                      JOptionPane.showConfirmDialog(
                          null,
                          "Are you sure you want to proceed with the update?",
                          "Confirm",
                          JOptionPane.YES_NO_OPTION,
                          JOptionPane.QUESTION_MESSAGE);
                  if (option == JOptionPane.YES_OPTION) {
                    int itemID = Integer.parseInt(iItemNumber.getText());
                    int updatedRow = model.updateThreshold(itemID, threshold);
                    if (updatedRow != 0) {
                      JOptionPane.showMessageDialog(
                          null,
                          "Product threshold count updated!",
                          "Success",
                          JOptionPane.INFORMATION_MESSAGE);
                      setIndexZero();
                      setDefaultViews();
                      isAddingRows = true;
                      populate();
                      isAddingRows = false;
                    } else {
                      JOptionPane.showMessageDialog(
                          null,
                          "There is an error while updating item threshold count.",
                          "Error",
                          JOptionPane.ERROR_MESSAGE);
                    }
                  }
                }
                setToDefault(iQtyThreshold, iEditUpdateQT, iCancelQT, true);
              }
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iEditUpdateQT);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iEditUpdateQT);
          }
        });

    iCancelRSP.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            iSellingPrice.setText(sellingPriceValue);
            setToDefault(iSellingPrice, iEditUpdateRSP, iCancelRSP, true);
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iCancelRSP);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iCancelRSP);
          }
        });

    iCancelUC.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            iUnitCost.setText(unitCostValue);
            setToDefault(iUnitCost, iEditUpdateUC, iCancelUC, true);
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iCancelUC);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iCancelUC);
          }
        });

    iCancelQT.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            iQtyThreshold.setText(qtyThresholdValue);
            setToDefault(iQtyThreshold, iEditUpdateQT, iCancelQT, true);
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iCancelQT);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iCancelQT);
          }
        });

    selectionModel.addListSelectionListener(
        (ListSelectionEvent e) -> {
          if (e.getValueIsAdjusting()) {
            return;
          }
          if (!isAddingRows) {
            int row = iProductsTable.getSelectedRow();
            int ID = Integer.parseInt((String) iProductsTable.getValueAt(row, 0));
            System.out.println("ID -> " + ID);
            iProductsTable.scrollRowToVisible(row);
            showProductDetails(ID);
          }
        });

    iSellingPriceText.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE)
                || (ch == '.'))) {
              tk.beep();
              e.consume();
            } else if ((ch == '.' && iSellingPriceText.getText().contains("."))
                || (ch == '.' && iSellingPriceText.getText().equals(""))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iUnitPriceText.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE)
                || (ch == '.'))) {
              tk.beep();
              e.consume();
            } else if ((ch == '.' && iUnitPriceText.getText().contains("."))
                || (ch == '.' && iUnitPriceText.getText().equals(""))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iQtyText.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iThresholdText.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iAddNew.addActionListener(
        (ActionEvent e) -> {
          int choice =
              JOptionPane.showOptionDialog(
                  view,
                  addItem,
                  "ADD Moto - Motorcycle Parts and Accessories",
                  JOptionPane.OK_CANCEL_OPTION,
                  JOptionPane.PLAIN_MESSAGE,
                  null,
                  null,
                  null);
          if (choice == JOptionPane.OK_OPTION) {
            String supplierName = getFormattedString((String) iSupplierList.getSelectedItem());
            String productLine = getFormattedString((String) iProductLineList.getSelectedItem());
            String supplierCode = getFormattedString(iSupplierCodeText.getText());
            String unitPrice = getFormattedString(iUnitPriceText.getText());
            String sellingPrice = getFormattedString(iSellingPriceText.getText());
            String qtyOnHand = getFormattedString(iQtyText.getText());
            String threshold = getFormattedString(iThresholdText.getText());
            String characteristics = getFormattedString(iCharacteristics.getText());
            String _model = getFormattedString(iModelText.getText());
            String description = getFormattedString(iDescriptionText.getText());

            if (supplierName.isEmpty()
                || productLine.isEmpty()
                || supplierCode.isEmpty()
                || unitPrice.isEmpty()
                || sellingPrice.isEmpty()
                || qtyOnHand.isEmpty()
                || threshold.isEmpty()
                || characteristics.isEmpty()
                || _model.isEmpty()
                || description.isEmpty()) {
              JOptionPane.showMessageDialog(
                  view, "All fields must not be empty!", "Error", JOptionPane.ERROR_MESSAGE);
            } else {
              Products product =
                  new Products(
                      productLine.toUpperCase().substring(0, 2) + "AD" + supplierCode,
                      supplierCode,
                      parseInt(qtyOnHand),
                      parseDouble(unitPrice),
                      parseDouble(sellingPrice),
                      parseDouble(sellingPrice) - parseDouble(unitPrice),
                      parseInt(threshold),
                      null,
                      description,
                      characteristics,
                      _model,
                      getKeybyValue_p(productLine),
                      getKeybyValue_s(supplierName));
              System.out.println(product.toString());
              int returnValue = model.addNewProduct(product);
              if (returnValue == 0) {
                JOptionPane.showMessageDialog(
                    view, "There must be some kind of error.", "Error", JOptionPane.ERROR_MESSAGE);
              } else {
                JOptionPane.showMessageDialog(
                    view,
                    "Successfully added new product!",
                    "Success",
                    JOptionPane.INFORMATION_MESSAGE);
                setIndexZero();
                setDefaultViews();
                isAddingRows = true;
                repopulateTable();
                isAddingRows = false;
              }
            }
          }
        });
  }