public class CopyEventCommand extends Command { public CopyEventCommand(CalendarCommandReference ref) { super(ref); } @Override public void execute(IWorkerStatusController worker) throws Exception { ICalendarStore store = ((CalendarCommandReference) getReference()) .getStore(); ICalendarItem calendar = ((CalendarCommandReference) getReference()) .getSrcCalendar(); IActivity eventItem = ((CalendarCommandReference) getReference()) .getActivity(); try { // retrieve event from store IEventInfo event = (IEventInfo) store.get(eventItem.getId()); IEventInfo copy = (IEventInfo) event.createCopy(); // set new calendar id copy.setCalendar(calendar.getId()); // persist modified calendar store.add(copy); } catch (StoreException e1) { JOptionPane.showMessageDialog(FrameManager.getInstance() .getActiveFrame(), e1.getMessage()); e1.printStackTrace();
public class MoveEventCommand extends Command { public MoveEventCommand(CalendarCommandReference ref) { super(ref); } @Override public void execute(IWorkerStatusController worker) throws Exception { ICalendarStore store = ((CalendarCommandReference) getReference()) .getStore(); ICalendarItem calendar = ((CalendarCommandReference) getReference()) .getSrcCalendar(); IActivity eventItem = ((CalendarCommandReference) getReference()) .getActivity(); try { // retrieve event from store IEventInfo event = (IEventInfo) store.get(eventItem.getId()); // set new calendar id event.setCalendar(calendar.getId()); // persist modified calendar store.modify(eventItem.getId(), event); } catch (StoreException e) { JOptionPane.showMessageDialog(FrameManager.getInstance() .getActiveFrame(), e.getMessage()); e.printStackTrace();
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/calendar/src/main/java/org/columba/calendar/command/CopyEventCommand.java File path: /columba-1.4-src/calendar/src/main/java/org/columba/calendar/command/MoveEventCommand.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class CopyEventCommand extends Command {
1
public class MoveEventCommand extends Command {
2
	public CopyEventCommand(CalendarCommandReference ref) {
2
	public MoveEventCommand(CalendarCommandReference ref) {
3
		super(ref);
3
		super(ref);
4
	}
4
	}
5
	@Override
5
	@Override
6
	public void execute(IWorkerStatusController worker) throws Exception {
6
	public void execute(IWorkerStatusController worker) throws Exception {
7
		ICalendarStore store = ((CalendarCommandReference) getReference())
7
		ICalendarStore store = ((CalendarCommandReference) getReference())
8
				.getStore();
8
				.getStore();
9
		ICalendarItem calendar = ((CalendarCommandReference) getReference())
9
		ICalendarItem calendar = ((CalendarCommandReference) getReference())
10
				.getSrcCalendar();
10
				.getSrcCalendar();
11
		IActivity eventItem = ((CalendarCommandReference) getReference())
11
		IActivity eventItem = ((CalendarCommandReference) getReference())
12
				.getActivity();
12
				.getActivity();
13
		try {
13
		try {
14
			// retrieve event from store
14
			// retrieve event from store
15
			IEventInfo event = (IEventInfo) store.get(eventItem.getId());
15
			IEventInfo event = (IEventInfo) store.get(eventItem.getId());
16
			IEventInfo copy = (IEventInfo) event.createCopy();
17
			// set new calendar id
16
			// set new calendar id
18
			copy.setCalendar(calendar.getId());
17
			event.setCalendar(calendar.getId());
19
			// persist modified calendar
18
			// persist modified calendar
20
			store.add(copy);
19
			store.modify(eventItem.getId(), event);
21
		} catch (StoreException e1) {
20
		} catch (StoreException e) {
22
			JOptionPane.showMessageDialog(FrameManager.getInstance()
21
			JOptionPane.showMessageDialog(FrameManager.getInstance()
23
					.getActiveFrame(), e1.getMessage());
22
					.getActiveFrame(), e.getMessage());
24
			e1.printStackTrace();
23
			e.printStackTrace();
25
		
24
		
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0