Search in sources :

Example 46 with ISVNLocalResource

use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.

the class UndoMergeCommand method run.

public void run(IProgressMonitor monitor) throws SVNException {
    ISVNClientAdapter svnClient = null;
    ISVNRepositoryLocation repository = null;
    try {
        final OperationManager operationManager = OperationManager.getInstance();
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        repository = svnResource.getRepository();
        svnClient = repository.getSVNClient();
        svnClient.addNotifyListener(operationResourceCollector);
        operationManager.beginOperation(svnClient);
        LocalResourceStatus status = SVNWorkspaceRoot.getSVNResourceFor(resource).getStatus();
        if (!status.isManaged()) {
            try {
                resource.delete(true, monitor);
            } catch (CoreException ex) {
                throw SVNException.wrapException(ex);
            }
        } else {
            File path = resource.getLocation().toFile();
            svnClient.revert(path, true);
            if (resource.getType() != IResource.FILE)
                operationManager.onNotify(path, SVNNodeKind.UNKNOWN);
            monitor.worked(100);
        }
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
        OperationManager.getInstance().endOperation(true, operationResourceCollector.getOperationResources());
        monitor.done();
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) CoreException(org.eclipse.core.runtime.CoreException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) OperationManager(org.tigris.subversion.subclipse.core.client.OperationManager) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 47 with ISVNLocalResource

use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.

the class MergeWizard method getCommonRoot.

@SuppressWarnings("unchecked")
public String getCommonRoot() {
    if (commonRoot == null) {
        ArrayList urlList = new ArrayList();
        for (int i = 0; i < resources.length; i++) {
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
            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;
        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);
            }
        }
    }
    return commonRoot;
}
Also used : ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource)

Example 48 with ISVNLocalResource

use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.

the class MergeAction method isEnabledForMultipleResources.

/*
   * (non-Javadoc)
   * @see org.tigris.subversion.subclipse.ui.actions.WorkspaceAction#isEnabledForMultipleResources()
   */
protected boolean isEnabledForMultipleResources() {
    try {
        // Must all be from same repository.
        ISVNRepositoryLocation repository = null;
        IResource[] selectedResources = getSelectedResources();
        for (int i = 0; i < selectedResources.length; i++) {
            ISVNRepositoryLocation compareToRepository = null;
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(selectedResources[i]);
            if (svnResource == null || !svnResource.isManaged()) {
                return false;
            }
            LocalResourceStatus status = svnResource.getStatusFromCache();
            if (status != null) {
                compareToRepository = status.getRepository();
            }
            if (compareToRepository == null) {
                return false;
            }
            if (repository != null && !compareToRepository.equals(repository)) {
                return false;
            }
            repository = compareToRepository;
        }
        return true;
    } catch (Exception e) {
        return false;
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) IResource(org.eclipse.core.resources.IResource) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 49 with ISVNLocalResource

use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.

the class AddAction method promptForAddOfIgnored.

/**
 * asks the user if he wants to add the resources if some of them are ignored
 *
 * @return false if he answered no
 */
private boolean promptForAddOfIgnored() {
    IResource[] resources = getSelectedResources();
    boolean prompt = false;
    for (int i = 0; i < resources.length; i++) {
        ISVNLocalResource resource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
        try {
            if (resource.isIgnored()) {
                prompt = true;
                break;
            }
        } catch (SVNException e) {
            handle(e);
        }
    }
    if (prompt) {
        return MessageDialog.openQuestion(getShell(), Policy.bind("AddAction.addIgnoredTitle"), // $NON-NLS-1$ //$NON-NLS-2$
        Policy.bind("AddAction.addIgnoredQuestion"));
    }
    return true;
}
Also used : SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

Example 50 with ISVNLocalResource

use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.

the class WorkspaceAction method getModifiedResources.

protected IResource[] getModifiedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws SVNException {
    final List modified = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        IResource resource = resources[i];
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        // get adds, deletes, updates and property updates.
        GetStatusCommand command = new GetStatusCommand(svnResource, true, false);
        command.run(iProgressMonitor);
        ISVNStatus[] statuses = command.getStatuses();
        for (int j = 0; j < statuses.length; j++) {
            if (SVNStatusUtils.isReadyForRevert(statuses[j]) || !SVNStatusUtils.isManaged(statuses[j])) {
                IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource, statuses[j]);
                if (currentResource != null)
                    modified.add(currentResource);
            }
        }
    }
    return (IResource[]) modified.toArray(new IResource[modified.size()]);
}
Also used : ArrayList(java.util.ArrayList) GetStatusCommand(org.tigris.subversion.subclipse.core.commands.GetStatusCommand) ArrayList(java.util.ArrayList) List(java.util.List) ISVNStatus(org.tigris.subversion.svnclientadapter.ISVNStatus) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

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