Search in sources :

Example 91 with ISVNLocalResource

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ISynchronizeModelElement(org.eclipse.team.ui.synchronize.ISynchronizeModelElement) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 92 with ISVNLocalResource

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;
}
Also used : SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) IResource(org.eclipse.core.resources.IResource)

Example 93 with ISVNLocalResource

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;
}
Also used : ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

Example 94 with ISVNLocalResource

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);
        }
    }
}
Also used : CommitOperation(org.tigris.subversion.subclipse.ui.operations.CommitOperation) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 95 with ISVNLocalResource

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);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) SVNException(org.tigris.subversion.subclipse.core.SVNException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)120 IResource (org.eclipse.core.resources.IResource)77 SVNException (org.tigris.subversion.subclipse.core.SVNException)76 ArrayList (java.util.ArrayList)39 CoreException (org.eclipse.core.runtime.CoreException)24 Iterator (java.util.Iterator)20 IFile (org.eclipse.core.resources.IFile)20 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 List (java.util.List)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)18 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)17 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)17 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)17 File (java.io.File)16 TeamException (org.eclipse.team.core.TeamException)16 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)15 ISynchronizeModelElement (org.eclipse.team.ui.synchronize.ISynchronizeModelElement)14 IContainer (org.eclipse.core.resources.IContainer)13 SyncInfo (org.eclipse.team.core.synchronize.SyncInfo)11