@Override public void action() throws Throwable { ArrayList<BibtexEntry> entries = new ArrayList<BibtexEntry>(); BibtexEntry[] sel = panel.getSelectedEntries(); for (int i = 0; i < sel.length; i++) { BibtexEntry bibtexEntry = sel[i]; entries.add(bibtexEntry); } final List<FileListEntry> links = AccessLinksForEntries.getExternalLinksForEntries(entries); for (Iterator<FileListEntry> iterator = links.iterator(); iterator.hasNext();) { FileListEntry entry = iterator.next(); System.out.println("Link: " + entry.getLink()); } final JProgressBar prog = new JProgressBar(); prog.setIndeterminate(true); final JDialog diag = new JDialog(panel.frame(), false); diag.getContentPane().add(prog, BorderLayout.CENTER); diag.pack(); diag.setLocationRelativeTo(panel.frame()); diag.setVisible(true); Thread t = new Thread(new Runnable() { public void run() { AccessLinksForEntries.copyExternalLinksToDirectory(links, new File("/home/alver/tmp"), panel.metaData(), prog, false, new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { diag.dispose(); } }); } }); t.start(); }
public void actionPerformed(ActionEvent event) { ArrayList<BibtexEntry> entries = new ArrayList<BibtexEntry>(); for (BibtexEntry e: JabRef.jrf.basePanel().getSelectedEntries()) { entries.add(e); } if (entries.isEmpty()) { JabRef.jrf.basePanel().output(Globals.lang("No entries selected.")); return; } JDialog diag = new JDialog(JabRef.jrf, true); final NamedCompound nc = new NamedCompound(Globals.lang("Automatically set file links")); Util.autoSetLinks(entries, nc, null, null, JabRef.jrf.basePanel().metaData(), new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getID() > 0) { // entry has been updated in Util.autoSetLinks, only treat nc and status message if (nc.hasEdits()) { nc.end(); JabRef.jrf.basePanel().undoManager.addEdit(nc); JabRef.jrf.basePanel().markBaseChanged(); } JabRef.jrf.output(Globals.lang("Finished autosetting external links.")); } else JabRef.jrf.output(Globals.lang("Finished autosetting external links.") +" "+Globals.lang("No files found.")); } }, diag); }
Clone fragments detected by clone detection tool
File path: /jabref-2.10/src/java/net/sf/jabref/external/AccessLinksForEntries.java File path: /jabref-2.10/src/java/net/sf/jabref/AutoLinkFilesAction.java
Method name: void action() Method name: void actionPerformed(ActionEvent)
Number of AST nodes: 3 Number of AST nodes: 2
1
@Override
1
public void actionPerformed(ActionEvent event) {
2
        public void action() throws Throwable {
2
        ArrayList<BibtexEntry> entries = new ArrayList<BibtexEntry>();
3
3
        for (BibtexEntry e: JabRef.jrf.basePanel().getSelectedEntries()) {
4
            ArrayList<BibtexEntry> entries = new ArrayList<BibtexEntry>();
4
            entries.add(e);
5
            BibtexEntry[] sel = panel.getSelectedEntries();
5
        }
6
            for (int i = 0; i < sel.length; i++) {
6
        if (entries.isEmpty()) {
7
                BibtexEntry bibtexEntry = sel[i];
7
            JabRef.jrf.basePanel().output(Globals.lang("No entries selected."));
8
                entries.add(bibtexEntry);
8
            return;
9
            }
9
        }
10
            final List<FileListEntry> links =
10
        JDialog diag = new JDialog(JabRef.jrf, true);
11
                    AccessLinksForEntries.getExternalLinksForEntries(entries);
11
        final NamedCompound nc = new NamedCompound(Globals.lang("Automatically set file links"));
12
            for (Iterator<FileListEntry> iterator = links.iterator(); iterator.hasNext();) {
12
        Util.autoSetLinks(entries, nc, null, null, JabRef.jrf.basePanel().metaData(), new ActionListener() {
13
                FileListEntry entry = iterator.next();
13
            public void actionPerformed(ActionEvent e) {
14
                System.out.println("Link: " + entry.getLink());
14
                if (e.getID() > 0) {
15
            }
15
                    // entry has been updated in Util.autoSetLinks, only treat nc and status message
16
16
                    if (nc.hasEdits()) {
17
            final JProgressBar prog = new JProgressBar();
17
                        nc.end();
18
            prog.setIndeterminate(true);
18
                        JabRef.jrf.basePanel().undoManager.addEdit(nc);
19
            final JDialog diag = new JDialog(panel.frame(), false);
19
                        JabRef.jrf.basePanel().markBaseChanged();
20
            diag.getContentPane().add(prog, BorderLayout.CENTER);
20
                    }
21
            diag.pack();
21
                    JabRef.jrf.output(Globals.lang("Finished autosetting external links."));
22
            diag.setLocationRelativeTo(panel.frame());
22
                }
23
            diag.setVisible(true);
23
                else JabRef.jrf.output(Globals.lang("Finished autosetting external links.")
24
            Thread t = new Thread(new Runnable() {
24
                    +" "+Globals.lang("No files found."));
25
                public void run() {
25
            }
26
                    AccessLinksForEntries.copyExternalLinksToDirectory(links,
26
        }, diag);
27
                            new File("/home/alver/tmp"), panel.metaData(), prog, false,
27
    }
28
                            new ActionListener() {
29
                                public void actionPerformed(ActionEvent actionEvent) {
30
                                    diag.dispose();
31
                                }
32
                            });
33
                }
34
            });
35
            t.start();
36
37
            
38
        }
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.600
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    for (int i = 0; i < sel.length; i++)
    3
    for (int i = 0; i < sel.length; i++)
    2
    for (BibtexEntry e : JabRef.jrf.basePanel().getSelectedEntries())
    Differences
    Expression1Expression2Difference
    bibtexEntryeVARIABLE_NAME_MISMATCH
    selJabRef.jrf.basePanel().getSelectedEntries()TYPE_COMPATIBLE_REPLACEMENT
    selJabRef.jrf.basePanel().getSelectedEntries()TYPE_COMPATIBLE_REPLACEMENT
    2
    for (BibtexEntry e : JabRef.jrf.basePanel().getSelectedEntries())
    4
    BibtexEntry bibtexEntry = sel[i];
    4
    BibtexEntry bibtexEntry = sel[i];
    Differences
    Expression1Expression2Difference
    bibtexEntryeVARIABLE_NAME_MISMATCH
    selJabRef.jrf.basePanel().getSelectedEntries()TYPE_COMPATIBLE_REPLACEMENT
                                                                        
    5
    entries.add(bibtexEntry);
    5
    entries.add(bibtexEntry);
    3
    entries.add(e);
    Differences
    Expression1Expression2Difference
    bibtexEntryeVARIABLE_NAME_MISMATCH
    3
    entries.add(e);
    Precondition Violations (0)
    Row Violation