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); }
public void insertUsingBST() { try { BasePanel panel =frame.basePanel(); final BibtexDatabase database = panel.database(); if (panel != null) { BibtexEntry[] entries = panel.getSelectedEntries(); ArrayList<BibtexEntry> el = new ArrayList<BibtexEntry>(); for (int i = 0; i < entries.length; i++) { el.add(entries[i]); } BstWrapper wrapper = new BstWrapper(); //wrapper.loadBstFile(new File("/home/usr/share/texmf-tetex/bibtex/bst/base/plain.bst")); wrapper.loadBstFile(new File("/home/usr/share/texmf-tetex/bibtex/bst/ams/amsalpha.bst")); Map<String,String> result = wrapper.processEntries(el, database); for (String key : result.keySet()) { System.out.println("Key: "+key); System.out.println("Entry: "+result.get(key)); ooBase.insertMarkedUpTextAtViewCursor(result.get(key), "Default"); } //System.out.println(result); } } catch (Exception ex) { ex.printStackTrace(); } }
Clone fragments detected by clone detection tool
File path: /jabref-2.10/src/java/net/sf/jabref/AutoLinkFilesAction.java File path: /jabref-2.10/src/java/net/sf/jabref/oo/OpenOfficePanel.java
Method name: void actionPerformed(ActionEvent) Method name: void insertUsingBST()
Number of AST nodes: 2 Number of AST nodes: 2
1
public void actionPerformed(ActionEvent event) {
1
public void insertUsingBST() {
2
        ArrayList<BibtexEntry> entries = new ArrayList<BibtexEntry>();
2
        try {
3
        for (BibtexEntry e: JabRef.jrf.basePanel().getSelectedEntries()) {
3
            BasePanel panel =frame.basePanel();
4
            entries.add(e);
4
            final BibtexDatabase database = panel.database();
5
        }
5
            if (panel != null) {
6
        if (entries.isEmpty()) {
6
                BibtexEntry[] entries = panel.getSelectedEntries();
7
            JabRef.jrf.basePanel().output(Globals.lang("No entries selected."));
7
                ArrayList<BibtexEntry> el = new ArrayList<BibtexEntry>();
8
            return;
8
                for (int i = 0; i < entries.length; i++) {
9
        }
9
                    el.add(entries[i]);
10
        JDialog diag = new JDialog(JabRef.jrf, true);
10
                }
11
        final NamedCompound nc = new NamedCompound(Globals.lang("Automatically set file links"));
11
12
        Util.autoSetLinks(entries, nc, null, null, JabRef.jrf.basePanel().metaData(), new ActionListener() {
12
                BstWrapper wrapper = new BstWrapper();
13
            public void actionPerformed(ActionEvent e) {
13
                //wrapper.loadBstFile(new File("/home/usr/share/texmf-tetex/bibtex/bst/base/plain.bst"));
14
                if (e.getID() > 0) {
14
                wrapper.loadBstFile(new File("/home/usr/share/texmf-tetex/bibtex/bst/ams/amsalpha.bst"));
15
                    // entry has been updated in Util.autoSetLinks, only treat nc and status message
15
                Map<String,String> result = wrapper.processEntries(el, database);
16
                    if (nc.hasEdits()) {
16
                for (String key : result.keySet()) {
17
                        nc.end();
17
                    System.out.println("Key: "+key);
18
                        JabRef.jrf.basePanel().undoManager.addEdit(nc);
18
                    System.out.println("Entry: "+result.get(key));
19
                        JabRef.jrf.basePanel().markBaseChanged();
19
                    ooBase.insertMarkedUpTextAtViewCursor(result.get(key), "Default");
20
                    }
20
                }
21
                    JabRef.jrf.output(Globals.lang("Finished autosetting external links."));
21
                //System.out.println(result);
22
                }
22
            }
23
                else JabRef.jrf.output(Globals.lang("Finished autosetting external links.")
23
        } catch (Exception ex) {
24
                    +" "+Globals.lang("No files found."));
24
            ex.printStackTrace();
25
            }
25
        }
26
        }, diag);
26
    }
27
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    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.400
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    for (BibtexEntry e : JabRef.jrf.basePanel().getSelectedEntries())
    2
    for (BibtexEntry e : JabRef.jrf.basePanel().getSelectedEntries())
    7
    for (int i = 0; i < entries.length; i++)
    Differences
    Expression1Expression2Difference
    JabRef.jrf.basePanel().getSelectedEntries()entriesTYPE_COMPATIBLE_REPLACEMENT
    JabRef.jrf.basePanel().getSelectedEntries()entriesTYPE_COMPATIBLE_REPLACEMENT
    7
    for (int i = 0; i < entries.length; i++)
    3
    entries.add(e);
    3
    entries.add(e);
    8
    el.add(entries[i]);
    Differences
    Expression1Expression2Difference
    eentries[i]TYPE_COMPATIBLE_REPLACEMENT
    entrieselVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entries[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    el.add(entries[i]);
    Precondition Violations (2)
    Row Violation
    1Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression entries[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted