无法在JCCD API中循环jtable

时间:2014-06-11 18:33:08

标签: java swing jtable

我已经构建了代码克隆应用程序,它使用了阻止ANTLR的JCCD API。为了显示代码克隆,我正在使用jtable。这是我的截图应用程序:https://docs.google.com/file/d/0B_Rg--NnjJccMERpaTNidzR3cFE/edit?usp=sharing

Okey,从上面的截图中,我成功地将一个文件与另一个文件进行比较。问题是当我将文件与两个或多个文件进行比较时。这些表只是给我代码克隆的最后一个嫌疑人。
但是,在我的netbeans输出控制台中,我在此链接中显示了成功:https://drive.google.com/file/d/0B_Rg--NnjJccWWdVTjdZc1R1bWc/edit?usp=sharing

如何在jTable中向一个或多个文件显示正确的输出控制台?

这是我的代码:

public static void printSimilarityGroups(final SimilarityGroupManager groupContainer) {

SimilarityGroup[] simGroups = groupContainer.getSimilarityGroups(); // output similarity groups
    DefaultTableModel model = (DefaultTableModel) Main_Menu.jTable1.getModel();
    model.setRowCount(0);

    List<final_tugas_akhir.Report> theListData = new ArrayList<Report>();

    if (null == simGroups) {
        simGroups = new SimilarityGroup[0];
    }
    if ((null != simGroups) && (0 < simGroups.length)) {
        for (int i = 0; i < simGroups.length; i++) {

            final ASourceUnit[] nodes = simGroups[i].getNodes();
            System.out.println("");
            System.out.println("Similarity Group " + simGroups[i].getGroupId());

            for (int j = 0; j < nodes.length; j++) {

                final SourceUnitPosistion minPos = getFirstNodePosition((ANode) nodes[j]); 
                final SourceUnitPosistion maxPos = getLastNodePosition((ANode) nodes[j]);

                ANode fileNode = (ANode) nodes[j];

                while (fileNode.getTipe() != TipeNode.FILE.getTipe()) {
                    fileNode = fileNode.getParent();
                }

                final_tugas_akhir.Report theResult = new final_tugas_akhir.Report(); //final_tugas_akhir.Report() is a class that contain getter and setter

                //Mixing the Line
                StringBuilder sb = new StringBuilder();
                StringBuilder append = sb.append(minPos.getBaris()).append("."); // get the row
                sb.append(minPos.getKarakter()).append(" - "); //get Character
                StringBuilder append1 = sb.append(maxPos.getBaris()).append(".");// get row
                sb.append(maxPos.getKarakter()); get the character

                theResult.setSimiliaritygroup(simGroups[i].getGroupId()); //Similiarity Group
                theResult.setId(nodes[j].getId()); //setter similiarity id on token
                theResult.setIndikasi(nodes[j].getText()); // setter Kind of Similairity
                theResult.setFileutama(fileNode.getText()); //Files name
                theResult.setLine(sb.toString());

                theListData.add(theResult);
            }
        }
        for (Report report : theListData) {
            //test for the console
            System.out.print(report.getSimiliaritygroup() + " ");
            System.out.print(report.getId() + " ");
            System.out.print(report.getIndikasi() + " ");
            System.out.print(report.getFileutama() + " ");
            System.out.print(report.getLine() + "\n");

            //for table that failed
            model.addRow(new Object[]{
                report.getSimiliaritygroup(),
                report.getId(),
                report.getIndikasi(),
                report.getFileutama(),
                report.getLine()});
        }
    } else {
        System.out.println("No similar nodes found.");
    }
}

非常感谢你......

0 个答案:

没有答案