use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class CommitSynchronizeOperation method run.
// private IResource[] getUnaddedResources(SyncInfoSet set) {
// IResource[] resources = set.getResources();
// List result = new ArrayList();
// for (int i = 0; i < resources.length; i++) {
// IResource resource = resources[i];
// if (isAdded(resource)) {
// result.add(resource);
// }
// }
// return (IResource[]) result.toArray(new IResource[result.size()]);
// }
// private boolean isAdded(IResource resource) {
// ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
// try {
// if (svnResource.isIgnored())
// return false;
// // visit the children of shared resources
// if (svnResource.isManaged())
// return false;
// if ((resource.getType() == IResource.FOLDER) && isSymLink(resource)) // don't traverse into
// symlink folders
// return false;
// } catch (SVNException e) {
// SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
// return false;
// }
// return true;
// }
// private boolean isSymLink(IResource resource) {
// File file = resource.getLocation().toFile();
// try {
// if (!file.exists())
// return true;
// else {
// String cnnpath = file.getCanonicalPath();
// String abspath = file.getAbsolutePath();
// return !abspath.equals(cnnpath);
// }
// } catch(IOException ex) {
// return true;
// }
// }
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// First, ask the user if they want to include conflicts
SyncInfoSet syncSet = getSyncInfoSet();
if (!promptForConflictHandling(getShell(), syncSet))
return;
// Divide the sync info by project
final Map projectSyncInfos = getProjectSyncInfoSetMap(syncSet);
Iterator iter = projectSyncInfos.keySet().iterator();
final IProject project = (IProject) iter.next();
SVNTeamProvider provider = (SVNTeamProvider) RepositoryProvider.getProvider(project, SVNUIPlugin.PROVIDER_ID);
monitor.beginTask(null, projectSyncInfos.size() * 100);
run(provider, syncSet, Policy.subMonitorFor(monitor, 100));
monitor.done();
}
use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class IgnoreSynchronizeOperation method run.
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// First, ask the user if they want to include conflicts
SyncInfoSet syncSet = getSyncInfoSet();
if (!promptForConflictHandling(getShell(), syncSet))
return;
// Divide the sync info by project
final Map projectSyncInfos = getProjectSyncInfoSetMap(syncSet);
monitor.beginTask(null, projectSyncInfos.size() * 100);
for (Iterator iter = projectSyncInfos.keySet().iterator(); iter.hasNext(); ) {
final IProject project = (IProject) iter.next();
// Pass the scheduling rule to the synchronizer so that sync change events
// and cache commits to disk are batched
SVNTeamProvider provider = (SVNTeamProvider) RepositoryProvider.getProvider(project, SVNUIPlugin.PROVIDER_ID);
if (provider != null) {
run(provider, (SyncInfoSet) projectSyncInfos.get(project), Policy.subMonitorFor(monitor, 100));
break;
}
}
monitor.done();
}
use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class LockAction method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
if (action != null && !action.isEnabled()) {
action.setEnabled(true);
} else {
if (getSelectedResources() != null && getSelectedResources().length > 0) {
final IResource[] resources = getSelectedResources();
SvnWizardLockPage lockPage = new SvnWizardLockPage(resources);
SvnWizard wizard = new SvnWizard(lockPage);
SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
wizard.setParentDialog(dialog);
if (dialog.open() == SvnWizardDialog.OK) {
final String comment = lockPage.getComment();
final boolean stealLock = lockPage.isStealLock();
run(new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
try {
Hashtable table = getProviderMapping(getSelectedResources());
Set keySet = table.keySet();
Iterator iterator = keySet.iterator();
while (iterator.hasNext()) {
SVNTeamProvider provider = (SVNTeamProvider) iterator.next();
LockResourcesCommand command = new LockResourcesCommand(provider.getSVNWorkspaceRoot(), resources, stealLock, comment);
command.run(Policy.subMonitorFor(monitor, 1000));
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
}, true, /* cancelable */
PROGRESS_DIALOG);
}
}
}
}
use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class SVNLightweightDecorator method decorate.
/**
* This method should only be called by the decorator thread.
*
* @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object,
* org.eclipse.jface.viewers.IDecoration)
*/
public void decorate(Object element, IDecoration decoration) {
IResource resource = null;
try {
resource = getResource(element);
if (resource != null && resource.getType() == IResource.ROOT)
return;
boolean isIgnored = false;
SVNTeamProvider svnProvider = null;
ISVNLocalResource svnResource = null;
if (resource != null) {
// get the team provider
svnProvider = (SVNTeamProvider) RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
if (svnProvider == null)
return;
// if the resource is ignored return an empty decoration. This will
// force a decoration update event and clear the existing SVN decoration.
svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
if (svnResource.isIgnored()) {
isIgnored = true;
// return;
}
} catch (SVNException e) {
// todo should log this error
return;
}
}
// determine a if resource has outgoing changes (e.g. is dirty).
boolean isDirty = false;
boolean isUnversioned = false;
if (resource == null) {
if (element instanceof ResourceMapping) {
IProject[] projects = ((ResourceMapping) element).getProjects();
if (projects != null) {
for (IProject project : projects) {
ISVNLocalResource svnProjectResource = SVNWorkspaceRoot.getSVNResourceFor(project);
if (svnProjectResource != null) {
try {
if (svnProjectResource.isDirty()) {
decoration.addOverlay(dirty);
return;
}
} catch (SVNException e) {
return;
}
}
}
}
}
return;
} else {
LocalResourceStatus status = null;
if (!isIgnored) {
try {
status = svnResource.getStatusFromCache();
isDirty = SVNLightweightDecorator.isDirty(svnResource, status);
} catch (SVNException e) {
if (!e.operationInterrupted()) {
SVNUIPlugin.log(e.getStatus());
isDirty = true;
}
}
if (status != null) {
isUnversioned = status.isUnversioned();
}
// if (resource.getType() == IResource.FILE || computeDeepDirtyCheck) {
// // isDirty = SVNLightweightDecorator.isDirty(svnResource);
// isDirty = SVNLightweightDecorator.isDirty(svnResource, status);
// }
// try {
// status = svnResource.getStatusFromCache();
// isUnversioned = status.isUnversioned();
// } catch (SVNException e1) {
// if (!e1.operationInterrupted()) {
// SVNUIPlugin.log(e1.getStatus());
// }
// }
decorateTextLabel(svnResource, status, decoration, isDirty);
}
computeColorsAndFonts(isIgnored, isDirty || isUnversioned, decoration);
if (!isIgnored) {
ImageDescriptor overlay = getOverlay(svnResource, status, isDirty, svnProvider);
if (overlay != null) {
// actually sending null arg would work but this makes logic clearer
decoration.addOverlay(overlay);
}
}
}
} catch (Exception e) {
SVNUIPlugin.log(IStatus.ERROR, "Error Decorating " + resource, e);
}
}
Aggregations