Example usage for javax.swing.table DefaultTableModel getRowCount

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

Introduction

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

Prototype

public int getRowCount() 

Source Link

Document

Returns the number of rows in this data table.

Usage

From source file:com.mirth.connect.client.ui.RegexAttachmentDialog.java

private void closeButtonActionPerformed(ActionEvent evt) {
    attachmentHandlerProperties.getProperties().put("regex.pattern", regexTextField.getText());
    attachmentHandlerProperties.getProperties().put("regex.mimetype", mimeTypeField.getText());

    DefaultTableModel inboundTableModel = (DefaultTableModel) inboundReplacementTable.getModel();
    for (int row = 0; row < inboundTableModel.getRowCount(); row++) {
        String replaceKey = (String) inboundTableModel.getValueAt(row, 0);
        String replaceValue = (String) inboundTableModel.getValueAt(row, 1);

        attachmentHandlerProperties.getProperties().put("regex.replaceKey" + row, replaceKey);
        attachmentHandlerProperties.getProperties().put("regex.replaceValue" + row, replaceValue);
    }/*from   w  ww  .  jav a  2 s .  c o  m*/

    DefaultTableModel outboundTableModel = (DefaultTableModel) outboundReplacementTable.getModel();
    for (int row = 0; row < outboundTableModel.getRowCount(); row++) {
        String replaceKey = (String) outboundTableModel.getValueAt(row, 0);
        String replaceValue = (String) outboundTableModel.getValueAt(row, 1);

        attachmentHandlerProperties.getProperties().put("outbound.regex.replaceKey" + row, replaceKey);
        attachmentHandlerProperties.getProperties().put("outbound.regex.replaceValue" + row, replaceValue);
    }

    attachmentHandlerProperties = null;
    this.dispose();
}

From source file:edu.ku.brc.af.ui.forms.formatters.DataObjFieldFormatMultiplePanel.java

/**
 * @return/*w w  w  .  j  a v a 2s  .c  o  m*/
 */
protected boolean isValidFormatter() {
    // check if there's an empty row in the switch formatter table
    DefaultTableModel model = (DefaultTableModel) formatSwitchTbl.getModel();

    if (model.getRowCount() == 0) {
        return false; // formatter is not valid if there are no internal formatters attached to it
    }

    Set<String> valueSet = new HashSet<String>();
    // check if there are valid values in each row
    for (int i = 0; i < model.getRowCount(); ++i) {
        for (int j = 0; j <= 1; ++j) {
            Object obj = model.getValueAt(i, j);
            String value = obj.toString();
            if (obj == null || StringUtils.isEmpty(value)) {
                return false;
            }
            // also check if field value is unique (column 0)
            if (j == 0) {
                // value already in the set: so it's not unique
                if (valueSet.contains(value))
                    return false;

                valueSet.add(value);
            }
        }
    }
    return true;
}

From source file:com.mirth.connect.client.ui.attachments.RegexAttachmentDialog.java

private void inboundNewButtonActionPerformed(ActionEvent evt) {
    DefaultTableModel model = ((DefaultTableModel) inboundReplacementTable.getModel());
    int row = model.getRowCount();

    model.addRow(new Object[] { "", "" });

    inboundReplacementTable.setRowSelectionInterval(row, row);
}

From source file:com.mirth.connect.client.ui.attachments.RegexAttachmentDialog.java

private void outboundNewButtonActionPerformed(ActionEvent evt) {
    DefaultTableModel model = ((DefaultTableModel) outboundReplacementTable.getModel());
    int row = model.getRowCount();

    model.addRow(new Object[] { "", "" });

    outboundReplacementTable.setRowSelectionInterval(row, row);
}

From source file:dbseer.gui.panel.DBSeerLiveMonitorPanel.java

public void reset() {
    synchronized (LiveMonitorInfo.LOCK) {
        DefaultTableModel model = (DefaultTableModel) monitorTable.getModel();
        int rowCount = model.getRowCount();
        for (int i = rowCount - 1; i >= 2; --i) {
            model.removeRow(i);/*w w w .j a v a2s .  co m*/
        }
        latencyCollection.removeAllSeries();
        throughputCollection.removeAllSeries();
        for (JLabel label : transactionLabels) {
            transactionTypesPanel.remove(label);
        }
        transactionLabels.clear();
        for (JButton button : transactionRenameButtons) {
            transactionTypesPanel.remove(button);
        }
        transactionRenameButtons.clear();
        for (JButton button : transactionViewSampleButtons) {
            transactionTypesPanel.remove(button);
        }
        transactionViewSampleButtons.clear();
        for (JButton button : transactionEnableDisableButtons) {
            transactionTypesPanel.remove(button);
        }
        transactionEnableDisableButtons.clear();
        transactionNames.clear();
        numTransactionType = 0;

        setTotalNumberOfTransactions(0.0);
        setCurrentTPS(0.0);
    }
    this.invalidate();
    this.repaint();
}

From source file:controldeadministradores.Admin.java

private void jbtn_buscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_buscarActionPerformed
    // TODO add your handling code here:
    DefaultTableModel model = (DefaultTableModel) jtbl_RepoteVuelos.getModel();
    int rowCount = model.getRowCount();
    //Remove rows one by one from the end of the table
    for (int i = rowCount - 1; i >= 0; i--) {
        model.removeRow(i);//w w w  .j  av a2 s. c o  m
    }
    String res = "";
    try {
        res = get(servidorDir + "/vuelos");
        JSONArray obj = new JSONArray(res);

        for (int i = 0; i < obj.length(); i++) {
            JSONObject a = obj.getJSONObject(i);
            String c = jcb_estado.getSelectedItem().toString();
            String estado = a.get("state").toString();
            if (estado.equals(c) || c.equals("Todos")) {
                model.addRow(
                        new Object[] { a.get("id_fly"), a.get("origin"), a.get("destiny"), a.get("date_out"),
                                a.get("date_in"), a.get("price_fc"), a.get("price_tc"), a.get("price_ec"),
                                a.get("amount_fc"), a.get("amount_tc"), a.get("amount_ec"), a.get("state") });
            }
        }
    } catch (IOException ex) {
        Logger.getLogger(Admin.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:dbseer.gui.panel.DBSeerLiveMonitorPanel.java

public synchronized void setCurrentAverageLatency(long time, int index, double latency) {
    synchronized (LiveMonitorInfo.LOCK) {
        DefaultTableModel model = (DefaultTableModel) monitorTable.getModel();
        if (model.getRowCount() <= 2 + (index * ROW_PER_TX_TYPE + 1)) {
            model.addRow(new Object[] { "", "" });
        }// ww  w .ja v  a 2  s  . c o m
        model.setValueAt(String.format("%.1f", latency), 2 + (index * ROW_PER_TX_TYPE) + 1, 1);
        if (numTransactionType < index + 1) {
            String newName = "Type " + (index + 1);
            transactionNames.add(newName);
            numTransactionType = index + 1;

            JLabel newLabel = new JLabel(newName);
            JButton renameButton = new JButton("Rename");
            JButton viewSampleButton = new JButton("View Examples");
            //            JButton enableDisableButton;
            //            if (DBSeerGUI.liveDataset.isTransactionEnabled(index))
            //            {
            //               enableDisableButton = new JButton("Disable");
            //            }
            //            else
            //            {
            //               enableDisableButton = new JButton("Enable");
            //            }

            renameButton.addActionListener(this);
            viewSampleButton.addActionListener(this);
            //            enableDisableButton.addActionListener(this);

            transactionTypesPanel.add(newLabel);
            transactionTypesPanel.add(renameButton);
            transactionTypesPanel.add(viewSampleButton);
            //            transactionTypesPanel.add(enableDisableButton);

            transactionLabels.add(newLabel);
            transactionRenameButtons.add(renameButton);
            transactionViewSampleButtons.add(viewSampleButton);
            //            transactionEnableDisableButtons.add(enableDisableButton);

            throughputCollection.addSeries(new TimeSeries(newName, Millisecond.class));
            latencyCollection.addSeries(new TimeSeries(newName, Millisecond.class));

            this.revalidate();
            this.repaint();
        }
        model.setValueAt(
                String.format("Current average latency of '%s' transactions", transactionNames.get(index)),
                2 + (index * ROW_PER_TX_TYPE) + 1, 0);

        if (index < latencyCollection.getSeriesCount()) {
            TimeSeries series = latencyCollection.getSeries(index);
            //            series.add(new Millisecond(), latency);
            series.addOrUpdate(new Millisecond(new Date(time * 1000)), latency);
        }
    }
}

From source file:gtu._work.ui.RegexCatchReplacer.java

/**
 * @param fromPattern//from w  ww .  j a v  a  2  s  . c  o  m
 *            ???pattern
 * @param toFormat
 *            ??pattern
 * @param replaceText
 *            ??
 */
void replacer(String fromPattern, String toFormat, String replaceText) {
    try {
        Pattern pattern = Pattern.compile(fromPattern);
        Matcher matcher = pattern.matcher(replaceText);
        Map<String, Integer> tmap = new LinkedHashMap<String, Integer>();
        String tempStr = null;
        for (; matcher.find();) {
            tempStr = toFormat.toString();
            for (int ii = 0; ii <= matcher.groupCount(); ii++) {
                System.out.println(ii + " -- " + matcher.group(ii));
                tempStr = tempStr.replaceAll("#" + ii + "#", Matcher.quoteReplacement(matcher.group(ii)));
                if (!tmap.containsKey(tempStr)) {
                    tmap.put(tempStr, 0);
                }
                tmap.put(tempStr, tmap.get(tempStr) + 1);
            }
        }
        DefaultTableModel model = JTableUtil.createModel(true, "match", "count");
        for (String str : tmap.keySet()) {
            model.addRow(new Object[] { str, tmap.get(str) });
        }
        setTitle("total : " + model.getRowCount());
        resultArea.setModel(model);
    } catch (Exception ex) {
        JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(ex.getMessage(), getTitle());
        ex.printStackTrace();
    }
}

From source file:dbseer.gui.panel.DBSeerLiveMonitorPanel.java

public synchronized void setCurrentTPS(long time, int index, double tps) {
    synchronized (LiveMonitorInfo.LOCK) {
        DefaultTableModel model = (DefaultTableModel) monitorTable.getModel();
        if (model.getRowCount() <= 2 + (index * ROW_PER_TX_TYPE)) {
            model.addRow(new Object[] { "", "" });
        }/*  w ww.  j  av a2s .c  om*/
        model.setValueAt(String.format("%.1f", tps), 2 + (index * ROW_PER_TX_TYPE), 1);
        if (numTransactionType < index + 1) {
            String newName = "Type " + (index + 1);
            transactionNames.add(newName);
            numTransactionType = index + 1;

            JLabel newLabel = new JLabel(newName);
            JButton renameButton = new JButton("Rename");
            JButton viewSampleButton = new JButton("View Examples");
            //            JButton enableDisableButton;
            //            if (DBSeerGUI.liveDataset.isTransactionEnabled(index))
            //            {
            //               enableDisableButton = new JButton("Disable");
            //            }
            //            else
            //            {
            //               enableDisableButton = new JButton("Enable");
            //            }

            renameButton.addActionListener(this);
            viewSampleButton.addActionListener(this);
            //            enableDisableButton.addActionListener(this);

            transactionTypesPanel.add(newLabel);
            transactionTypesPanel.add(renameButton);
            transactionTypesPanel.add(viewSampleButton);
            //            transactionTypesPanel.add(enableDisableButton);

            transactionLabels.add(newLabel);
            transactionRenameButtons.add(renameButton);
            transactionViewSampleButtons.add(viewSampleButton);
            //            transactionEnableDisableButtons.add(enableDisableButton);

            for (DBSeerDataSet dataset : DBSeerGUI.liveDatasets) {
                dataset.addTransactionType("Type " + numTransactionType);
            }

            //         TimeSeriesCollection newThroughputCollection = new TimeSeriesCollection(new TimeSeries(newName, Millisecond.class));
            //         TimeSeriesCollection collection = (TimeSeriesCollection) throughputChartPanel.getChart().getXYPlot().getDataset();
            throughputCollection.addSeries(new TimeSeries(newName, Millisecond.class));
            latencyCollection.addSeries(new TimeSeries(newName, Millisecond.class));

            //         throughputChartPanel.getChart().getXYPlot().setDataset(index, newThroughputCollection);

            this.revalidate();
            this.repaint();
        }
        model.setValueAt(String.format("Current TPS of '%s' transactions", transactionNames.get(index)),
                2 + (index * ROW_PER_TX_TYPE), 0);

        //      TimeSeriesCollection collection = (TimeSeriesCollection) throughputChartPanel.getChart().getXYPlot().getDataset();
        if (index < throughputCollection.getSeriesCount()) {
            TimeSeries series = throughputCollection.getSeries(index);
            //            series.add(new Millisecond(), tps);
            series.addOrUpdate(new Millisecond(new Date(time * 1000)), tps);
        }
    }
}

From source file:controldeadministradores.Admin.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:
    DefaultTableModel model = (DefaultTableModel) jtbl_RepoteVuelosAeropuerto.getModel();
    int rowCount = model.getRowCount();
    //Remove rows one by one from the end of the table
    for (int i = rowCount - 1; i >= 0; i--) {
        model.removeRow(i);/*w  ww . jav  a  2s .  c  om*/
    }
    String res = "";
    try {
        res = get(servidorDir + "/vuelos");
        JSONArray obj = new JSONArray(res);

        for (int i = 0; i < obj.length(); i++) {
            JSONObject a = obj.getJSONObject(i);
            String aero = jtxt_aeropuerto.getText();
            String estado = a.get("state").toString();
            String origen = a.get("origin").toString();
            String destino = a.get("destiny").toString();
            if ((estado.equals("En Aeropuerto") && origen.equals(aero))
                    || (estado.equals("En Arribo") && destino.equals(aero))) {
                model.addRow(
                        new Object[] { a.get("id_fly"), a.get("origin"), a.get("destiny"), a.get("date_out"),
                                a.get("date_in"), a.get("price_fc"), a.get("price_tc"), a.get("price_ec"),
                                a.get("amount_fc"), a.get("amount_tc"), a.get("amount_ec"), a.get("state") });
            }
        }
    } catch (IOException ex) {
        Logger.getLogger(Admin.class.getName()).log(Level.SEVERE, null, ex);
    }
}