use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class RevertSynchronizeAction method getSubscriberOperation.
@SuppressWarnings({ "rawtypes", "unchecked" })
protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
statusMap = new HashMap();
url = null;
IStructuredSelection selection = getStructuredSelection();
if (selection.size() == 1) {
ISynchronizeModelElement element = (ISynchronizeModelElement) selection.getFirstElement();
IResource resource = element.getResource();
if (resource != null) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
url = svnResource.getStatus().getUrlString();
if ((url == null) || (resource.getType() == IResource.FILE))
url = Util.getParentUrl(svnResource);
} catch (SVNException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
}
List selectedResources = new ArrayList(elements.length);
for (int i = 0; i < elements.length; i++) {
if (elements[i] instanceof ISynchronizeModelElement) {
selectedResources.add(((ISynchronizeModelElement) elements[i]).getResource());
}
}
IResource[] resources = new IResource[selectedResources.size()];
selectedResources.toArray(resources);
boolean changeSetMode = isChangeSetMode();
List<IResource> topSelection = new ArrayList<IResource>();
if (!changeSetMode) {
Iterator iter = selection.iterator();
while (iter.hasNext()) {
ISynchronizeModelElement element = (ISynchronizeModelElement) iter.next();
topSelection.add(element.getResource());
}
}
IResource[] topSelectionArray;
if (changeSetMode) {
topSelectionArray = resources;
} else {
topSelectionArray = new IResource[topSelection.size()];
topSelection.toArray(topSelectionArray);
}
for (IResource resource : resources) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
if (svnResource != null) {
try {
if (resource instanceof IContainer) {
statusMap.put(resource, svnResource.getStatus().getPropStatus());
} else {
statusMap.put(resource, svnResource.getStatus().getTextStatus());
}
} catch (SVNException e) {
// ignore
}
}
}
RevertSynchronizeOperation revertOperation = new RevertSynchronizeOperation(configuration, elements, url, resources, statusMap);
revertOperation.setSelectedResources(topSelectionArray);
return revertOperation;
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class RevertSynchronizeOperation method isExternal.
private boolean isExternal(IResource resource) {
IResource parent = resource;
while (parent != null) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(parent);
try {
LocalResourceStatus status = svnResource.getStatus();
if (status.isFileExternal() || SVNStatusKind.EXTERNAL.equals(status.getTextStatus())) {
return true;
}
} catch (SVNException e) {
return false;
}
parent = parent.getParent();
}
return false;
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class CommitSynchronizeOperation method onTagPath.
private boolean onTagPath(IResource[] modifiedResources) throws SVNException {
// Multiple resources selected.
if (url == null) {
IResource resource = modifiedResources[0];
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
String firstUrl = svnResource.getStatus().getUrlString();
if ((firstUrl == null) || (resource.getType() == IResource.FILE))
firstUrl = Util.getParentUrl(svnResource);
// $NON-NLS-1$
if (firstUrl.indexOf("/tags/") != -1)
return true;
} else // One resource selected.
if (url.indexOf("/tags/") != -1)
// $NON-NLS-1$
return true;
return false;
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class CommitSynchronizeOperation method run.
/* (non-Javadoc)
* @see org.eclipse.team.examples.filesystem.ui.FileSystemSynchronizeOperation#run(org.eclipse.team.examples.filesystem.FileSystemProvider, org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) {
if (set.hasConflicts() || set.hasIncomingChanges()) {
switch(promptForConflicts(getShell(), set)) {
case 0:
// Yes, commit non-conflicts
set.removeConflictingNodes();
set.removeIncomingNodes();
break;
case 1:
// No, stop here
return;
default:
return;
}
}
if (confirmCommit(set)) {
final IResource[][] resourcesToBeAdded = new IResource[][] { null };
final IResource[][] resourcesToBeDeleted = new IResource[][] { null };
List toBeAddedList = new ArrayList();
List toBeDeletedList = new ArrayList();
for (int i = 0; i < resourcesToCommit.length; i++) {
IResource resource = resourcesToCommit[i];
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
if (!svnResource.isManaged())
toBeAddedList.add(resource);
if (svnResource.getStatus().isMissing())
toBeDeletedList.add(resource);
} catch (SVNException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
resourcesToBeAdded[0] = new IResource[toBeAddedList.size()];
toBeAddedList.toArray(resourcesToBeAdded[0]);
resourcesToBeDeleted[0] = new IResource[toBeDeletedList.size()];
toBeDeletedList.toArray(resourcesToBeDeleted[0]);
try {
CommitOperation commit = new CommitOperation(getPart(), resourcesToCommit, resourcesToBeAdded[0], resourcesToBeDeleted[0], resourcesToCommit, commitComment, keepLocks);
commit.run();
} catch (InvocationTargetException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
} catch (InterruptedException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class EditConflictsSynchronizeOperation method run.
protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IResource[] resources = set.getResources();
if (resources[0] instanceof IFile) {
final IFile resource = (IFile) resources[0];
run(new WorkspaceModifyOperation() {
public void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
IFile conflictNewFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictNew());
IFile conflictOldFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictOld());
IFile conflictWorkingFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictWorking());
if (conflictWorkingFile == null) {
conflictWorkingFile = resource;
}
IPreferenceStore preferenceStore = SVNUIPlugin.getPlugin().getPreferenceStore();
if (preferenceStore.getBoolean(ISVNUIConstants.PREF_MERGE_USE_EXTERNAL)) {
editConflictsExternal(resource, conflictOldFile, conflictWorkingFile, conflictNewFile);
} else {
editConflictsInternal(resource, conflictOldFile, conflictWorkingFile, conflictNewFile);
}
} catch (SVNException e) {
throw new InvocationTargetException(e);
}
}
}, false, /* cancelable */
PROGRESS_BUSYCURSOR);
}
}
Aggregations