Example usage for javax.swing.table DefaultTableModel setRowCount

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

Introduction

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

Prototype

public void setRowCount(int rowCount) 

Source Link

Document

Sets the number of rows in the model.

Usage

From source file:UI.MainUI.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    DefaultTableModel dtm = (DefaultTableModel) forecastTable.getModel();
    dtm.setRowCount(0);
    dtm.setRowCount(4);/*from w  w w  .  ja  v  a2  s .  c o m*/
}

From source file:UI.MainUI.java

private void forecastBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_forecastBtnActionPerformed
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    DefaultTableModel dtm = (DefaultTableModel) forecastTable.getModel();
    dtm.setRowCount(0);
    dtm.setRowCount(4);/*from  w w  w  . ja v a  2  s .  co  m*/

    if (algo == 1) {
        startFForecast();
    } else {
        startRForecast();
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

}

From source file:stainingestimation.StainingEstimation.java

/**
 * Writes an entry into the staining estimation parameter table.
 * @param fscores The parameters to be written.
 *//*from  w w w .ja  v  a2 s  .  co  m*/
void writePrecisionRecallTable(double[][][] fscores) {
    if (fscores != null) {
        DefaultTableModel tm = ((DefaultTableModel) jXTable1.getModel());
        tm.setRowCount(0);
        int i = 0;
        for (double[][] d1 : fscores) {
            for (double[] d2 : d1) {
                tm.setRowCount(++i);
                for (int j = 0; j < jXTable1.getModel().getColumnCount(); j++) {
                    if (((DefaultTableModel) jXTable1.getModel()).getColumnClass(j) == Double.class) {
                        tm.setValueAt(d2[j], i - 1, j);
                    } else if (((DefaultTableModel) jXTable1.getModel()).getColumnClass(j) == Integer.class) {
                        tm.setValueAt((int) d2[j], i - 1, j);
                    } else {
                        if (jXTable1.getModel().getColumnName(j).equalsIgnoreCase("staining")) {
                            tm.setValueAt(jComboBox1.getModel().getElementAt(Math.round((float) d2[j])), i - 1,
                                    j);
                        } else {
                            tm.setValueAt(Double.toString(d2[j]), i - 1, j);
                        }
                    }
                }
            }
        }
        jXTable1.doLayout();
        jXTable1.packAll();
        jXTable1.packTable(0);
        jButton11.setEnabled(jXTable1.getRowCount() > 0);
    }
}

From source file:jp.massbank.spectrumsearch.SearchPage.java

private void fillGuiDbTableData(List<GuiDbTableRow> rows) {
    DefaultTableModel dataModel = (DefaultTableModel) querySorter.getTableModel();
    dataModel.setRowCount(0);
    Collections.sort(rows);//from   w  w w .  j  av a  2s. c  om
    if (rows != null && rows.size() > 0) {
        for (GuiDbTableRow row : rows) {
            dataModel.addRow(new String[] { row.getRecordId(), row.getRecordTitle(), row.getContributor(),
                    row.getIndex() });
        }
    }
}

From source file:jp.massbank.spectrumsearch.SearchPage.java

private void fillGuiResultTableData(List<GuiResultTableRow> rows) {
    DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel();
    dataModel.setRowCount(0);
    Collections.sort(rows);/* w  w w  . j  a  v  a2  s  . co  m*/
    if (rows != null && rows.size() > 0) {
        for (GuiResultTableRow row : rows) {
            dataModel.addRow(new Object[] { row.getRecordTitle(), row.getScore(), row.getHit(),
                    row.getRecordId(), row.getIonMode(), row.getContributor(), row.getIndex() });
        }
    }
}

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

private void updateTagTable() {
    DefaultTableModel model = (DefaultTableModel) tagTable.getModel();
    model.setRowCount(0);

    for (String tag : currentChannel.getProperties().getTags()) {
        model.addRow(new Object[] { tag });
    }/*from w ww .  j a  v  a2s.  co  m*/
}

From source file:jp.massbank.spectrumsearch.SearchPage.java

/**
 * DB//from   www .  j av a2 s. co  m
 * ???DB??
 * @param ps 
 * @param precursor 
 * @param queryName ???
 * @param queryKey 
 */
private void searchDb(String[] ps, String precursor, String queryName, String queryKey) {
    initSearchParameterSetting();

    queryPlot.clear();
    compPlot.clear();
    resultPlot.clear();
    queryPlot.setPeaks(null, 0);
    compPlot.setPeaks(null, 1);
    resultPlot.setPeaks(null, 0);
    DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel();
    dataModel.setRowCount(0);
    hitLabel.setText("");

    if (queryTabPane.getSelectedIndex() == TAB_ORDER_DB) {
        queryPlot.setSpectrumInfo(queryName, queryKey, precursor, PeakPanel.SP_TYPE_QUERY, false);
    } else if (queryTabPane.getSelectedIndex() == TAB_ORDER_FILE) {
        queryPlot.setSpectrumInfo(queryName, queryKey, precursor, PeakPanel.SP_TYPE_QUERY, true);
    }

    // ??????
    if (ps.length == 0
            || (ps.length == 1 && ps[0].split("\t")[0].equals("0") && ps[0].split("\t")[1].equals("0"))) {
        queryPlot.setNoPeak(true);
        StringBuilder sb = new StringBuilder();
        sb.append(" 0 Hit.    (");
        sb.append((PRECURSOR < 1) ? "" : "Precursor : " + PRECURSOR + ", ");
        sb.append("Tolerance : ");
        sb.append(" ");
        sb.append((tolUnit1.isSelected()) ? tolUnit1.getText() : tolUnit2.getText());
        sb.append(", Cutoff threshold : " + CUTOFF_THRESHOLD + ")");
        hitLabel.setText(sb.toString());

        //         hitLabel.setText(" 0 Hit.    ("
        //               + ((PRECURSOR < 1) ? "" : "Precursor : " + PRECURSOR + ", ")
        //               + "Tolerance : "
        //               + TOLERANCE
        //               + " "
        //               + ((tolUnit1.isSelected()) ? tolUnit1.getText() : tolUnit2.getText()) + ", Cutoff threshold : "
        //               + CUTOFF_THRESHOLD + ")");

        // ?
        this.setCursor(Cursor.getDefaultCursor());
        return;
    }

    // POST?
    final SearchQueryParam param = new SearchQueryParam(); // StringBuffer post = new StringBuffer();
    if (isRecInteg) {
        param.setInteg(true); //   post.append( "INTEG=true&" );
    } else if (isRecActu) {
        param.setInteg(false); //   post.append( "INTEG=false&" );
    }
    if (PRECURSOR > 0) {
        param.setPrecursor(PRECURSOR); //   post.append( "PRE=" + PRECURSOR + "&");
    }
    param.setCutoff(CUTOFF_THRESHOLD); //   post.append( "CUTOFF=" + CUTOFF_THRESHOLD + "&" );
    param.setTolerance(TOLERANCE); //   post.append( "TOLERANCE=" + TOLERANCE + "&" );
    if (tolUnit2.isSelected()) {
        param.setTolUnit(ToleranceUnit.PPM.getLabel()); //   post.append( "TOLUNIT=ppm&" );
    } else {
        param.setTolUnit(ToleranceUnit.UNIT.getLabel()); //   post.append( "TOLUNIT=unit&" );
    }
    StringBuffer sbInstance = new StringBuffer(); //   post.append( "INST=" );
    boolean isAllInstanceSelected = true;
    for (Entry<String, Boolean> entry : isInstCheck.entrySet()) {
        if (entry.getValue()) {
            if (sbInstance.length() > 0) {
                sbInstance.append(",");
            }
            sbInstance.append(entry.getKey());
        } else {
            isAllInstanceSelected = false;
        }
    }

    //      for (Iterator i=isInstCheck.keySet().iterator(); i.hasNext();) {
    //         String key = (String)i.next();
    //         
    //         if ( (isInstCheck.get(key)) ) {
    //            if (sbInstance.length() > 0) {
    //               sbInstance.append( "," );
    //            }
    //            sbInstance.append( key );
    //         } else {
    //            isInstAll = false;
    //         }
    //      }

    if (isAllInstanceSelected) {
        if (sbInstance.length() > 0) {
            sbInstance.append(",");
        }
        sbInstance.append("ALL");
    }
    param.setInstType(sbInstance.toString()); // post.append( instTmp.toString() + "&" );

    StringBuffer sbMs = new StringBuffer(); // post.append( "MS=" );
    boolean isAllMsSelected = true;
    for (Entry<String, Boolean> entry : isMsCheck.entrySet()) {
        if (entry.getValue()) {
            if (sbMs.length() > 0) {
                sbMs.append(",");
            }
            sbMs.append(entry.getKey());
        } else {
            isAllMsSelected = false;
        }
    }

    //      for (Iterator i=isMsCheck.keySet().iterator(); i.hasNext(); ) {
    //         String key = (String)i.next();
    //         
    //         if ( (isMsCheck.get(key)) ) {
    //            if (msTmp.length() > 0) {
    //               msTmp.append( "," );
    //            }
    //            msTmp.append( key );
    //         } else {
    //            isMsAll = false;
    //         }
    //      }

    if (isAllMsSelected) {
        if (sbMs.length() > 0) {
            sbMs.append(",");
        }
        sbMs.append("ALL");
    }
    param.setMsType(sbMs.toString()); // post.append( msTmp.toString() + "&" );

    if (isIonRadio.get(IonMode.POSITIVE.getKey())) { // if (isIonRadio.get("Posi")) {
        param.setIon(1); // post.append( "ION=1&" );
    } else if (isIonRadio.get(IonMode.NEGATIVE.getKey())) { // } else if (isIonRadio.get("Nega")) {
        param.setIon(-1); // post.append( "ION=-1&" );
    } else {
        param.setIon(0); // post.append( "ION=0&");
    }

    StringBuffer sbPeakValue = new StringBuffer(); // post.append( "VAL=" );
    for (int i = 0; i < ps.length; i++) {
        sbPeakValue.append(ps[i].replace("\t", ",") + "@");
    }
    param.setPeak(sbPeakValue.toString());

    // ???
    setOperationEnbled(false);

    // ?
    dlg.showDialog();

    //      this.param = post.toString();
    this.ps = ps;
    SwingWorker worker = new SwingWorker() {
        private ArrayList<String> result = null;

        public Object construct() {
            // ??-??CGI
            SearchLogic searchLogic = new SearchLogic();
            result = searchLogic.getSearchResult(param);
            return null;
            //            String cgiType = MassBankCommon.CGI_TBL[MassBankCommon.CGI_TBL_NUM_TYPE][MassBankCommon.CGI_TBL_TYPE_SEARCH];
            //            result = mbcommon.execMultiDispatcher(baseUrl, cgiType, SearchPage.this.param);
            //            return null;
        }

        public void finished() {
            // ???
            setOperationEnbled(true);

            // ???
            dlg.hideDialog();

            int total = 0;
            if (result != null && result.size() > 0) {
                total = result.size();

                List<GuiResultTableRow> guiResultTableRows = new ArrayList<GuiResultTableRow>();
                // ?DBTable?
                for (int i = 0; i < total; i++) {
                    String line = (String) result.get(i);
                    String[] item = line.replace("\n", StringUtils.EMPTY).split("\t");
                    String recordId = item[0];
                    String recordTitle = item[1];
                    // Score, Hit
                    String strScore = StringUtils.EMPTY;
                    String strHit = StringUtils.EMPTY;
                    String hitScore = item[2];
                    int pos = hitScore.indexOf(".");
                    if (pos > 0) {
                        strScore = "0" + hitScore.substring(pos);
                        strHit = hitScore.substring(0, pos);
                    } else {
                        strScore = "0";
                        strHit = hitScore;
                    }
                    Double score = Double.parseDouble(strScore);
                    Integer hit = Integer.parseInt(strHit);

                    // Ion
                    int iIon = Integer.parseInt(item[3]);
                    String strIonMode = StringUtils.EMPTY;
                    if (iIon > 0) {
                        strIonMode = "P";
                    } else if (iIon < 0) {
                        strIonMode = "N";
                    } else {
                        strIonMode = "-";
                    }

                    // SiteName
                    String contributor = SiteUtil.getSiteNameByRecordId(recordId);
                    GuiResultTableRow guiResultTableRow = new GuiResultTableRow((i + 1), recordId, recordTitle,
                            contributor, score, hit, strIonMode);
                    guiResultTableRows.add(guiResultTableRow);
                }

                fillGuiResultTableData(guiResultTableRows);
            }

            PeakData peak = new PeakData(SearchPage.this.ps);
            queryPlot.setPeaks(peak, 0);
            compPlot.setPeaks(peak, 0);
            resultTabPane.setSelectedIndex(0);
            setAllPlotAreaRange(queryPlot);
            SearchPage.this.setCursor(Cursor.getDefaultCursor());

            StringBuilder sbHitLabel = new StringBuilder();
            sbHitLabel.append(" ");
            sbHitLabel.append(total);
            sbHitLabel.append(" Hit.    (");
            sbHitLabel.append((PRECURSOR < 1) ? "" : "Precursor : " + PRECURSOR + ", ");
            sbHitLabel.append("Tolerance : ");
            sbHitLabel.append(TOLERANCE);
            sbHitLabel.append(" ");
            sbHitLabel.append((tolUnit1.isSelected()) ? tolUnit1.getText() : tolUnit2.getText());
            sbHitLabel.append(", Cutoff threshold : ");
            sbHitLabel.append(CUTOFF_THRESHOLD);
            sbHitLabel.append(")");
            hitLabel.setText(sbHitLabel.toString());
            hitLabel.setToolTipText(sbHitLabel.toString());

            //            hitLabel.setText(" "
            //                  + total
            //                  + " Hit.    ("
            //                  + ((PRECURSOR < 1) ? "" : "Precursor : " + PRECURSOR + ", ")
            //                  + "Tolerance : "
            //                  + TOLERANCE
            //                  + " "
            //                  + ((tolUnit1.isSelected()) ? tolUnit1.getText()
            //                        : tolUnit2.getText()) + ", Cutoff threshold : "
            //                  + CUTOFF_THRESHOLD + ")");

            //            hitLabel.setToolTipText(" "
            //                  + total
            //                  + " Hit.    ("
            //                  + ((PRECURSOR < 1) ? "" : "Precursor : " + PRECURSOR + ", ")
            //                  + "Tolerance : "
            //                  + TOLERANCE
            //                  + " "
            //                  + ((tolUnit1.isSelected()) ? tolUnit1.getText()
            //                        : tolUnit2.getText()) + ", Cutoff threshold : "
            //                  + CUTOFF_THRESHOLD + ")");
        }
    };
    worker.start();
}

From source file:jp.massbank.spectrumsearch.SearchPage.java

/**
 * ?//from  w w  w .  j  a  v  a  2s .  co  m
 */
private void createWindow() {

    // ??
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.setInitialDelay(50);
    ttm.setDismissDelay(8000);

    // Search?
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(),
            new EmptyBorder(1, 1, 1, 1));
    mainPanel.setBorder(border);

    // *********************************************************************
    // User File Query
    // *********************************************************************
    DefaultTableModel fileDm = new DefaultTableModel();
    fileSorter = new TableSorter(fileDm, TABLE_QUERY_FILE);
    queryFileTable = new JTable(fileSorter) {
        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    queryFileTable.addMouseListener(new TblMouseListener());
    fileSorter.setTableHeader(queryFileTable.getTableHeader());
    queryFileTable.setRowSelectionAllowed(true);
    queryFileTable.setColumnSelectionAllowed(false);
    queryFileTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col = { COL_LABEL_NO, COL_LABEL_NAME, COL_LABEL_ID };
    ((DefaultTableModel) fileSorter.getTableModel()).setColumnIdentifiers(col);
    (queryFileTable.getColumn(queryFileTable.getColumnName(0))).setPreferredWidth(44);
    (queryFileTable.getColumn(queryFileTable.getColumnName(1))).setPreferredWidth(LEFT_PANEL_WIDTH - 44);
    (queryFileTable.getColumn(queryFileTable.getColumnName(2))).setPreferredWidth(70);

    ListSelectionModel lm = queryFileTable.getSelectionModel();
    lm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lm.addListSelectionListener(new LmFileListener());
    queryFilePane = new JScrollPane(queryFileTable);
    queryFilePane.addMouseListener(new PaneMouseListener());
    queryFilePane.setPreferredSize(new Dimension(300, 300));

    // *********************************************************************
    // Result
    // *********************************************************************
    DefaultTableModel resultDm = new DefaultTableModel();
    resultSorter = new TableSorter(resultDm, TABLE_RESULT);
    resultTable = new JTable(resultSorter) {
        @Override
        public String getToolTipText(MouseEvent me) {
            //            super.getToolTipText(me);
            // ?????
            Point pt = me.getPoint();
            int row = rowAtPoint(pt);
            if (row < 0) {
                return null;
            } else {
                int nameCol = getColumnModel().getColumnIndex(COL_LABEL_NAME);
                return " " + getValueAt(row, nameCol) + " ";
            }
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    resultTable.addMouseListener(new TblMouseListener());
    resultSorter.setTableHeader(resultTable.getTableHeader());

    JPanel dbPanel = new JPanel();
    dbPanel.setLayout(new BorderLayout());
    resultPane = new JScrollPane(resultTable);
    resultPane.addMouseListener(new PaneMouseListener());

    resultTable.setRowSelectionAllowed(true);
    resultTable.setColumnSelectionAllowed(false);
    resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col2 = { COL_LABEL_NAME, COL_LABEL_SCORE, COL_LABEL_HIT, COL_LABEL_ID, COL_LABEL_ION,
            COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };

    resultDm.setColumnIdentifiers(col2);
    (resultTable.getColumn(resultTable.getColumnName(0))).setPreferredWidth(LEFT_PANEL_WIDTH - 180);
    (resultTable.getColumn(resultTable.getColumnName(1))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(2))).setPreferredWidth(20);
    (resultTable.getColumn(resultTable.getColumnName(3))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(4))).setPreferredWidth(20);
    (resultTable.getColumn(resultTable.getColumnName(5))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(6))).setPreferredWidth(50);

    ListSelectionModel lm2 = resultTable.getSelectionModel();
    lm2.addListSelectionListener(new LmResultListener());

    resultPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, 200));
    dbPanel.add(resultPane, BorderLayout.CENTER);

    // *********************************************************************
    // DB Query
    // *********************************************************************
    DefaultTableModel dbDm = new DefaultTableModel();
    querySorter = new TableSorter(dbDm, TABLE_QUERY_DB);
    queryDbTable = new JTable(querySorter) {
        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    queryDbTable.addMouseListener(new TblMouseListener());
    querySorter.setTableHeader(queryDbTable.getTableHeader());
    queryDbPane = new JScrollPane(queryDbTable);
    queryDbPane.addMouseListener(new PaneMouseListener());

    int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
    queryDbPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, h));
    queryDbTable.setRowSelectionAllowed(true);
    queryDbTable.setColumnSelectionAllowed(false);
    queryDbTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col3 = { COL_LABEL_ID, COL_LABEL_NAME, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };
    DefaultTableModel model = (DefaultTableModel) querySorter.getTableModel();
    model.setColumnIdentifiers(col3);

    // 
    queryDbTable.getColumn(queryDbTable.getColumnName(0)).setPreferredWidth(70);
    queryDbTable.getColumn(queryDbTable.getColumnName(1)).setPreferredWidth(LEFT_PANEL_WIDTH - 70);
    queryDbTable.getColumn(queryDbTable.getColumnName(2)).setPreferredWidth(70);
    queryDbTable.getColumn(queryDbTable.getColumnName(3)).setPreferredWidth(50);

    ListSelectionModel lm3 = queryDbTable.getSelectionModel();
    lm3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lm3.addListSelectionListener(new LmQueryDbListener());

    // ?
    JPanel btnPanel = new JPanel();
    btnName.addActionListener(new BtnSearchNameListener());
    btnAll.addActionListener(new BtnAllListener());
    btnPanel.add(btnName);
    btnPanel.add(btnAll);

    parentPanel2 = new JPanel();
    parentPanel2.setLayout(new BoxLayout(parentPanel2, BoxLayout.PAGE_AXIS));
    parentPanel2.add(btnPanel);
    parentPanel2.add(queryDbPane);

    // ?
    JPanel dispModePanel = new JPanel();
    isDispSelected = dispSelected.isSelected();
    isDispRelated = dispRelated.isSelected();
    if (isDispSelected) {
        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    } else if (isDispRelated) {
        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    Object[] retRadio = new Object[] { dispSelected, dispRelated };
    for (int i = 0; i < retRadio.length; i++) {
        ((JRadioButton) retRadio[i]).addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if (isDispSelected != dispSelected.isSelected() || isDispRelated != dispRelated.isSelected()) {

                    isDispSelected = dispSelected.isSelected();
                    isDispRelated = dispRelated.isSelected();

                    // ??
                    resultTable.clearSelection();
                    resultPlot.clear();
                    compPlot.setPeaks(null, 1);
                    resultPlot.setPeaks(null, 0);
                    setAllPlotAreaRange();
                    pkgView.initResultRecInfo();

                    if (isDispSelected) {
                        resultTable.getSelectionModel()
                                .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                    } else if (isDispRelated) {
                        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                    }
                }
            }
        });
    }
    ButtonGroup disGroup = new ButtonGroup();
    disGroup.add(dispSelected);
    disGroup.add(dispRelated);
    dispModePanel.add(lbl2);
    dispModePanel.add(dispSelected);
    dispModePanel.add(dispRelated);

    JPanel paramPanel = new JPanel();
    paramPanel.add(etcPropertyButton);
    etcPropertyButton.setMargin(new Insets(0, 10, 0, 10));
    etcPropertyButton.addActionListener(new ActionListener() {
        private ParameterSetWindow ps = null;

        public void actionPerformed(ActionEvent e) {
            // ??????????
            if (!isSubWindow) {
                ps = new ParameterSetWindow(getParentFrame());
            } else {
                ps.requestFocus();
            }
        }
    });

    JPanel optionPanel = new JPanel();
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel.add(dispModePanel);
    optionPanel.add(paramPanel);

    // PackageView?????
    pkgView = new PackageViewPanel();
    pkgView.initAllRecInfo();

    queryTabPane.addTab("DB", parentPanel2);
    queryTabPane.setToolTipTextAt(TAB_ORDER_DB, "Query from DB.");
    queryTabPane.addTab("File", queryFilePane);
    queryTabPane.setToolTipTextAt(TAB_ORDER_FILE, "Query from user file.");
    queryTabPane.setSelectedIndex(TAB_ORDER_DB);
    queryTabPane.setFocusable(false);
    queryTabPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {

            // ?
            queryPlot.clear();
            compPlot.clear();
            resultPlot.clear();
            queryPlot.setPeaks(null, 0);
            compPlot.setPeaks(null, 1);
            resultPlot.setPeaks(null, 0);

            // PackageView?
            pkgView.initAllRecInfo();

            // DB Hit?
            if (resultTabPane.getTabCount() > 0) {
                resultTabPane.setSelectedIndex(0);
            }
            DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel();
            dataModel.setRowCount(0);
            hitLabel.setText(" ");

            // DB?User File??????
            queryTabPane.update(queryTabPane.getGraphics());
            if (queryTabPane.getSelectedIndex() == TAB_ORDER_DB) {
                parentPanel2.update(parentPanel2.getGraphics());
                updateSelectQueryTable(queryDbTable);
            } else if (queryTabPane.getSelectedIndex() == TAB_ORDER_FILE) {
                queryFilePane.update(queryFilePane.getGraphics());
                updateSelectQueryTable(queryFileTable);
            }
        }
    });

    //       
    JPanel queryPanel = new JPanel();
    queryPanel.setLayout(new BorderLayout());
    queryPanel.add(queryTabPane, BorderLayout.CENTER);
    queryPanel.add(optionPanel, BorderLayout.SOUTH);
    queryPanel.setMinimumSize(new Dimension(0, 170));

    JPanel jtp2Panel = new JPanel();
    jtp2Panel.setLayout(new BorderLayout());
    jtp2Panel.add(dbPanel, BorderLayout.CENTER);
    jtp2Panel.add(hitLabel, BorderLayout.SOUTH);
    jtp2Panel.setMinimumSize(new Dimension(0, 70));
    Color colorGreen = new Color(0, 128, 0);
    hitLabel.setForeground(colorGreen);

    resultTabPane.addTab("Result", jtp2Panel);
    resultTabPane.setToolTipTextAt(TAB_RESULT_DB, "Result of DB hit.");
    resultTabPane.setFocusable(false);

    queryPlot.setMinimumSize(new Dimension(0, 100));
    compPlot.setMinimumSize(new Dimension(0, 120));
    resultPlot.setMinimumSize(new Dimension(0, 100));
    int height = initAppletHight / 3;
    JSplitPane jsp_cmp2db = new JSplitPane(JSplitPane.VERTICAL_SPLIT, compPlot, resultPlot);
    JSplitPane jsp_qry2cmp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPlot, jsp_cmp2db);
    jsp_cmp2db.setDividerLocation(height);
    jsp_qry2cmp.setDividerLocation(height - 25);
    jsp_qry2cmp.setMinimumSize(new Dimension(190, 0));

    viewTabPane.addTab("Compare View", jsp_qry2cmp);
    viewTabPane.addTab("Package View", pkgView);
    viewTabPane.setToolTipTextAt(TAB_VIEW_COMPARE, "Comparison of query and result spectrum.");
    viewTabPane.setToolTipTextAt(TAB_VIEW_PACKAGE, "Package comparison of query and result spectrum.");
    viewTabPane.setSelectedIndex(TAB_VIEW_COMPARE);
    viewTabPane.setFocusable(false);

    JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPanel, resultTabPane);
    jsp.setDividerLocation(310);
    jsp.setMinimumSize(new Dimension(180, 0));
    jsp.setOneTouchExpandable(true);

    JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jsp, viewTabPane);
    int divideSize = (int) (initAppletWidth * 0.4);
    divideSize = (divideSize >= 180) ? divideSize : 180;
    jsp2.setDividerLocation(divideSize);
    jsp2.setOneTouchExpandable(true);

    mainPanel.add(jsp2, BorderLayout.CENTER);
    add(mainPanel);

    queryPlot.setSearchPage(this);
    compPlot.setSearchPage(this);
    resultPlot.setSearchPage(this);

    setJMenuBar(MenuBarGenerator.generateMenuBar(this));
}

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

/**
 * Adds a new channel that is passed in and then sets the overall panel to edit that channel.
 *///  w ww  .  j  a  va2 s .c  om
public void addChannel(Channel channel, String groupId) {
    loadingChannel = true;
    lastModelIndex = -1;
    currentChannel = channel;
    saveGroupId = groupId;

    sourceSourceDropdown.setModel(new javax.swing.DefaultComboBoxModel(
            LoadedExtensions.getInstance().getSourceConnectors().keySet().toArray()));
    destinationSourceDropdown.setModel(new javax.swing.DefaultComboBoxModel(
            LoadedExtensions.getInstance().getDestinationConnectors().keySet().toArray()));

    Connector sourceConnector = makeNewConnector(false);
    sourceConnector.setName("sourceConnector");
    sourceConnector.setTransportName(SOURCE_DEFAULT);
    Transformer sourceTransformer = new Transformer();

    // Set the default inbound and outbound dataType and properties
    String defaultDataType = UIConstants.DATATYPE_DEFAULT;
    // If the default data type is not loaded, use the first data type that is.
    if (!LoadedExtensions.getInstance().getDataTypePlugins().containsKey(defaultDataType)
            && LoadedExtensions.getInstance().getDataTypePlugins().size() > 0) {
        defaultDataType = LoadedExtensions.getInstance().getDataTypePlugins().keySet().iterator().next();
    }

    // Use a different properties object for the inbound and outbound
    DataTypeProperties defaultInboundProperties = LoadedExtensions.getInstance().getDataTypePlugins()
            .get(defaultDataType).getDefaultProperties();
    DataTypeProperties defaultOutboundProperties = LoadedExtensions.getInstance().getDataTypePlugins()
            .get(defaultDataType).getDefaultProperties();

    sourceTransformer.setInboundDataType(defaultDataType);
    sourceTransformer.setInboundProperties(defaultInboundProperties);
    sourceTransformer.setOutboundDataType(defaultDataType);
    sourceTransformer.setOutboundProperties(defaultOutboundProperties);

    sourceConnector.setTransformer(sourceTransformer);

    currentChannel.setSourceConnector(sourceConnector);
    setLastModified();

    try {
        ServerSettings serverSettings = parent.mirthClient.getServerSettings();
        currentChannel.getProperties().setMetaDataColumns(serverSettings.getDefaultMetaDataColumns());
        if (serverSettings.getQueueBufferSize() != null && serverSettings.getQueueBufferSize() > 0) {
            defaultQueueBufferSize = serverSettings.getQueueBufferSize();
        }
    } catch (ClientException e) {
        parent.alertThrowable(parent, e, "Error loading default metadata columns: " + e.getMessage());
    }

    loadChannelInfo();
    makeDestinationTable(true);
    updateMetaDataTable();

    setDestinationVariableList();
    loadingChannel = false;
    channelView.setSelectedIndex(0);
    summaryNameField.requestFocus();
    parent.setSaveEnabled(true);

    DefaultTableModel model = (DefaultTableModel) tagTable.getModel();
    model.setRowCount(0);

    Map<String, String> sourceResourceIds = new LinkedHashMap<String, String>();
    sourceResourceIds.put(ResourceProperties.DEFAULT_RESOURCE_ID, ResourceProperties.DEFAULT_RESOURCE_NAME);
    ((SourceConnectorPropertiesInterface) currentChannel.getSourceConnector().getProperties())
            .getSourceConnectorProperties().setResourceIds(sourceResourceIds);

    for (Connector destinationConnector : currentChannel.getDestinationConnectors()) {
        Map<String, String> destinationResourceIds = new LinkedHashMap<String, String>();
        destinationResourceIds.put(ResourceProperties.DEFAULT_RESOURCE_ID,
                ResourceProperties.DEFAULT_RESOURCE_NAME);
        ((DestinationConnectorPropertiesInterface) destinationConnector.getProperties())
                .getDestinationConnectorProperties().setResourceIds(destinationResourceIds);
    }
    setResourceIds();
}

From source file:edu.harvard.i2b2.patientMapping.ui.PatientMappingJPanel.java

private void jImportButtonActionPerformed(java.awt.event.ActionEvent evt) {
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            String fileName = openFileDialog();
            //if (fileName != null) {
            //String fileName = dialog.getFileName();
            if (fileName != null && fileName.trim().length() > 0) {
                log.info("Selected file: " + fileName);
                FileReader fr;//from w  w w.j  ava  2 s .c om
                BufferedReader br = null;
                try {
                    fr = new FileReader(new File(fileName));
                    br = new BufferedReader(fr);
                    String line = br.readLine();
                    //if(!line.startsWith("@@i2b2 patient mapping file@@")) {
                    //   java.awt.EventQueue.invokeLater(new Runnable() {
                    //      public void run() {
                    //setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    //         JOptionPane.showMessageDialog(jLabel1, "The file is not in a valid format.", "Error importing", JOptionPane.ERROR_MESSAGE);
                    //      }
                    //   });
                    //JOptionPane.showMessageDialog(null, "The file is not a valid.", "Error importing", JOptionPane.ERROR_MESSAGE);
                    //   return;
                    //}
                    //line = br.readLine();
                    log.info("column name: " + line);
                    String[] cols = line.split(",");

                    DefaultTableModel model = new DefaultTableModel(cols, 200) {

                        @Override
                        public boolean isCellEditable(int arg0, int arg1) {
                            return false;
                        }

                    }; //{
                       //@SuppressWarnings("unchecked")
                       //Class[] types = new Class[] { java.lang.Boolean.class,
                       //java.lang.String.class };

                    //@SuppressWarnings("unchecked")
                    //public Class getColumnClass(int columnIndex) {
                    //if(columnIndex ==0) {
                    //return java.lang.Boolean.class;
                    //}
                    //return java.lang.Object.class;
                    //}
                    // };
                    jTable1.setModel(model);

                    String[] row;
                    int rowCount = 0;
                    line = br.readLine();
                    while (line != null) {
                        log.info(line);
                        row = line.split(",");
                        String id = "";
                        for (int i = 0; i < row.length; i++) {
                            id = row[i];
                            //if(cols[i].indexOf("_E") > 0) {
                            //////id = decryptID(id);
                            //}
                            //decryptID(row[i]);
                            jTable1.setValueAt(id, rowCount, i);
                        }
                        rowCount++;
                        line = br.readLine();
                    }
                    model.setRowCount(rowCount);
                    br.close();
                } catch (Exception e) {
                    e.printStackTrace();
                    if (br != null) {
                        try {
                            br.close();
                        } catch (Exception e1) {
                        }
                    }
                }
            }
            //}      
        }
    });
}