forked from phoedos/pmd
+ missing utility class for repository access
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7085 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -53,7 +53,6 @@ import net.sourceforge.pmd.eclipse.runtime.PMDRuntimeConstants;
|
||||
import net.sourceforge.pmd.eclipse.runtime.builder.MarkerUtil;
|
||||
import net.sourceforge.pmd.eclipse.ui.PMDUiConstants;
|
||||
import net.sourceforge.pmd.eclipse.ui.nls.StringKeys;
|
||||
import net.sourceforge.pmd.eclipse.ui.views.br.RepositoryUtil;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -0,0 +1,45 @@
|
||||
package net.sourceforge.pmd.eclipse.ui.model;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.team.core.RepositoryProvider;
|
||||
import org.eclipse.team.core.history.IFileRevision;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brian Remedios
|
||||
*/
|
||||
public class RepositoryUtil {
|
||||
|
||||
private static Boolean hasRepositoryAccess;
|
||||
|
||||
private RepositoryUtil() { }
|
||||
|
||||
public static boolean hasRepositoryAccess() {
|
||||
|
||||
if (hasRepositoryAccess != null) return hasRepositoryAccess;
|
||||
|
||||
try {
|
||||
Object cls = Class.forName("org.eclipse.team.core.RepositoryProvider");
|
||||
hasRepositoryAccess = Boolean.TRUE;
|
||||
} catch (ClassNotFoundException e) {
|
||||
hasRepositoryAccess = Boolean.FALSE;
|
||||
}
|
||||
|
||||
return hasRepositoryAccess;
|
||||
}
|
||||
|
||||
public static String authorNameFor(IResource resource) {
|
||||
|
||||
IProject project = resource.getProject();
|
||||
String authorName = null;
|
||||
try {
|
||||
RepositoryProvider provider = RepositoryProvider.getProvider(project);
|
||||
IFileRevision revision = provider.getFileHistoryProvider().getWorkspaceFileRevision(resource);
|
||||
authorName = revision.getAuthor();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return authorName;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user