/** * Method updateFileVersion * * @param aTargetFileVer R4EFileVersion * @param aSrcFile IFile */ public static void updateFileVersion(R4EFileVersion aTargetFileVer, IFile aSrcFile) { if ((null != aTargetFileVer) && (null != aSrcFile)) { aTargetFileVer.setName(aSrcFile.getName()); aTargetFileVer.setRepositoryPath( ""); // No repositories for workspace files since they are not in source control aTargetFileVer.setResource(aSrcFile); aTargetFileVer.setPlatformURI(ResourceUtils.toPlatformURIStr(aSrcFile)); } }
/** * Method updateFileVersion * * @param aTargetFileVer R4EFileVersion * @param aScmArt ScmArtifact * @throws CoreException */ public static void updateFileVersion(R4EFileVersion aTargetFileVer, ScmArtifact aScmArt) throws CoreException { if ((null != aTargetFileVer) && (null != aScmArt)) { aTargetFileVer.setName(aScmArt.getFileRevision(null).getName()); aTargetFileVer.setVersionID(aScmArt.getId()); final IFileRevision fileRev = aScmArt.getFileRevision(null); if (null != fileRev) { final IStorage fileStore = fileRev.getStorage(null); if (null != fileStore) { final IPath filePath = fileStore.getFullPath(); if (null != filePath) { aTargetFileVer.setRepositoryPath(filePath.toPortableString()); } } } final String fileRelPath = aScmArt.getProjectRelativePath(); if (null == fileRelPath) { R4EUIPlugin.Ftracer.traceDebug( "Invalid relative file path in scmArtifact with path: " + aScmArt.getPath()); } final IProject project = ResourceUtils.getProject(aScmArt.getProjectName()); final IResource resource = ResourceUtils.findResource(project, fileRelPath); aTargetFileVer.setPlatformURI(ResourceUtils.toPlatformURIStr(resource)); aTargetFileVer.setResource(resource); final String projPlatformURI = ResourceUtils.toPlatformURIStr(project); if (null == projPlatformURI) { R4EUIPlugin.Ftracer.traceDebug( "Unable to resolve the project: " + aScmArt.getProjectName() + " platform's URI, in scmArtifact with path: " + aScmArt.getPath()); } } }