use of org.tigris.subversion.subclipse.core.ISVNResource in project subclipse by subclipse.
the class LocalFolder method getSVNFolders.
public IFolder[] getSVNFolders(IProgressMonitor monitor, final boolean unmanage) throws SVNException {
final ArrayList<IFolder> svnFolders = new ArrayList<IFolder>();
SVNProviderPlugin.run(new ISVNRunnable() {
public void run(IProgressMonitor pm) throws SVNException {
pm = Policy.monitorFor(pm);
pm.beginTask(null, 100);
ISVNResource[] members = members(Policy.subMonitorFor(pm, 20), FOLDER_MEMBERS | MANAGED_MEMBERS);
ArrayList<IContainer> dirs = new ArrayList<IContainer>();
for (ISVNResource member : members) {
dirs.add((IContainer) ((ISVNLocalResource) member).getIResource());
}
// we add the current folder to the
dirs.add((IContainer) getIResource());
// list : we want to add .svn dir
// for it too
IProgressMonitor monitorDel = Policy.subMonitorFor(pm, 80);
monitorDel.beginTask(null, dirs.size());
for (IContainer container : dirs) {
monitorDel.worked(1);
recursiveGetSVNFolders(container, monitorDel, unmanage);
}
monitorDel.done();
pm.done();
}
private void recursiveGetSVNFolders(IContainer container, IProgressMonitor pm, boolean unmanage) {
try {
// We must not add svn directories for linked resources.
if (container.isLinked())
return;
pm.beginTask(null, 10);
pm.subTask(container.getFullPath().toOSString());
IResource[] members = container.members(true);
for (IResource member : members) {
pm.worked(1);
if (member.getType() != IResource.FILE) {
recursiveGetSVNFolders((IContainer) member, pm, unmanage);
}
}
// Post order traversal
IFolder svnFolder = container.getFolder(new Path(SVNProviderPlugin.getPlugin().getAdminDirectoryName()));
if (svnFolder.exists()) {
svnFolders.add(svnFolder);
if (unmanage) {
try {
svnFolder.delete(true, null);
} catch (CoreException e) {
}
}
}
} catch (CoreException e) {
// Just ignore and continue
} finally {
pm.done();
}
}
}, Policy.subMonitorFor(monitor, 99));
IFolder[] folderArray = new IFolder[svnFolders.size()];
svnFolders.toArray(folderArray);
return folderArray;
}
use of org.tigris.subversion.subclipse.core.ISVNResource in project subclipse by subclipse.
the class SVNHistoryPage method getSetCommitPropertiesAction.
private IAction getSetCommitPropertiesAction() {
// set Action (context menu)
if (setCommitPropertiesAction == null) {
setCommitPropertiesAction = new // $NON-NLS-1$
Action(// $NON-NLS-1$
Policy.bind("HistoryView.setCommitProperties")) {
public void run() {
try {
final ISelection selection = getSelection();
if (!(selection instanceof IStructuredSelection))
return;
final ILogEntry ourSelection = getLogEntry((IStructuredSelection) selection);
// Failing that, try the resource originally selected by the user if
// from the Team menu
// TODO: Search all paths from currentSelection and find the
// shortest path and
// get the resources for that instance (in order to get the 'best'
// "bugtraq" properties)
final ProjectProperties projectProperties = (resource != null) ? ProjectProperties.getProjectProperties(resource) : (ourSelection.getRemoteResource() != null) ? ProjectProperties.getProjectProperties(ourSelection.getRemoteResource()) : ProjectProperties.getProjectProperties(// will return null!
remoteResource);
final ISVNResource svnResource = ourSelection.getRemoteResource() != null ? ourSelection.getRemoteResource() : ourSelection.getResource();
SetCommitPropertiesDialog dialog = new SetCommitPropertiesDialog(getSite().getShell(), ourSelection.getRevision(), resource, projectProperties);
// Set previous text - the text to edit
dialog.setOldAuthor(ourSelection.getAuthor());
dialog.setOldComment(ourSelection.getComment());
boolean doCommit = (dialog.open() == Window.OK);
if (doCommit) {
final String author;
final String commitComment;
if (ourSelection.getAuthor().equals(dialog.getAuthor()))
author = null;
else
author = dialog.getAuthor();
if (ourSelection.getComment().equals(dialog.getComment()))
commitComment = null;
else
commitComment = dialog.getComment();
final ChangeCommitPropertiesCommand command = new ChangeCommitPropertiesCommand(svnResource.getRepository(), ourSelection.getRevision(), commitComment, author);
PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
command.run(monitor);
} catch (SVNException e) {
throw new InvocationTargetException(e);
} finally {
if (ourSelection instanceof LogEntry) {
LogEntry logEntry = (LogEntry) ourSelection;
if (command.isLogMessageChanged())
logEntry.setComment(commitComment);
if (command.isAuthorChanged())
logEntry.setAuthor(author);
}
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
tableHistoryViewer.refresh();
tableHistoryViewer.setSelection(selection, true);
}
});
}
}
});
}
} catch (InvocationTargetException e) {
SVNUIPlugin.openError(getSite().getShell(), null, null, e, SVNUIPlugin.LOG_NONTEAM_EXCEPTIONS);
} catch (InterruptedException e) {
// Do nothing
} catch (SVNException e) {
// TODO Auto-generated catch block
SVNUIPlugin.openError(getSite().getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
}
}
// we don't allow multiple selection
public boolean isEnabled() {
ISelection selection = getSelection();
return selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1;
}
};
}
return setCommitPropertiesAction;
}
use of org.tigris.subversion.subclipse.core.ISVNResource in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffAction method isEnabled.
protected boolean isEnabled() throws TeamException {
Object[] selectedObjects = selection.toArray();
if (selectedObjects.length == 0 || selectedObjects.length > 2)
return false;
ISVNResource svnResource1 = null;
ISVNResource svnResource2 = null;
if (selectedObjects[0] instanceof ISVNResource)
svnResource1 = (ISVNResource) selectedObjects[0];
else {
if (selectedObjects[0] instanceof ILogEntry)
svnResource1 = ((ILogEntry) selectedObjects[0]).getResource();
}
if (svnResource1 == null)
return false;
if (selectedObjects.length > 1) {
if (selectedObjects[1] instanceof ISVNResource)
svnResource2 = (ISVNResource) selectedObjects[1];
else {
if (selectedObjects[1] instanceof ILogEntry)
svnResource2 = ((ILogEntry) selectedObjects[1]).getResource();
}
if (!svnResource1.getRepository().getRepositoryRoot().toString().equals(svnResource2.getRepository().getRepositoryRoot().toString()))
return false;
return (svnResource1.isFolder() == svnResource2.isFolder());
}
return true;
}
use of org.tigris.subversion.subclipse.core.ISVNResource in project subclipse by subclipse.
the class BaseFolder method members.
/* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.ISVNFolder#members(org.eclipse.core.runtime.IProgressMonitor, int)
*/
public ISVNResource[] members(IProgressMonitor monitor, int flags) throws SVNException {
final List<ISVNResource> result = new ArrayList<ISVNResource>();
ISVNRemoteResource[] resources = getMembers(monitor);
// RemoteFolders never have phantom members
if ((flags & EXISTING_MEMBERS) == 0 && (flags & PHANTOM_MEMBERS) == 1) {
return new ISVNResource[0];
}
boolean includeFiles = (((flags & FILE_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
boolean includeFolders = (((flags & FOLDER_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
boolean includeManaged = (((flags & MANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
for (ISVNResource svnResource : resources) {
if ((includeFiles && (!svnResource.isFolder())) || (includeFolders && (svnResource.isFolder()))) {
if (includeManaged) {
result.add(svnResource);
}
}
}
return (ISVNResource[]) result.toArray(new ISVNResource[result.size()]);
}
use of org.tigris.subversion.subclipse.core.ISVNResource in project subclipse by subclipse.
the class RemoteFolder method members.
/* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.ISVNFolder#members(org.eclipse.core.runtime.IProgressMonitor, int)
*/
public ISVNResource[] members(IProgressMonitor monitor, int flags) throws SVNException {
final List<ISVNResource> result = new ArrayList<ISVNResource>();
ISVNRemoteResource[] resources = getMembers(monitor);
// RemoteFolders never have phantom members
if ((flags & EXISTING_MEMBERS) == 0 && (flags & PHANTOM_MEMBERS) == 1) {
return new ISVNResource[0];
}
boolean includeFiles = (((flags & FILE_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
boolean includeFolders = (((flags & FOLDER_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
boolean includeManaged = (((flags & MANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
for (ISVNResource svnResource : resources) {
if ((includeFiles && (!svnResource.isFolder())) || (includeFolders && (svnResource.isFolder()))) {
if (includeManaged) {
result.add(svnResource);
}
}
}
return (ISVNResource[]) result.toArray(new ISVNResource[result.size()]);
}
Aggregations