Search in sources :

Example 21 with LocalResourceStatus

use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus in project subclipse by subclipse.

the class ResolveSynchronizeOperation method run.

protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    boolean folderSelected = false;
    propertyConflicts = false;
    textConflicts = false;
    treeConflicts = false;
    canceled = false;
    final IResource[] resources = set.getResources();
    for (int i = 0; i < resources.length; i++) {
        if (resources[i] instanceof IContainer) {
            folderSelected = true;
            break;
        }
        if (!propertyConflicts || !textConflicts || !treeConflicts) {
            ISVNLocalResource resource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
            try {
                LocalResourceStatus status = resource.getStatus();
                if (status != null && status.isPropConflicted())
                    propertyConflicts = true;
                if (status != null && status.isTextConflicted())
                    textConflicts = true;
                if (status != null && status.hasTreeConflict())
                    treeConflicts = true;
            } catch (SVNException e) {
                SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
            }
        }
    }
    if (folderSelected) {
        selectedResolution = ISVNConflictResolver.Choice.chooseMerged;
    } else {
        Display.getDefault().syncExec(new Runnable() {

            public void run() {
                if (propertyConflicts && !textConflicts) {
                    String message;
                    if (resources.length > 1)
                        // $NON-NLS-1$
                        message = Policy.bind("ResolveAction.confirmMultiple");
                    else
                        message = Policy.bind("ResolveAction.confirm", // $NON-NLS-1$
                        resources[0].getName());
                    if (!MessageDialog.openConfirm(getShell(), Policy.bind("ResolveOperation.taskName"), message)) {
                        // $NON-NLS-1$
                        canceled = true;
                        return;
                    }
                    selectedResolution = ISVNConflictResolver.Choice.chooseMerged;
                } else {
                    SvnWizardMarkResolvedPage markResolvedPage = new SvnWizardMarkResolvedPage(resources);
                    markResolvedPage.setPropertyConflicts(propertyConflicts);
                    markResolvedPage.setTreeConflicts(treeConflicts);
                    SvnWizard wizard = new SvnWizard(markResolvedPage);
                    SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
                    wizard.setParentDialog(dialog);
                    if (dialog.open() == SvnWizardDialog.CANCEL) {
                        canceled = true;
                        return;
                    }
                    selectedResolution = markResolvedPage.getResolution();
                }
            }
        });
    }
    if (canceled)
        return;
    run(new WorkspaceModifyOperation() {

        public void execute(IProgressMonitor monitor) throws InvocationTargetException {
            ISVNRepositoryLocation repository = null;
            ISVNClientAdapter svnClient = null;
            try {
                for (int i = 0; i < resources.length; i++) {
                    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
                    repository = svnResource.getRepository();
                    svnClient = repository.getSVNClient();
                    svnClient.resolve(resources[i].getLocation().toFile(), selectedResolution);
                    repository.returnSVNClient(svnClient);
                    repository = null;
                    svnClient = null;
                    // for some reason, just refreshing the file won't cut it.
                    resources[i].getParent().refreshLocal(IResource.DEPTH_INFINITE, monitor);
                }
            } catch (TeamException e) {
                throw new InvocationTargetException(e);
            } catch (CoreException e) {
                throw new InvocationTargetException(e);
            } catch (SVNClientException e) {
                throw new InvocationTargetException(e);
            } finally {
                if (repository != null) {
                    repository.returnSVNClient(svnClient);
                }
            }
        }
    }, false, /* cancelable */
    PROGRESS_BUSYCURSOR);
}
Also used : WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) CoreException(org.eclipse.core.runtime.CoreException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) IContainer(org.eclipse.core.resources.IContainer) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) IResource(org.eclipse.core.resources.IResource) SvnWizardMarkResolvedPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardMarkResolvedPage) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 22 with LocalResourceStatus

use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus 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 23 with LocalResourceStatus

use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus in project subclipse by subclipse.

the class SVNMarkerListener method resourceSyncInfoChanged.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.IResourceStateChangeListener#resourceSyncInfoChanged(org.eclipse.core.resources.IResource[])
   */
public void resourceSyncInfoChanged(IResource[] changedResources) {
    for (int i = 0; i < changedResources.length; i++) {
        try {
            if (changedResources[i].exists()) {
                changedResources[i].deleteMarkers("org.tigris.subversion.subclipse.ui.conflictMarker", true, // $NON-NLS-1$
                IResource.DEPTH_ZERO);
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(changedResources[i]);
                LocalResourceStatus status = svnResource.getStatus();
                if (status.isTextConflicted() || status.isPropConflicted() || status.hasTreeConflict()) {
                    try {
                        IMarker marker = changedResources[i].createMarker(// $NON-NLS-1$
                        "org.tigris.subversion.subclipse.ui.conflictMarker");
                        setMessage(status, marker);
                        marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
                        // $NON-NLS-1$
                        marker.setAttribute("textConflict", status.isTextConflicted());
                        // $NON-NLS-1$
                        marker.setAttribute("propertyConflict", status.isPropConflicted());
                        // $NON-NLS-1$
                        marker.setAttribute("treeConflict", status.hasTreeConflict());
                    } catch (Exception e) {
                        SVNUIPlugin.log(e.getMessage());
                    }
                }
            }
        } catch (Exception e) {
            SVNUIPlugin.log(e.getMessage());
        }
    }
    if (!treeConflictsViewRefreshed) {
        treeConflictsViewRefreshed = TreeConflictsView.refresh(changedResources);
    }
}
Also used : IMarker(org.eclipse.core.resources.IMarker) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) CoreException(org.eclipse.core.runtime.CoreException)

Example 24 with LocalResourceStatus

use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus in project subclipse by subclipse.

the class BranchTagAction 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 25 with LocalResourceStatus

use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus in project subclipse by subclipse.

the class SwitchAction 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)

Aggregations

LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)26 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)17 IResource (org.eclipse.core.resources.IResource)12 SVNException (org.tigris.subversion.subclipse.core.SVNException)12 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)7 CoreException (org.eclipse.core.runtime.CoreException)6 TeamException (org.eclipse.team.core.TeamException)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 ArrayList (java.util.ArrayList)4 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)4 File (java.io.File)3 List (java.util.List)2 IContainer (org.eclipse.core.resources.IContainer)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Path (org.eclipse.core.runtime.Path)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 OperationManager (org.tigris.subversion.subclipse.core.client.OperationManager)2 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)2