Failed to looping in a jtable in JCCD API

孤街醉人 提交于 2019-12-25 05:51:29

问题


I have build code clone application, that using JCCD API that impelemnted ANTLR. To show the code clone, I am using a jtable. This is my screenshot Application : https://docs.google.com/file/d/0B_Rg--NnjJccMERpaTNidzR3cFE/edit?usp=sharing

Okey, from the following screenshot above, I was success to compare one file to another one file. The problem is when I am compare a file to two or more files. The tables just give me the last suspect of code clone.
But, in my netbeans output console, I was success that showed in this link : https://drive.google.com/file/d/0B_Rg--NnjJccWWdVTjdZc1R1bWc/edit?usp=sharing

How can I showed the right output console one to more files to my jTable ?

This is My code :

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.");
    }
}

Thank you so much...

来源:https://stackoverflow.com/questions/24170096/failed-to-looping-in-a-jtable-in-jccd-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!