use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class ShowHistorySynchronizeAction method getSyncInfoFilter.
/* (non-Javadoc)
* @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSyncInfoFilter()
*/
protected FastSyncInfoFilter getSyncInfoFilter() {
return new FastSyncInfoFilter() {
public boolean select(SyncInfo info) {
IStructuredSelection selection = getStructuredSelection();
if (selection.size() != 1)
return false;
ISynchronizeModelElement element = (ISynchronizeModelElement) selection.getFirstElement();
IResource resource = element.getResource();
if (resource == null)
return false;
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
return !resource.exists() || (svnResource.getStatus().isManaged() && !svnResource.getStatus().isAdded());
} catch (SVNException e) {
return false;
}
}
};
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class SvnPropertiesView method handlePartSelectionChanged.
/**
* called when the selection changed on another part
*/
private void handlePartSelectionChanged(IWorkbenchPart part, ISelection selection) {
if (!(selection instanceof IStructuredSelection))
return;
try {
Object first = ((IStructuredSelection) selection).getFirstElement();
if (first instanceof IAdaptable) {
IAdaptable a = (IAdaptable) first;
Object adapter = a.getAdapter(IResource.class);
if (adapter instanceof IResource) {
IResource resource = (IResource) adapter;
// If the resource isn't open or doesn't exist it won't have properties
if (!resource.isAccessible()) {
showSvnProperties(null);
} else {
ISVNLocalResource svnResource = (ISVNLocalResource) resource.getAdapter(ISVNLocalResource.class);
showSvnProperties(svnResource);
}
}
}
} catch (SVNException e) {
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class SvnWizardSwitchPage method getCommonRoot.
private String getCommonRoot() {
ArrayList<String> urlList = new ArrayList<String>();
for (IResource resource : resources) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
String anUrl = svnResource.getStatus().getUrlString();
if (anUrl != null)
urlList.add(anUrl);
} catch (SVNException e1) {
}
}
urlStrings = new String[urlList.size()];
urlList.toArray(urlStrings);
if (urlStrings.length == 0)
return null;
String urlString = urlStrings[0];
if (urlStrings.length == 1)
return urlString;
String commonRoot = null;
tag1: for (int i = 0; i < urlString.length(); i++) {
String partialPath = urlString.substring(0, i + 1);
if (partialPath.endsWith("/")) {
// $NON-NLS-1$
for (int j = 1; j < urlStrings.length; j++) {
if (!urlStrings[j].startsWith(partialPath))
break tag1;
}
commonRoot = partialPath.substring(0, i);
}
}
switchResources = new SwitchResource[resources.length];
for (int i = 0; i < resources.length; i++) {
switchResources[i] = new SwitchResource(resources[i], urlStrings[i].substring(commonRoot.length() + 1));
}
return commonRoot;
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class MarkMergedSynchronizeAction method getSyncInfoFilter.
/* (non-Javadoc)
* @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSyncInfoFilter()
*/
protected FastSyncInfoFilter getSyncInfoFilter() {
return new FastSyncInfoFilter() {
public boolean select(SyncInfo info) {
SyncInfoDirectionFilter filter = new SyncInfoDirectionFilter(new int[] { SyncInfo.CONFLICTING });
if (!filter.select(info))
return false;
IStructuredSelection selection = getStructuredSelection();
Iterator iter = selection.iterator();
while (iter.hasNext()) {
ISynchronizeModelElement element = (ISynchronizeModelElement) iter.next();
IResource resource = element.getResource();
if (resource == null || !resource.exists())
return false;
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
if (!svnResource.isManaged() || svnResource.isAdded())
return false;
} catch (SVNException e) {
return false;
}
}
return true;
}
};
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class MarkMergedSynchronizeOperation method run.
protected void run(SVNTeamProvider provider, SyncInfoSet set, final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
final IResource[] resources = set.getResources();
run(new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor mon) throws CoreException, InvocationTargetException, InterruptedException {
for (int i = 0; i < resources.length; i++) {
File tempFile = null;
try {
tempFile = copyToTempFile(resources[i]);
} catch (Exception e) {
SVNUIPlugin.log(e.getMessage());
showErrorMessage(e);
return;
}
if (monitor.isCanceled()) {
if (tempFile != null)
tempFile.delete();
return;
}
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
if (svnResource instanceof LocalResource)
((LocalResource) svnResource).revert(false);
else
svnResource.revert();
new UpdateOperation(getPart(), resources[i], SVNRevision.HEAD).run(monitor);
if (monitor.isCanceled()) {
if (tempFile != null)
tempFile.delete();
return;
}
File file = new File(resources[i].getLocation().toString());
try {
copy(tempFile, file);
} catch (Exception e1) {
SVNUIPlugin.log(e1.getMessage());
showErrorMessage(e1);
}
if (tempFile != null)
tempFile.delete();
}
}
}, true, /* cancelable */
PROGRESS_BUSYCURSOR);
}
Aggregations