protected void executeOperation() throws EGLModelException { IPackageFragmentRoot root = (IPackageFragmentRoot) this.getElementToProcess(); IEGLPathEntry rootEntry = root.getRawEGLPathEntry(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // move resource if (!root.isExternal() && (this.updateModelFlags & IPackageFragmentRoot.NO_RESOURCE_MODIFICATION) == 0) { moveResource(root, rootEntry, workspaceRoot); } // update refering projects classpath excluding orignating project IEGLProject originatingProject = root.getEGLProject(); if ((this.updateModelFlags & IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_EGLPATH) != 0) { updateReferringProjectClasspaths(rootEntry.getPath(), originatingProject); } boolean isRename = this.destination.segment(0).equals(originatingProject.getElementName()); boolean updateOriginating = (this.updateModelFlags & IPackageFragmentRoot.ORIGINATING_PROJECT_EGLPATH) != 0; boolean updateDestination = (this.updateModelFlags & IPackageFragmentRoot.DESTINATION_PROJECT_EGLPATH) != 0; // update originating classpath if (updateOriginating) { if (isRename && updateDestination) { renameEntryInClasspath(rootEntry.getPath(), originatingProject); } else { removeEntryFromClasspath(rootEntry.getPath(), originatingProject); } } // update destination classpath if (updateDestination) { if (!isRename || !updateOriginating) { addEntryToEGLPath(rootEntry, workspaceRoot); } // else reference has been updated when updating originating project classpath } }
protected void moveResource( IPackageFragmentRoot root, IEGLPathEntry rootEntry, final IWorkspaceRoot workspaceRoot) throws EGLModelException { final char[][] exclusionPatterns = ((EGLPathEntry) rootEntry).fullExclusionPatternChars(); IResource rootResource = root.getResource(); if (rootEntry.getEntryKind() != IEGLPathEntry.CPE_SOURCE || exclusionPatterns == null) { try { IResource destRes; if ((this.updateModelFlags & IPackageFragmentRoot.REPLACE) != 0 && (destRes = workspaceRoot.findMember(this.destination)) != null) { destRes.delete(this.updateResourceFlags, fMonitor); } rootResource.move(this.destination, this.updateResourceFlags, fMonitor); } catch (CoreException e) { throw new EGLModelException(e); } } else { final int sourceSegmentCount = rootEntry.getPath().segmentCount(); final IFolder destFolder = workspaceRoot.getFolder(this.destination); final IPath[] nestedFolders = getNestedFolders(root); IResourceProxyVisitor visitor = new IResourceProxyVisitor() { public boolean visit(IResourceProxy proxy) throws CoreException { if (proxy.getType() == IResource.FOLDER) { IPath path = proxy.requestFullPath(); if (prefixesOneOf(path, nestedFolders)) { if (equalsOneOf(path, nestedFolders)) { // nested source folder return false; } else { // folder containing nested source folder IFolder folder = destFolder.getFolder(path.removeFirstSegments(sourceSegmentCount)); if ((updateModelFlags & IPackageFragmentRoot.REPLACE) != 0 && folder.exists()) { return true; } folder.create(updateResourceFlags, true, fMonitor); return true; } } else { // subtree doesn't contain any nested source folders IPath destPath = destination.append(path.removeFirstSegments(sourceSegmentCount)); IResource destRes; if ((updateModelFlags & IPackageFragmentRoot.REPLACE) != 0 && (destRes = workspaceRoot.findMember(destPath)) != null) { destRes.delete(updateResourceFlags, fMonitor); } proxy.requestResource().move(destPath, updateResourceFlags, fMonitor); return false; } } else { IPath path = proxy.requestFullPath(); IPath destPath = destination.append(path.removeFirstSegments(sourceSegmentCount)); IResource destRes; if ((updateModelFlags & IPackageFragmentRoot.REPLACE) != 0 && (destRes = workspaceRoot.findMember(destPath)) != null) { destRes.delete(updateResourceFlags, fMonitor); } proxy.requestResource().move(destPath, updateResourceFlags, fMonitor); return false; } } }; try { rootResource.accept(visitor, IResource.NONE); } catch (CoreException e) { throw new EGLModelException(e); } } this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE); }