ICalendarMediator m = (ICalendarMediator) getFrameMediator(); ICalendarListView list = m.getListView(); // get selected calendar id ICalendarItem calendar = list.getSelected(); if (calendar == null) { JOptionPane.showMessageDialog(FrameManager.getInstance() .getActiveFrame(), "No calendar for import selected."); return; } JFileChooser fc = new JFileChooser(); fc.setMultiSelectionEnabled(true); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileHidingEnabled(false); if (fc.showOpenDialog(frameMediator.getContainer().getFrame()) == JFileChooser.APPROVE_OPTION) { File[] sourceFiles = fc.getSelectedFiles(); if (sourceFiles.length >= 1) { ICalendarStore store = CalendarStoreFactory.getInstance() .getLocaleStore(); Command command = new ImportCalendarCommand( new CalendarCommandReference(store, calendar), sourceFiles); CommandProcessor.getInstance().addOp(command); } }
ICalendarMediator m = (ICalendarMediator) getFrameMediator(); ICalendarView c = m.getCalendarView(); IActivity activity = c.getSelectedActivity(); String id = (String) activity.getId(); if (id == null) { JOptionPane .showMessageDialog(FrameManager.getInstance() .getActiveFrame(), "No event for export selected."); return; } JFileChooser fc = new JFileChooser(); fc.setMultiSelectionEnabled(false); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileHidingEnabled(false); if (fc.showSaveDialog(frameMediator.getContainer().getFrame()) == JFileChooser.APPROVE_OPTION) { File destFile = fc.getSelectedFile(); ICalendarStore store = CalendarStoreFactory.getInstance() .getLocaleStore(); Command command = new SaveEventToFileCommand( new CalendarCommandReference(store, activity), destFile); CommandProcessor.getInstance().addOp(command); }
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/calendar/src/main/java/org/columba/calendar/ui/action/ImportCalendarAction.java File path: /columba-1.4-src/calendar/src/main/java/org/columba/calendar/ui/action/SaveAsAction.java
Method name: void actionPerformed(ActionEvent) Method name: void actionPerformed(ActionEvent)
Number of AST nodes: 16 Number of AST nodes: 16
1
ICalendarMediator m = (ICalendarMediator) getFrameMediator();
1
ICalendarMediator m = (ICalendarMediator) getFrameMediator();
2
		ICalendarListView list = m.getListView();
2
		ICalendarView c = m.getCalendarView();
3
		// get selected calendar id
3
		IActivity activity = c.getSelected
4
		ICalendarItem calendar = list.getSelecte
4
Activity();
5
d();
5
		String id = (String) activity.getId();
6
		if (calendar == null) {
6
		if (id == null) {
7
			JOptionPane
7
			JOptionPane
8
.showMessageDialog(FrameManager.getInstance()
8
					.showMessageDialog(FrameManager.getInstance()
9
					.getActiveFrame(),
9
							.getActiveFrame(),
10
					"No calendar for import selected.");
10
 "No event for export selected.");
11
			return;
11
			return;
12
		}
12
		}
13
		JFileChooser fc = new JFileChooser();
13
		JFileChooser fc = new JFileChooser();
14
		fc.setMultiSelectionEnabled(true);
14
		fc.setMultiSelectionEnabled(false);
15
		fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
15
		fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
16
		fc.setFileHidingEnabled(false);
16
		fc.setFileHidingEnabled(false);
17
		if (fc.showOpenDialog(frameMediator.getContainer().getFrame()) == JFileChooser.APPROVE_OPTION) {
17
		if (fc.showSaveDialog(frameMediator.getContainer().getFrame()) == JFileChooser.APPROVE_OPTION) {
18
			File[] sourceFiles = fc.getSelectedFiles();
18
			File destFile = fc.getSelectedFile();
19
			if (sourceFiles.length >= 1) {
20
				ICalendarStore store = CalendarStoreFactory.getInstance()
19
			ICalendarStore store = CalendarStoreFactory.getInstance()
21
						.getLocaleStore();
20
					.getLocaleStore();
22
				Command command = new ImportCalendarCommand(
21
			Command command = new SaveEventToFileCommand(
23
						new CalendarCommandReference(store, calendar), sourceFiles);
22
					new CalendarCommandReference(store, activity), destFile);
24
				CommandProcessor.getInstance().addOp(command);
23
			CommandProcessor.getInstance().addOp(command);
25
			}
26
		}
24
		}
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.4
Clones locationClones are in different classes having the same super class
Number of node comparisons29
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment9
    Time elapsed for statement mapping (ms)22.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                              
    1
    ICalendarMediator m = (ICalendarMediator)getFrameMediator();
                                                                                  
    2
    ICalendarView c = m.getCalendarView();
                                                                                                
    3
    IActivity activity = c.getSelectedActivity();
                                                                                
    4
    String id = (String)activity.getId();
                                                                                
    8
    JFileChooser fc = new JFileChooser();
                                                                                
    9
    fc.setMultiSelectionEnabled(false);
    Preondition Violations
    Unmatched statement fc.setMultiSelectionEnabled(false); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9
    fc.setMultiSelectionEnabled(false);
                                                                                                              
    10
    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    Preondition Violations
    Unmatched statement fc.setFileSelectionMode(JFileChooser.FILES_ONLY); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10
    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                                                                          
    11
    fc.setFileHidingEnabled(false);
    Preondition Violations
    Unmatched statement fc.setFileHidingEnabled(false); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    11
    fc.setFileHidingEnabled(false);
    12
    File[] sourceFiles = fc.getSelectedFiles();
                                                                                              
    13
    if (sourceFiles.length >= 1)
    13
    if (sourceFiles.length >= 1)
    12
    if (fc.showSaveDialog(frameMediator.getContainer().getFrame()) == JFileChooser.APPROVE_OPTION)
    Differences
    Expression1Expression2Difference
    sourceFiles.lengthfc.showSaveDialog(frameMediator.getContainer().getFrame())TYPE_COMPATIBLE_REPLACEMENT
    1JFileChooser.APPROVE_OPTIONTYPE_COMPATIBLE_REPLACEMENT
    >===OPERATOR_MISMATCH
    Preondition Violations
    Expression sourceFiles.length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression fc.showSaveDialog(frameMediator.getContainer().getFrame()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sourceFiles.length >= 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression fc.showSaveDialog(frameMediator.getContainer().getFrame()) == JFileChooser.APPROVE_OPTION cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    if (fc.showSaveDialog(frameMediator.getContainer().getFrame()) == JFileChooser.APPROVE_OPTION)
                                                                                  
    13
    File destFile = fc.getSelectedFile();
    Preondition Violations
    Unmatched statement File destFile=fc.getSelectedFile(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    File destFile = fc.getSelectedFile();
    14
    ICalendarStore store = CalendarStoreFactory.getInstance().getLocaleStore();
    14
    ICalendarStore store = CalendarStoreFactory.getInstance().getLocaleStore();
    15
    Command command = new ImportCalendarCommand(new CalendarCommandReference(store, calendar), sourceFiles);
    15
    Command command = new ImportCalendarCommand(new CalendarCommandReference(store, calendar), sourceFiles);
    15
    Command command = new SaveEventToFileCommand(new CalendarCommandReference(store, activity), destFile);
    Differences
    Expression1Expression2Difference
    org.columba.calendar.command.ImportCalendarCommandorg.columba.calendar.command.SaveEventToFileCommandSUBCLASS_TYPE_MISMATCH
    calendaractivityVARIABLE_NAME_MISMATCH
    org.columba.calendar.base.api.ICalendarItemorg.columba.calendar.base.api.IActivityVARIABLE_TYPE_MISMATCH
    sourceFilesdestFileVARIABLE_NAME_MISMATCH
    java.io.File[]java.io.FileVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression new ImportCalendarCommand(new CalendarCommandReference(store,calendar),sourceFiles) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new SaveEventToFileCommand(new CalendarCommandReference(store,activity),destFile) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.columba.calendar.base.api.ICalendarItem of variable calendar does not match with type org.columba.calendar.base.api.IActivity of variable activity
    • Make classes org.columba.calendar.base.api.ICalendarItem and org.columba.calendar.base.api.IActivity extend a common superclass
    Type java.io.File[] of variable sourceFiles does not match with type java.io.File of variable destFile
    • Make classes java.io.File[] and java.io.File extend a common superclass
    15
    Command command = new SaveEventToFileCommand(new CalendarCommandReference(store, activity), destFile);
    16
    CommandProcessor.getInstance().addOp(command);
    16
    CommandProcessor.getInstance().addOp(command);
    Precondition Violations (12)
    Row Violation
    1Unmatched statement fc.setMultiSelectionEnabled(false); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement fc.setFileSelectionMode(JFileChooser.FILES_ONLY); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement fc.setFileHidingEnabled(false); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Expression sourceFiles.length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression fc.showSaveDialog(frameMediator.getContainer().getFrame()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression sourceFiles.length >= 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression fc.showSaveDialog(frameMediator.getContainer().getFrame()) == JFileChooser.APPROVE_OPTION cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Unmatched statement File destFile=fc.getSelectedFile(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Expression new ImportCalendarCommand(new CalendarCommandReference(store,calendar),sourceFiles) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression new SaveEventToFileCommand(new CalendarCommandReference(store,activity),destFile) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Type org.columba.calendar.base.api.ICalendarItem of variable calendar does not match with type org.columba.calendar.base.api.IActivity of variable activity
    12Type java.io.File[] of variable sourceFiles does not match with type java.io.File of variable destFile