use of org.tigris.subversion.subclipse.core.SVNStatus in project subclipse by subclipse.
the class RemoteFolder method getMembers.
/**
* Get the members of this folder at the same revision than this resource
*
* @param monitor a progress monitor
* @return ISVNRemoteResource[] an array of child remoteResources
*/
protected ISVNRemoteResource[] getMembers(IProgressMonitor monitor) throws SVNException {
final IProgressMonitor progress = Policy.monitorFor(monitor);
// $NON-NLS-1$
progress.beginTask(Policy.bind("RemoteFolder.getMembers"), 100);
// Try to hit the cache first.
if (children != null) {
progress.done();
return children;
}
ISVNClientAdapter client = null;
try {
client = getRepository().getSVNClient();
ISVNDirEntryWithLock[] list = client.getListWithLocks(url, getRevision(), SVNRevision.HEAD, false);
List<RemoteResource> result = new ArrayList<RemoteResource>(list.length);
// directories first
for (ISVNDirEntryWithLock entryWithLock : list) {
ISVNDirEntry entry = entryWithLock.getDirEntry();
if (entry.getNodeKind() == SVNNodeKind.DIR) {
result.add(new RemoteFolder(this, getRepository(), url.appendPath(entry.getPath()), getRevision(), entry.getLastChangedRevision(), entry.getLastChangedDate(), entry.getLastCommitAuthor()));
}
}
// files then
for (ISVNDirEntryWithLock entryWithLock : list) {
ISVNDirEntry entry = entryWithLock.getDirEntry();
ISVNLock lock = entryWithLock.getLock();
if (entry.getNodeKind() == SVNNodeKind.FILE) {
RemoteFile remoteFile = new RemoteFile(this, getRepository(), url.appendPath(entry.getPath()), getRevision(), entry.getLastChangedRevision(), entry.getLastChangedDate(), entry.getLastCommitAuthor());
remoteFile.setPegRevision(getRevision());
remoteFile.setLock(lock);
result.add(remoteFile);
}
}
// Save it to the cache
children = (ISVNRemoteResource[]) result.toArray(new ISVNRemoteResource[result.size()]);
return children;
} catch (SVNClientException e) {
throw new SVNException(new SVNStatus(IStatus.ERROR, SVNStatus.DOES_NOT_EXIST, Policy.bind("RemoteFolder.doesNotExist", // $NON-NLS-1$
getRepositoryRelativePath())));
} finally {
getRepository().returnSVNClient(client);
progress.done();
}
}
use of org.tigris.subversion.subclipse.core.SVNStatus in project subclipse by subclipse.
the class SVNHistoryPage method getUpdateToRevisionAction.
// update to the selected revision (context menu)
private IAction getUpdateToRevisionAction() {
if (updateToRevisionAction == null) {
updateToRevisionAction = getContextMenuAction(Policy.bind("HistoryView.getRevisionAction"), new // $NON-NLS-1$
IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
ISelection selection = getSelection();
if (!(selection instanceof IStructuredSelection))
return;
IStructuredSelection ss = (IStructuredSelection) selection;
ISVNRemoteFile remoteFile = (ISVNRemoteFile) getLogEntry(ss).getRemoteResource();
try {
if (remoteFile != null) {
if (confirmOverwrite()) {
IFile file = (IFile) resource;
new ReplaceOperation(getSite().getPage().getActivePart(), file, remoteFile.getLastChangedRevision()).run(monitor);
historyTableProvider.setRemoteResource(remoteFile);
historyTableProvider.setProjectProperties(ProjectProperties.getProjectProperties(resource));
Display.getDefault().asyncExec(new Runnable() {
public void run() {
tableHistoryViewer.refresh();
}
});
}
}
} catch (InvocationTargetException e) {
throw new CoreException(new SVNStatus(IStatus.ERROR, 0, e.getMessage()));
} catch (InterruptedException e) {
// Cancelled by user
}
}
});
PlatformUI.getWorkbench().getHelpSystem().setHelp(updateToRevisionAction, IHelpContextIds.GET_FILE_REVISION_ACTION);
}
return updateToRevisionAction;
}
use of org.tigris.subversion.subclipse.core.SVNStatus in project subclipse by subclipse.
the class SVNOperation method handleErrors.
protected void handleErrors(IStatus[] errors) throws SVNException {
if (errors.length == 0)
return;
if (errors.length == 1 && statusCount == 1) {
throw new SVNException(errors[0]);
}
MultiStatus result = new MultiStatus(SVNUIPlugin.ID, 0, getErrorMessage(errors, statusCount), null);
for (int i = 0; i < errors.length; i++) {
IStatus s = errors[i];
if (s.isMultiStatus()) {
result.add(new SVNStatus(s.getSeverity(), s.getMessage(), s.getException()));
result.addAll(s);
} else {
result.add(s);
}
}
throw new SVNException(result);
}
use of org.tigris.subversion.subclipse.core.SVNStatus in project subclipse by subclipse.
the class SVNUIPlugin method openError.
/**
* Convenience method for showing an error dialog
*
* @param shell a valid shell or null
* @param exception the exception to be report
* @param title the title to be displayed
* @param flags customizing attributes for the error handling
* @return IStatus the status that was displayed to the user
*/
public static IStatus openError(Shell providedShell, String title, String message, Throwable exception, int flags) {
// Unwrap InvocationTargetExceptions
if (exception instanceof InvocationTargetException) {
Throwable target = ((InvocationTargetException) exception).getTargetException();
// re-throw any runtime exceptions or errors so they can be handled by the workbench
if (target instanceof RuntimeException) {
throw (RuntimeException) target;
}
if (target instanceof Error) {
throw (Error) target;
}
return openError(providedShell, title, message, target, flags);
}
// Determine the status to be displayed (and possibly logged)
IStatus status = null;
boolean log = false;
if (exception instanceof CoreException) {
status = ((CoreException) exception).getStatus();
log = ((flags & LOG_CORE_EXCEPTIONS) > 0);
} else if (exception instanceof TeamException) {
status = ((TeamException) exception).getStatus();
log = ((flags & LOG_TEAM_EXCEPTIONS) > 0);
} else if (exception instanceof InterruptedException) {
// $NON-NLS-1$
return new SVNStatus(IStatus.OK, Policy.bind("ok"));
} else if (exception != null) {
// $NON-NLS-1$
status = new SVNStatus(IStatus.ERROR, Policy.bind("internal"), exception);
log = ((flags & LOG_OTHER_EXCEPTIONS) > 0);
// $NON-NLS-1$
if (title == null)
title = Policy.bind("SimpleInternal");
}
// Check for a build error and report it differently
if (status.getCode() == IResourceStatus.BUILD_FAILED) {
// $NON-NLS-1$
message = Policy.bind("buildError");
log = true;
}
// Check for multi-status with only one child
if (status.isMultiStatus() && status.getChildren().length == 1) {
status = status.getChildren()[0];
}
if (status.isOK())
return status;
// Log if the user requested it
if (log)
SVNUIPlugin.log(status);
// Create a runnable that will display the error status
String svnInterface = SVNUIPlugin.getPlugin().getPreferenceStore().getString(ISVNUIConstants.PREF_SVNINTERFACE);
boolean loadError = svnInterface.equals("javahl") && status != null && status.getMessage() != null && status.getMessage().equals(SVNClientManager.UNABLE_TO_LOAD_DEFAULT_CLIENT);
if (!loadError || loadErrorHandled) {
final String displayTitle = title;
final String displayMessage = message;
final IStatus displayStatus = status;
final IOpenableInShell openable = new IOpenableInShell() {
public void open(Shell shell) {
if (displayStatus.getSeverity() == IStatus.INFO && !displayStatus.isMultiStatus()) {
MessageDialog.openInformation(shell, Policy.bind("information"), // $NON-NLS-1$
displayStatus.getMessage());
} else {
ErrorDialog.openError(shell, displayTitle, displayMessage, displayStatus);
}
}
};
openDialog(providedShell, openable, flags);
}
if (loadError)
loadErrorHandled = true;
// return the status we display
return status;
}
use of org.tigris.subversion.subclipse.core.SVNStatus in project subclipse by subclipse.
the class SVNWorkspaceRoot method setSharing.
/**
* Set the sharing for a project to enable it to be used with the SVNTeamProvider. This is used
* when a project has .svn directory but is not shared in Eclipse. An exception is thrown if
* project does not have a remote directory counterpart
*/
public static void setSharing(IProject project, IProgressMonitor monitor) throws TeamException {
// Ensure provided info matches that of the project
LocalResourceStatus status = peekResourceStatusFor(project);
// we will change this exception !
if (!status.hasRemote())
throw new SVNException(new SVNStatus(IStatus.ERROR, // $NON-NLS-1$
Policy.bind("SVNProvider.infoMismatch", project.getName())));
String repositoryURL = null;
ISVNClientAdapter client = SVNProviderPlugin.getPlugin().getSVNClient();
try {
SVNProviderPlugin.disableConsoleLogging();
ISVNInfo info = client.getInfoFromWorkingCopy(project.getLocation().toFile());
if (info.getRepository() != null)
repositoryURL = info.getRepository().toString();
} catch (SVNClientException e) {
} finally {
SVNProviderPlugin.enableConsoleLogging();
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
if (repositoryURL == null)
repositoryURL = status.getUrlString();
// Ensure that the provided location is managed
SVNProviderPlugin.getPlugin().getRepositories().getRepository(repositoryURL, false);
// Register the project with Team
RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
}
Aggregations