//先初始化变量
startVersion = 0;
stopVersion = 0;
reviewboardClient = null;
SVNRevision fromRevision = null;
SVNRevision toRevision = null;
Object[] selectedObjects = selection.toArray();
//请求方式:(1)右键Team,显示资源历史记录
if (selectedObjects[0] instanceof ILogEntry) {
selectedSVNResources = new ISVNResource[2];
selectedSVNResources[0] = ((ILogEntry)selectedObjects[0]).getResource();
toRevision = ((ILogEntry)selectedObjects[0]).getRevision();
if (selectedObjects.length > 1) {
selectedSVNResources[1] = ((ILogEntry)selectedObjects[1]).getResource();
fromRevision = ((ILogEntry)selectedObjects[1]).getRevision();
}
}
//请求方式:(2)从SVN资源库直接打开历史记录的情况(这种情况下无法获得IResource)
if ( null == selectedSVNResources || selectedSVNResources.length == 0) {
selectedSVNResources = getSelectedRemoteResources();
if ( null != selectedSVNResources && selectedSVNResources.length > 0 ) {
if (selectedSVNResources[0] instanceof ISVNRemoteResource)
toRevision = ((ISVNRemoteResource)selectedSVNResources[0]).getRevision();
if (selectedSVNResources.length > 1 && selectedSVNResources[1] instanceof ISVNRemoteResource)
fromRevision = ((ISVNRemoteResource)selectedSVNResources[1]).getRevision();
}
}
if( null == selectedSVNResources || selectedSVNResources.length == 0 ){
return ;
}
ArrayList<IResource> selectedResourceList = new ArrayList<IResource>();
for( ISVNResource svnResourceTmp : selectedSVNResources ){
if( null == svnResourceTmp ){
continue;
}
IResource resource = svnResourceTmp.getResource();
if( null == resource ){
continue;
}
//确认resourceList已经不包含重复值
boolean isExsit = false;
for( IResource resourceTmp : selectedResourceList){
if( resourceTmp.getLocation().toString().equals(resource.getLocation().toString())){
isExsit = true;
break;
}
}
if( !isExsit ){
selectedResourceList.add( resource );
}
}
selectedResources = selectedResourceList.toArray( new IResource[selectedResourceList.size()] );
final IReviewboardClientRepository reviewboardClientRepository = SVNClientRepositoryAwair.getReviewboardClientRepository();
//友好化用户体验
if( null == reviewboardClientRepository.getClientFromUrlToClientMap()){
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if( null != reviewboardClientRepository ){
if( null != monitor ){
monitor.setTaskName(RbSubclipseMessages.getString("PROGRESS_READINGCACHE")); //$NON-NLS-1$
monitor.worked(1);
}
try {
reviewboardClient = reviewboardClientRepository.getClient(false, monitor);
} catch (OperationCanceledException e) {
return ;
}
}
}
}, true, PROGRESS_DIALOG);
}else{
try {
reviewboardClient = reviewboardClientRepository.getClient(false, null);
} catch (OperationCanceledException e) {
return ;
}
}
if( null == reviewboardClient ){
MessageDialog.openError(getShell(),
RbSubclipseMessages.getString("ERROR_INFORMATION_LABLE"),
RbSubclipseMessages.getString("ERROR_SERVER_NOT_CONFIFIGURED")); //$NON-NLS-1$
return;
}
if( null != fromRevision ){
try {
startVersion = Integer.parseInt(fromRevision.toString());
} catch (NumberFormatException e) {
}
}
if( null != toRevision ){
try {
stopVersion = Integer.parseInt(toRevision.toString());
} catch (NumberFormatException e) {
}
}
if( startVersion > stopVersion ){