0

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...

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Fadly Massere
  • 107
  • 1
  • 1
  • 8
  • I don't see what this has to do with ANTLR. Sure, you got some data from a parse which ANTLR's generated parser was responsible for, but the question seems to be mainly Java/Swing related. Btw, your documents are not shared. No need to properly share them: it's better to contain all information here in your question. – Bart Kiers Jun 11 '14 at 19:57
  • but how to show that correct result to a jtable ? it could be perfect project 4 my big antlr project . – Fadly Massere Jun 11 '14 at 23:10
  • I don't know: I've little experience with Swing. – Bart Kiers Jun 12 '14 at 07:49
  • Your images are inaccessible; see also this related [example](http://stackoverflow.com/a/9134371/230513). – trashgod Jun 12 '14 at 09:32
  • the problem is just to display the result in jtable. When I am compared one to one, it is fine. So the jtable displayed the result. But, when I am compared one to many file, the jtable just displaying the last suspect. due, the jtable displaying show all the suspect. I think, I am lost in looping in this part
    for (Report report : theListData) ..., thanks
    – Fadly Massere Jun 12 '14 at 10:42

0 Answers0