JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); // id = org.columba.example.HelloWorld$HelloWorldPlugin String id = (String) value; //String userVisibleName = pluginHandler.getUserVisibleName(id); String userVisibleName = id; label.setText(userVisibleName); return label;
return new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); PlasticTheme theme = (PlasticTheme) value; label.setText(theme.getName()); return label; } };
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/core/src/main/java/org/columba/core/gui/config/ThemeComboBoxRenderer.java File path: /columba-1.4-src/core/src/main/java/org/columba/core/gui/themes/plugin/PlasticLookAndFeelConfigPlugin.java
Method name: Component getListCellRendererComponent(JList, Object, int, boolean, boolean) Method name: ListCellRenderer createThemeRenderer()
Number of AST nodes: 5 Number of AST nodes: 1
1
JLabel label = (JLabel) super.getListCellRendererComponent(list,
1
return new DefaultListCellRenderer() {
2
                public Component getListCellRendererComponent(JList list,
2
 value,
3
                    Object value,
3
				index, isSelected, cellHasFocus);
4
 int index, boolean isSelected,
4
		// id = org.columba.example.HelloWorld$HelloWorldPlugin
5
		String id = (String) value;
6
		//String userVisibleName = pluginHandler.getUserVisibleName(id);
7
		String userVisibleName = id;
8
		
5
                    boolean cellHasFocus) {
6
                    JLabel label = (JLabel) super.getListCellRendererComponent(list,
7
                            value, index, isSelected, cellHasFocus);
8
                    PlasticTheme theme = (PlasticTheme) value;
9
label.setText(userVisibleName);
9
                    label.setText(theme.getName());
10
		return label
10
                    return label;
11
                }
11
;
12
            };
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are in different classes
Number of node comparisons5
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                                                                                                                                                                                                              
    2
    String id = (String)value;
                                                          
    3
    String userVisibleName = id;
                                                              
    4
    label.setText(userVisibleName);
    4
    label.setText(userVisibleName);
    Preondition Violations
    Unmatched statement label.setText(userVisibleName); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                        
    5
    return label;
    5
    return label;
    1
    return new DefaultListCellRenderer() {...};
    Differences
    Expression1Expression2Difference
    javax.swing.JLabelSUBCLASS_TYPE_MISMATCH
    labelnew DefaultListCellRenderer(){ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus){ JLabel label=(JLabel)super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus); PlasticTheme theme=(PlasticTheme)value; label.setText(theme.getName()); return label; } } TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression label cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new DefaultListCellRenderer(){ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus){ JLabel label=(JLabel)super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus); PlasticTheme theme=(PlasticTheme)value; label.setText(theme.getName()); return label; } } cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Super method call return new DefaultListCellRenderer(){ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus){ JLabel label=(JLabel)super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus); PlasticTheme theme=(PlasticTheme)value; label.setText(theme.getName()); return label; } } ; cannot be extracted from method
    1
    return new DefaultListCellRenderer() {...};
    Precondition Violations (5)
    Row Violation
    1Unmatched statement label.setText(userVisibleName); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Expression label cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new DefaultListCellRenderer(){ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus){ JLabel label=(JLabel)super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus); PlasticTheme theme=(PlasticTheme)value; label.setText(theme.getName()); return label; } } cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Super method call return new DefaultListCellRenderer(){ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus){ JLabel label=(JLabel)super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus); PlasticTheme theme=(PlasticTheme)value; label.setText(theme.getName()); return label; } } ; cannot be extracted from method
    5The refactoring of the clones is infeasible, because classes org.columba.core.gui.config.ThemeComboBoxRenderer and org.columba.core.gui.themes.plugin.PlasticLookAndFeelConfigPlugin do not have a common superclass