Source:
public IResource copy(String newName, boolean copySuppFiles, boolean copyAsLink) { IResource copiedExpResource = super.copy(newName, copySuppFiles, true); if (copyAsLink) { return copiedExpResource; } TmfExperimentFolder experimentsFolder = getProject().getExperimentsFolder(); TmfTraceFolder tracesFolder = getProject().getTracesFolder(); if (experimentsFolder == null || copiedExpResource == null || tracesFolder == null) { return null; } experimentsFolder.refreshChildren(); TmfExperimentElement copiedExperiment = experimentsFolder.getExperiment(copiedExpResource); if (copiedExperiment == null) { return null; } List<TmfTraceElement> originalExpTraces = copiedExperiment.getTraces(); Map<IResource, String> copiedTraceResources = new HashMap<>(); for (TmfTraceElement originalExpTrace : originalExpTraces) { TmfTraceElement traceElement = originalExpTrace.getElementUnderTraceFolder(); IFolder newFolder = tracesFolder.getResource().getFolder(newName); IPath traceElementPath = traceElement.getPath().makeRelativeTo(tracesFolder.getPath()); IFolder traceDestinationFolder = newFolder.getFolder(traceElementPath.removeLastSegments(1)); try { if (!traceDestinationFolder.exists()) { TraceUtils.createFolder(traceDestinationFolder, null); } } catch (CoreException e) { Activator.getDefault().logError("Error copying experiment", e); } IPath newTracePath = newFolder.getFullPath().append(traceElementPath); String elementPath = new Path(newName).append(traceElementPath).toString(); copiedTraceResources.put(traceElement.copy(copySuppFiles, copyAsLink, newTracePath), elementPath); } for (TmfTraceElement originalExpTrace : originalExpTraces) { try { copiedExperiment.deleteTraceResource(originalExpTrace.getResource()); } catch (CoreException e) { Activator.getDefault().logError("Error copying experiment", e); } } for (Entry<IResource, String> copiedTraceEntry : copiedTraceResources.entrySet()) { copiedExperiment.addTrace(copiedTraceEntry.getKey(), copiedTraceEntry.getValue(), false); } return copiedExpResource; }

Target:
public IResource copy(String newName, boolean copySuppFiles, boolean copyAsLink) { IResource copiedExpResource = super.copy(newName, copySuppFiles, true); if (copyAsLink) { return copiedExpResource; } TmfExperimentFolder experimentsFolder = getProject().getExperimentsFolder(); TmfTraceFolder tracesFolder = getProject().getTracesFolder(); if (experimentsFolder == null || copiedExpResource == null || tracesFolder == null) { return null; } experimentsFolder.refreshChildren(); TmfExperimentElement copiedExperiment = experimentsFolder.getExperiment(copiedExpResource); if (copiedExperiment == null) { return null; } List<TmfTraceElement> originalExpTraces = copiedExperiment.getTraces(); Map<IResource, String> copiedTraceResources = new HashMap<>(); for (TmfTraceElement originalExpTrace : originalExpTraces) { TmfTraceElement traceElement = originalExpTrace.getElementUnderTraceFolder(); IFolder newFolder = tracesFolder.getResource().getFolder(newName); IPath traceElementPath = traceElement.getPath().makeRelativeTo(tracesFolder.getPath()); IFolder traceDestinationFolder = newFolder.getFolder(traceElementPath.removeLastSegments(1)); try { if (!traceDestinationFolder.exists()) { TraceUtils.createFolder(traceDestinationFolder, null); } } catch (CoreException e) { Activator.getDefault().logError("Error copying experiment", e); } IPath newTracePath = newFolder.getFullPath().append(traceElementPath); String elementPath = new Path(newName).append(traceElementPath).toString(); IResource copiedTraceResource = traceElement.copy(copySuppFiles, copyAsLink, newTracePath); if (copiedTraceResource != null) { copiedTraceResources.put(copiedTraceResource, elementPath); } } for (TmfTraceElement originalExpTrace : originalExpTraces) { try { copiedExperiment.deleteTraceResource(originalExpTrace.getResource()); } catch (CoreException e) { Activator.getDefault().logError("Error copying experiment", e); } } for (Entry<IResource, String> copiedTraceEntry : copiedTraceResources.entrySet()) { copiedExperiment.addTrace(copiedTraceEntry.getKey(), copiedTraceEntry.getValue(), false); } return copiedExpResource; }