Example usage for javax.swing.table DefaultTableModel addRow

List of usage examples for javax.swing.table DefaultTableModel addRow

Introduction

In this page you can find the example usage for javax.swing.table DefaultTableModel addRow.

Prototype

public void addRow(Object[] rowData) 

Source Link

Document

Adds a row to the end of the model.

Usage

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void btnWeightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWeightActionPerformed
    Boolean isSave = false;//  w ww  .  j  a  va  2 s .  c  om
    String staff = "";
    String pass = "NO";
    if (this.currentEntry != null) {
        if (AppHelper.CheckTwoDigit(this.txtWeight.getText())) {
            if (recordValidationService.Validate(currentEntry, RecordKey.PRODUCT_WEIGHT,
                    Float.parseFloat(this.txtWeight.getText()))) {
                isSave = true;
                pass = "YES";
            } else {
                if (!this.txtWeightStaff.getText().equals("")) {
                    isSave = true;

                } else {
                    JOptionPane.showMessageDialog(this,
                            "the value is not within the range, please entry technician name.", "Warning",
                            JOptionPane.OK_OPTION);
                    this.labWeightStaff.setVisible(true);
                    this.txtWeightStaff.setVisible(true);
                }
            }
            staff = this.txtWeightStaff.getText();
            this.txtWeightStaff.setText("");
        } else {
            JOptionPane.showMessageDialog(this, "Please entry the valid number like (123.45).", "Warning",
                    JOptionPane.OK_OPTION);
        }

        if (isSave) {
            DefaultTableModel model = (DefaultTableModel) this.tblWeight.getModel();
            Date now = new Date();
            String time = new SimpleDateFormat("HH:mm").format(now);
            Float value = Float.parseFloat(this.txtWeight.getText());
            model.addRow(new Object[] { time, value, pass, staff });
            ((AbstractTableModel) this.tblWeight.getModel()).fireTableDataChanged();
            datasetWeight.addValue(value, "Weight", time);
            this.labWeightStaff.setVisible(false);
            this.txtWeightStaff.setVisible(false);
            this.txtWeight.setText("");
            UpdateEntryData(now, value, RecordKey.PRODUCT_WEIGHT, staff, pass, "");
        }
    }
}

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void btnCycleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCycleActionPerformed
    Boolean isSave = false;/*from  w w  w  . jav  a  2 s .  c  om*/
    String staff = "";
    String pass = "NO";
    if (this.currentEntry != null) {
        if (!this.txtCycle.getText().equals("")) {
            isSave = true;
            pass = "YES";
            staff = txtCycleStaff.getText();
            this.txtCycleStaff.setText("");
        } else {
            JOptionPane.showMessageDialog(this, "Please entry the value of cycle time.", "Warning",
                    JOptionPane.OK_OPTION);
        }

        if (isSave) {
            DefaultTableModel model = (DefaultTableModel) this.tblCycle.getModel();
            Date now = new Date();
            String time = new SimpleDateFormat("HH:mm").format(now);
            Float value = (float) 0;
            String stringValue = this.txtCycle.getText();
            model.addRow(new Object[] { time, stringValue, staff });
            ((AbstractTableModel) this.tblCycle.getModel()).fireTableDataChanged();
            this.txtCycle.setText("");
            UpdateEntryData(now, value, RecordKey.CYCLE, staff, pass, stringValue);
        }
    }
}

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void btnTapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTapActionPerformed
    Boolean isSave = false;/*from ww w. j  a v a  2s.  com*/
    String staff = "";
    String pass = "NO";
    if (this.currentEntry != null) {
        if (this.cbTap.getSelectedIndex() != 0) {
            if (recordValidationService.Validate(currentEntry, RecordKey.TAP_POSITION,
                    (float) this.cbTap.getSelectedIndex())) {
                isSave = true;
                pass = "YES";
            } else {
                String checker = JOptionPane.showInputDialog(this,
                        "the value is not within the range, please entry technician name.", "Warning",
                        JOptionPane.OK_OPTION);
                pass = "NO(" + checker + ")";
                if (!checker.equals("")) {
                    isSave = true;
                }
            }
            staff = txtTapStaff.getText();
            this.txtTapStaff.setText("");
        } else {
            JOptionPane.showMessageDialog(this, "Please select the tap position.", "Warning",
                    JOptionPane.OK_OPTION);
        }

        if (isSave) {
            DefaultTableModel model = (DefaultTableModel) this.tblTap.getModel();
            Date now = new Date();
            String time = new SimpleDateFormat("HH:mm").format(now);
            Float value = (float) this.cbTap.getSelectedIndex();
            String stringValue = this.cbTap.getSelectedItem().toString();
            model.addRow(new Object[] { time, stringValue, pass, staff });
            ((AbstractTableModel) this.tblTap.getModel()).fireTableDataChanged();
            datasetTap.addValue(value, "Tap", time);
            this.cbTap.setSelectedIndex(0);
            UpdateEntryData(now, value, RecordKey.TAP_POSITION, staff, pass, stringValue);
        }
    }
}

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void btnBungActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBungActionPerformed
    Boolean isSave = false;//  w  w  w.j a  v  a  2 s .com
    String staff = "";
    String pass = "NO";
    if (this.currentEntry != null) {
        if (this.cbBung.getSelectedIndex() != 0) {
            if (this.cbBung.getSelectedIndex() != 1) {
                isSave = true;
                pass = "YES";
            } else {
                String checker = JOptionPane.showInputDialog(this,
                        "the value is not within the range, please entry technician name.", "Warning",
                        JOptionPane.OK_OPTION);
                pass = "NO(" + checker + ")";
                if (!checker.equals("")) {
                    isSave = true;
                }
            }
            staff = txtBungStaff.getText();
            this.txtBungStaff.setText("");
        } else {
            JOptionPane.showMessageDialog(this, "Please select the tap position.", "Warning",
                    JOptionPane.OK_OPTION);
        }

        if (isSave) {
            DefaultTableModel model = (DefaultTableModel) this.tblBung.getModel();
            Date now = new Date();
            String time = new SimpleDateFormat("HH:mm").format(now);
            Float value = (float) this.cbBung.getSelectedIndex();
            String stringValue = this.cbBung.getSelectedItem().toString();
            model.addRow(new Object[] { time, stringValue, pass, staff });
            ((AbstractTableModel) this.tblBung.getModel()).fireTableDataChanged();
            this.cbBung.setSelectedIndex(0);
            UpdateEntryData(now, value, RecordKey.BUNG, staff, pass, stringValue);
        }
    }
}

From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java

private void targetFromInternalClipboardAction() {
    String data = "";
    try {/*from w ww .j  a  va 2s.  c om*/
        data = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null)
                .getTransferData(DataFlavor.stringFlavor);

        String[] lines = data.split("\n");
        int cnt = 0;
        DefaultTableModel theModel = (DefaultTableModel) jVictimTable.getModel();
        for (String line : lines) {
            String[] split = line.split(";");
            Village v = DataHolder.getSingleton().getVillagesById().get(Integer.parseInt(split[0]));
            if (v != null) {
                boolean added = false;
                for (int i = 0; i < theModel.getRowCount(); i++) {
                    if (jVictimTable.getValueAt(i, 1).equals(v)) {
                        Integer amount = (Integer) jVictimTable.getValueAt(i, 3);
                        jVictimTable.setValueAt(amount + 1, i, 3);
                        cnt++;
                        added = true;
                        break;
                    }
                }
                if (!added) {
                    Boolean fake = Boolean.parseBoolean(split[1]);
                    Integer attacks = Integer.parseInt(split[2]);
                    if (attacks != null) {
                        theModel.addRow(new Object[] { v.getTribe(), v, fake, attacks, 0 });
                        cnt++;
                    }
                }
            }
        }
        showSuccess(cnt + ((cnt == 1) ? " Eintrag eingefgt" : " Eintrge eingefgt"));
    } catch (UnsupportedFlavorException ufe) {
        logger.error("Failed to copy data from internal clipboard", ufe);
        showError("Fehler beim Einfgen aus der Zwischenablage");
    } catch (IOException ioe) {
        logger.error("Failed to copy data from internal clipboard", ioe);
        showError("Fehler beim Einfgen aus der Zwischenablage");
    } catch (NumberFormatException nfe) {
        //invalid paste, try village parser       
        List<Village> villages = PluginManager.getSingleton().executeVillageParser(data);
        if (!villages.isEmpty()) {
            addTargetVillages(villages);
        } else {
            showInfo("Keine verwendbaren Daten in der Zwischenablage gefunden");
        }
    }
}

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void btnBoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBoreActionPerformed
    Boolean isSave = false;//  w  w w .  j av a 2s .co m
    String staff = "";
    String pass = "NO";
    String checker = "";
    if (this.currentEntry != null) {
        if (AppHelper.CheckTwoDigit(this.txtBore1.getText()) && AppHelper.CheckTwoDigit(this.txtBore2.getText())
                && AppHelper.CheckTwoDigit(this.txtNeck.getText())) {
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE1,
                    Float.parseFloat(this.txtBore1.getText()))
                    && recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE2,
                            Float.parseFloat(this.txtBore2.getText()))
                    && recordValidationService.Validate(currentEntry, RecordKey.THREAD_NECK,
                            Float.parseFloat(this.txtNeck.getText()))) {
                isSave = true;

            } else {
                checker = JOptionPane.showInputDialog(this,
                        "the value is not within the range, please entry technician name.", "Warning",
                        JOptionPane.OK_OPTION);

                if (!checker.equals("")) {
                    isSave = true;
                }
            }
            staff = this.txtBoreStaff.getText();
            this.txtBoreStaff.setText("");
        } else {
            JOptionPane.showMessageDialog(this, "Please entry the valid number like (123.45).", "Warning",
                    JOptionPane.OK_OPTION);
        }

        if (isSave) {
            DefaultTableModel model = (DefaultTableModel) this.tblBore.getModel();
            Date now = new Date();
            String time = new SimpleDateFormat("HH:mm").format(now);
            Float valueBore1 = Float.parseFloat(this.txtBore1.getText());
            Float valueBore2 = Float.parseFloat(this.txtBore2.getText());
            Float valueNeck = Float.parseFloat(this.txtNeck.getText());
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE1, valueBore1)) {
                pass = "YES";
            } else {
                pass = "NO(" + checker + ")";
            }
            model.addRow(new Object[] { time, RecordKey.THREAD_BORE1, valueBore1, pass, staff });
            UpdateEntryData(now, valueBore1, RecordKey.THREAD_BORE1, staff, pass, "");
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE2, valueBore2)) {
                pass = "YES";
            } else {
                pass = "NO(" + checker + ")";
            }
            model.addRow(new Object[] { time, RecordKey.THREAD_BORE2, valueBore2, pass, staff });
            UpdateEntryData(now, valueBore2, RecordKey.THREAD_BORE2, staff, pass, "");
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_NECK, valueNeck)) {
                pass = "YES";
            } else {
                pass = "NO(" + checker + ")";
            }
            model.addRow(new Object[] { time, RecordKey.THREAD_NECK, valueNeck, pass, staff });
            UpdateEntryData(now, valueNeck, RecordKey.THREAD_NECK, staff, pass, "");

            ((AbstractTableModel) this.tblBore.getModel()).fireTableDataChanged();
            this.txtBore1.setText("");
            this.txtBore2.setText("");
            this.txtNeck.setText("");
            //

        }
    }
}

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void btnBore1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBore1ActionPerformed
    Boolean isSave = false;/* w  w  w  .j av a 2  s . c o  m*/
    String staff = "";
    String pass = "NO";
    String checker = "";
    if (this.currentEntry != null) {
        if (AppHelper.CheckTwoDigit(this.txtBore11.getText())
                && AppHelper.CheckTwoDigit(this.txtBore21.getText())
                && AppHelper.CheckTwoDigit(this.txtNeck1.getText())) {
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE1_2,
                    Float.parseFloat(this.txtBore11.getText()))
                    && recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE2_2,
                            Float.parseFloat(this.txtBore21.getText()))
                    && recordValidationService.Validate(currentEntry, RecordKey.THREAD_NECK_2,
                            Float.parseFloat(this.txtNeck1.getText()))) {
                isSave = true;

            } else {
                checker = JOptionPane.showInputDialog(this,
                        "the value is not within the range, please entry technician name.", "Warning",
                        JOptionPane.OK_OPTION);

                if (!checker.equals("")) {
                    isSave = true;
                }
            }
            staff = this.txtBoreStaff1.getText();
            this.txtBoreStaff1.setText("");
        } else {
            JOptionPane.showMessageDialog(this, "Please entry the valid number like (123.45).", "Warning",
                    JOptionPane.OK_OPTION);
        }

        if (isSave) {
            DefaultTableModel model = (DefaultTableModel) this.tblBore.getModel();
            Date now = new Date();
            String time = new SimpleDateFormat("HH:mm").format(now);
            Float valueBore1 = Float.parseFloat(this.txtBore11.getText());
            Float valueBore2 = Float.parseFloat(this.txtBore21.getText());
            Float valueNeck = Float.parseFloat(this.txtNeck1.getText());
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE1_2, valueBore1)) {
                pass = "YES";
            } else {
                pass = "NO(" + checker + ")";
            }
            model.addRow(new Object[] { time, RecordKey.THREAD_BORE1_2, valueBore1, pass, staff });
            UpdateEntryData(now, valueBore1, RecordKey.THREAD_BORE1_2, staff, pass, "");
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE2_2, valueBore2)) {
                pass = "YES";
            } else {
                pass = "NO(" + checker + ")";
            }
            model.addRow(new Object[] { time, RecordKey.THREAD_BORE2_2, valueBore2, pass, staff });
            UpdateEntryData(now, valueBore2, RecordKey.THREAD_BORE2_2, staff, pass, "");
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_NECK_2, valueNeck)) {
                pass = "YES";
            } else {
                pass = "NO(" + checker + ")";
            }
            model.addRow(new Object[] { time, RecordKey.THREAD_NECK_2, valueNeck, pass, staff });
            UpdateEntryData(now, valueNeck, RecordKey.THREAD_NECK_2, staff, pass, "");

            ((AbstractTableModel) this.tblBore.getModel()).fireTableDataChanged();
            this.txtBore11.setText("");
            this.txtBore21.setText("");
            this.txtNeck1.setText("");
        }
    }
}

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void UpdateEntryForm() {
    List<Record> records = this.recordService.GetAllEntitiesByKeyAndRecord(RecordKey.ALL,
            this.currentEntry.getId());
    //load images
    if (currentEntry.getMouldId().getImageBoreA() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageBoreA(), this.pnlBoreImage1, 75);
    } else {//w w  w .ja  va2s .co  m
        AppHelper.DisplayImageFromResource("/b1.png", this.pnlBoreImage1, 75);
    }
    if (currentEntry.getMouldId().getImageBoreB() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageBoreB(), this.pnlBoreImage2, 75);
    } else {
        AppHelper.DisplayImageFromResource("/b2.png", this.pnlBoreImage2, 75);
    }
    if (currentEntry.getMouldId().getImageNeck() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageNeck(), this.pnlNeckImage, 75);
    } else {
        AppHelper.DisplayImageFromResource("/b3.png", this.pnlNeckImage, 75);
    }
    if (currentEntry.getMouldId().getImageTap() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageTap(), this.pnlTapImage, 75);
    } else {
        AppHelper.DisplayImageFromResource("/no_photo_small.png", this.pnlTapImage, 75);
    }
    if (currentEntry.getProductId().getDgnondg() != null && currentEntry.getProductId().getDgnondg() == 0) {
        if (currentEntry.getMouldId().getImageDg() != null) {
            AppHelper.DisplayImage(currentEntry.getMouldId().getImageDg(), this.pnlWallImage, 75);
        } else {
            AppHelper.DisplayImageFromResource("/no_photo_small.png", this.pnlWallImage, 75);
        }
    } else {
        if (currentEntry.getMouldId().getImageNonDg() != null) {
            AppHelper.DisplayImage(currentEntry.getMouldId().getImageNonDg(), this.pnlWallImage, 75);
        } else {
            AppHelper.DisplayImageFromResource("/no_photo_small.png", this.pnlWallImage, 75);
        }
    }
    //info
    UpdateProductInfo(this.currentEntry);
    //weight
    this.labWeightStaff.setVisible(false);
    this.txtWeightStaff.setVisible(false);
    datasetWeight = new DefaultCategoryDataset();

    List<Record> recordsWeight = records.stream().filter(x -> x.getRecordKey().equals("PRODUCT_WEIGHT"))
            .collect(Collectors.toList());
    DefaultTableModel modelWeight = (DefaultTableModel) this.tblWeight.getModel();
    modelWeight.setRowCount(0);
    for (Record record : recordsWeight) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        datasetWeight.addValue(record.getNumberValue(), "Weight", time);
        modelWeight.addRow(new Object[] { time, record.getNumberValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblWeight.getModel()).fireTableDataChanged();
    JFreeChart chartWeight = ChartFactory.createLineChart("Product Weight (grams)", "", "", datasetWeight,
            PlotOrientation.VERTICAL, false, true, false);
    ChartPanel cpWeight = new ChartPanel(chartWeight);
    this.pnlChartWeight.removeAll();
    this.pnlChartWeight.add(cpWeight, gridBagConstraints);
    //wall
    List<Record> recordsWall = records.stream().filter(x -> x.getRecordKey().startsWith("WALL_"))
            .collect(Collectors.toList());
    DefaultTableModel modelWall = (DefaultTableModel) this.tblWall.getModel();
    modelWall.setRowCount(0);
    for (Record record : recordsWall) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        String name = record.getRecordKey();
        modelWall.addRow(new Object[] { time, name, record.getNumberValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblWall.getModel()).fireTableDataChanged();
    //Tap
    datasetTap = new DefaultCategoryDataset();

    List<Record> recordsTap = records.stream().filter(x -> x.getRecordKey().equals("TAP_POSITION"))
            .collect(Collectors.toList());
    DefaultTableModel modelTap = (DefaultTableModel) this.tblTap.getModel();
    modelTap.setRowCount(0);
    for (Record record : recordsTap) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        datasetTap.addValue(record.getNumberValue(), "Tap", time);
        modelTap.addRow(new Object[] { time, record.getStringValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblTap.getModel()).fireTableDataChanged();
    JFreeChart chartTap = ChartFactory.createLineChart("Tap Positio", "", "", datasetTap,
            PlotOrientation.VERTICAL, false, true, false);
    ChartPanel cpTap = new ChartPanel(chartTap);
    this.pnlChartTap.removeAll();
    this.pnlChartTap.add(cpTap, gridBagConstraints);
    //Bore
    List<Record> recordsBore = records.stream().filter(x -> x.getRecordKey().startsWith("THREAD_"))
            .collect(Collectors.toList());
    DefaultTableModel modelBore = (DefaultTableModel) this.tblBore.getModel();
    modelBore.setRowCount(0);
    for (Record record : recordsBore) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        String name = record.getRecordKey();
        modelBore.addRow(new Object[] { time, name, record.getNumberValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblBore.getModel()).fireTableDataChanged();
    if (this.currentEntry.getProductId() != null
            && this.currentEntry.getProductId().getClosureType().equals("TWIN")) {
        this.txtBore11.setVisible(true);
        this.txtBore21.setVisible(true);
        this.txtNeck1.setVisible(true);
        this.txtBoreStaff1.setVisible(true);
        this.btnBore1.setVisible(true);
    } else {
        this.txtBore11.setVisible(false);
        this.txtBore21.setVisible(false);
        this.txtNeck1.setVisible(false);
        this.txtBoreStaff1.setVisible(false);
        this.btnBore1.setVisible(false);
    }
    //Check
    List<Record> recordsCheck = records.stream().filter(x -> x.getRecordKey().startsWith("CHECK_"))
            .collect(Collectors.toList());
    DefaultTableModel modelCheck = (DefaultTableModel) this.tblCheck.getModel();
    modelCheck.setRowCount(0);
    for (Record record : recordsCheck) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        String name = record.getRecordKey();
        modelCheck.addRow(new Object[] { time, name, record.getStringValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblCheck.getModel()).fireTableDataChanged();
    //Drop
    List<Record> recordsDrop = records.stream().filter(x -> x.getRecordKey().startsWith("DROP_"))
            .collect(Collectors.toList());
    DefaultTableModel modelDrop = (DefaultTableModel) this.tblDrop.getModel();
    modelDrop.setRowCount(0);
    for (Record record : recordsDrop) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String name = record.getRecordKey();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        modelDrop.addRow(new Object[] { time, name, record.getStringValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblDrop.getModel()).fireTableDataChanged();
    //Bung
    List<Record> recordsBung = records.stream().filter(x -> x.getRecordKey().equals("BUNG"))
            .collect(Collectors.toList());
    DefaultTableModel modelBung = (DefaultTableModel) this.tblBung.getModel();
    modelBung.setRowCount(0);
    for (Record record : recordsBung) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        modelBung.addRow(new Object[] { time, record.getStringValue(), pass, staff });
    }
    //Cycle
    List<Record> recordsCycle = records.stream().filter(x -> x.getRecordKey().equals("CYCLE"))
            .collect(Collectors.toList());
    DefaultTableModel modelCycle = (DefaultTableModel) this.tblCycle.getModel();
    modelCycle.setRowCount(0);
    for (Record record : recordsCycle) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        modelCycle.addRow(new Object[] { time, record.getStringValue(), staff });
    }
    //Seconds
    float totalSeconds = 0f;
    List<Record> recordsSeconds = records.stream().filter(x -> x.getRecordKey().equals("SECONDS"))
            .collect(Collectors.toList());
    DefaultTableModel modelSeconds = (DefaultTableModel) this.tblSeconds.getModel();
    modelSeconds.setRowCount(0);
    for (Record record : recordsSeconds) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        modelSeconds.addRow(new Object[] { time, record.getNumberValue() });
        totalSeconds += record.getNumberValue();
    }
    this.labSecondsTotal.setText(Float.toString(totalSeconds));
    //Rejects
    float totalRejects = 0f;
    List<Record> recordsRejects = records.stream().filter(x -> x.getRecordKey().equals("REJECTS"))
            .collect(Collectors.toList());
    DefaultTableModel modelRejects = (DefaultTableModel) this.tblRejects.getModel();
    modelRejects.setRowCount(0);
    for (Record record : recordsRejects) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        modelRejects.addRow(new Object[] { time, record.getNumberValue() });
        totalRejects += record.getNumberValue();
    }
    this.labRejectsTotal.setText(Float.toString(totalRejects));
    //material
    this.FillPolymerComboBox(this.cbProductPolymer, 0);
    this.FillAdditiveComboBox(this.cbProductAdditive1, 0);
    this.FillAdditiveComboBox(this.cbProductAdditive2, 0);
    this.FillAdditiveComboBox(this.cbProductAdditive3, 0);
    DefaultTableModel modelMaterial = (DefaultTableModel) this.tblMaterial.getModel();
    modelMaterial.setRowCount(0);
    if (currentEntry.getMaterial() != null && !currentEntry.getMaterial().equals("")) {
        FillMaterialTable(currentEntry.getMaterial());
    }
    txtPolymerBatchA.setText("");
    txtPolymerBatchB.setText("");
    txtAdditiveABatchA.setText("");
    txtAdditiveBBatchA.setText("");
    txtAdditiveCBatchA.setText("");
    txtAdditiveABatchB.setText("");
    txtAdditiveBBatchB.setText("");
    txtAdditiveCBatchB.setText("");
    //staff
    this.FillStaffComboBox(this.cbSupervisor1,
            currentEntry.getSupervisor1() != null ? currentEntry.getSupervisor1().getId() : 0, "SUPERVISOR");
    this.FillStaffComboBox(this.cbSupervisor2,
            currentEntry.getSupervisor2() != null ? currentEntry.getSupervisor2().getId() : 0, "SUPERVISOR");
    this.FillStaffComboBox(this.cbSupervisor3,
            currentEntry.getSupervisor3() != null ? currentEntry.getSupervisor3().getId() : 0, "SUPERVISOR");
    this.FillStaffComboBox(this.cbTechnician1,
            currentEntry.getTechnician1() != null ? currentEntry.getTechnician1().getId() : 0, "TECHNICIAN");
    this.FillStaffComboBox(this.cbTechnician2,
            currentEntry.getTechnician2() != null ? currentEntry.getTechnician2().getId() : 0, "TECHNICIAN");
    this.FillStaffComboBox(this.cbTechnician3,
            currentEntry.getTechnician3() != null ? currentEntry.getTechnician3().getId() : 0, "TECHNICIAN");
    this.FillStaffComboBox(this.cbWorker1,
            currentEntry.getWorker1() != null ? currentEntry.getWorker1().getId() : 0, "PROCESS WORKER");
    this.FillStaffComboBox(this.cbWorker2,
            currentEntry.getWorker2() != null ? currentEntry.getWorker2().getId() : 0, "PROCESS WORKER");
    this.FillStaffComboBox(this.cbWorker3,
            currentEntry.getWorker3() != null ? currentEntry.getWorker3().getId() : 0, "PROCESS WORKER");
    //Leak
    List<Record> recordsLeak = records.stream()
            .filter(x -> x.getRecordKey().startsWith("DROP_") || x.getRecordKey().equals("ANY_LEAK"))
            .collect(Collectors.toList());
    DefaultTableModel modelLeak = (DefaultTableModel) this.tblLeak.getModel();
    modelLeak.setRowCount(0);
    for (Record record : recordsLeak) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String name = record.getRecordKey();
        modelLeak.addRow(new Object[] { time, name, record.getStringValue() });
    }
    ((AbstractTableModel) this.tblLeak.getModel()).fireTableDataChanged();
    this.txtLeakNotes.setVisible(false);
    //quantity
    this.txtPalletQuantity.setText(
            currentEntry.getPalletQuantity() == null ? "0" : currentEntry.getPalletQuantity().toString());
    this.txtOtherQuantity.setText(
            currentEntry.getOtherQuantity() == null ? "0" : currentEntry.getOtherQuantity().toString());
    this.txtPalletProducedA.setText(
            currentEntry.getPalletProducedA() == null ? "0" : currentEntry.getPalletProducedA().toString());
    this.txtPalletProducedB.setText(
            currentEntry.getPalletProducedB() == null ? "0" : currentEntry.getPalletProducedB().toString());
    int a1 = 0;
    int a2 = 0;
    int b1 = 0;
    int b2 = 0;
    a1 = Integer.parseInt(this.txtPalletProducedA.getText());
    b1 = Integer.parseInt(this.txtPalletProducedB.getText());
    a2 = Integer.parseInt(this.txtPalletQuantity.getText());
    b2 = Integer.parseInt(this.txtOtherQuantity.getText());
    this.labQuantityTotal.setText(Integer.toString((a1 * a2) + (b1 * b2)));
}

From source file:com.cch.aj.entryrecorder.frame.SettingsJFrame.java

private void btnCheckInsertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheckInsertActionPerformed
    if (!this.txtCheckDesc.getText().equals("")) {
        String desc = this.txtCheckDesc.getText();

        int checkId = this.checkitemService.CreateEntity();
        Checkitem check = this.checkitemService.FindEntity(checkId);
        check.setDescription(desc);/*w  w  w .j ava  2  s .  c  o  m*/
        List<Product> list = new ArrayList<Product>();
        list.add(this.settingProduct);
        check.setProductCollection(list);
        this.checkitemService.UpdateEntity(check);
        DefaultTableModel model = (DefaultTableModel) this.tblCheck.getModel();
        model.addRow(new Object[] { check.getId(), desc });
        this.txtCheckDesc.setText("");
    } else {
        JOptionPane.showMessageDialog(this, "please enter the valid data", "Warming", JOptionPane.OK_OPTION);
    }
}

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void FillMaterialTable(String data) {
    try {/*from   ww  w .  java 2  s. c  om*/
        JSONObject json = new JSONObject(data);
        JSONArray items = (JSONArray) json.get("items");
        for (int i = 0; i < items.length(); i++) {
            JSONObject record = (JSONObject) items.get(i);
            DefaultTableModel model = (DefaultTableModel) this.tblMaterial.getModel();
            String time = record.getString("time");
            String polymer = record.getString("polymer");
            String additive1 = record.getString("additive1");
            String additive2 = record.getString("additive2");
            String additive3 = record.getString("additive3");
            String polymer_batch1 = record.getString("polymer_batch1");
            String polymer_batch2 = record.getString("polymer_batch2");
            String additive1_batch1 = record.getString("additive1_batch1");
            String additive1_batch2 = record.getString("additive1_batch2");
            String additive2_batch1 = record.getString("additive2_batch1");
            String additive2_batch2 = record.getString("additive2_batch2");
            String additive3_batch1 = record.getString("additive3_batch1");
            String additive3_batch2 = record.getString("additive3_batch2");
            if (!polymer.equals("")) {
                model.addRow(new Object[] { time, "polymer", polymer });
            }
            if (!polymer_batch1.equals("")) {
                model.addRow(new Object[] { time, "polymer_batch1", polymer_batch1 });
            }
            if (!polymer_batch2.equals("")) {
                model.addRow(new Object[] { time, "polymer_batch2", polymer_batch2 });
            }
            if (!additive1.equals("")) {
                model.addRow(new Object[] { time, "additive1", additive1 });
            }
            if (!additive1_batch1.equals("")) {
                model.addRow(new Object[] { time, "additive1_batch1", additive1_batch1 });
            }
            if (!additive1_batch2.equals("")) {
                model.addRow(new Object[] { time, "additive1_batch2", additive1_batch2 });
            }
            if (!additive2.equals("")) {
                model.addRow(new Object[] { time, "additive2", additive2 });
            }
            if (!additive2_batch1.equals("")) {
                model.addRow(new Object[] { time, "additive2_batch1", additive2_batch1 });
            }
            if (!additive2_batch2.equals("")) {
                model.addRow(new Object[] { time, "additive2_batch2", additive2_batch2 });
            }
            if (!additive3.equals("")) {
                model.addRow(new Object[] { time, "additive3", additive3 });
            }
            if (!additive3_batch1.equals("")) {
                model.addRow(new Object[] { time, "additive3_batch1", additive3_batch1 });
            }
            if (!additive3_batch2.equals("")) {
                model.addRow(new Object[] { time, "additive3_batch2", additive3_batch2 });
            }
        }
    } catch (JSONException ex) {
        Logger.getLogger(MainJFrame.class.getName()).log(Level.SEVERE, null, ex);
    }
}