Search in sources :

Example 11 with LocalResourceStatus

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

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

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

the class WorkspaceAction method isEnabledForSVNResource.

/**
 * Method isEnabledForSVNResource.
 *
 * @param svnResource
 * @return boolean
 */
protected boolean isEnabledForSVNResource(ISVNLocalResource svnResource) throws SVNException {
    if (isEnabledForIgnoredResources() && isEnabledForManagedResources() && isEnabledForUnmanagedResources() && isEnabledForAddedResources() && isEnabledForCopiedResources()) {
        return true;
    }
    LocalResourceStatus status = svnResource.getStatusFromCache();
    boolean managed = false;
    boolean ignored = false;
    boolean added = false;
    boolean copied = false;
    if (!isEnabledForIgnoredResources()) {
        if (!status.isManaged() && status.isIgnored()) {
            ignored = true;
        } else {
            ignored = svnResource.isIgnored();
        }
    }
    if (!ignored) {
        managed = status.isManaged();
        if (managed) {
            copied = status.isCopied();
            added = status.isAdded();
        }
    }
    if (managed && !isEnabledForManagedResources())
        return false;
    if (!managed && !isEnabledForUnmanagedResources())
        return false;
    if (ignored && !isEnabledForIgnoredResources())
        return false;
    if (copied && added) {
        if (!isEnabledForCopiedResources())
            return false;
    } else if (added && !isEnabledForAddedResources()) {
        return false;
    }
    return true;
}
Also used : LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)

Example 14 with LocalResourceStatus

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

the class ResolveActionWithChoices method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    boolean folderSelected = false;
    boolean propertyConflicts = false;
    boolean textConflicts = false;
    boolean treeConflicts = false;
    boolean treeConflictDialogShown = false;
    IResource[] resources = getSelectedResources();
    for (int i = 0; i < resources.length; i++) {
        if (resources[i] instanceof IContainer) {
            folderSelected = true;
        }
        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 (resources.length == 1 && treeConflicts && !propertyConflicts && !textConflicts) {
        treeConflict = getTreeConflict(resources[0]);
        if (treeConflict != null) {
            ResolveTreeConflictWizard wizard = new ResolveTreeConflictWizard(treeConflict, getTargetPart());
            WizardDialog dialog = new SizePersistedWizardDialog(Display.getDefault().getActiveShell(), wizard, // $NON-NLS-1$
            "ResolveTreeConflict");
            if (dialog.open() != WizardDialog.OK)
                return;
            treeConflictDialogShown = true;
        }
    }
    if (resources.length > 1 && treeConflicts) {
        if (!MessageDialog.openConfirm(getShell(), Policy.bind("ResolveOperation.taskName"), Policy.bind("ResolveAction.confirmTreeConflicts")))
            // $NON-NLS-1$	//$NON-NLS-2$
            return;
        setResolution(ISVNConflictResolver.Choice.chooseMerged);
    } else if (!treeConflictDialogShown) {
        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)
            return;
        setResolution(markResolvedPage.getResolution());
    }
    if (!treeConflictDialogShown)
        super.execute(action);
}
Also used : SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) ResolveTreeConflictWizard(org.tigris.subversion.subclipse.ui.conflicts.ResolveTreeConflictWizard) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) IContainer(org.eclipse.core.resources.IContainer) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) IResource(org.eclipse.core.resources.IResource) SvnWizardMarkResolvedPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardMarkResolvedPage)

Example 15 with LocalResourceStatus

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

the class StatusCacheManager method getStatus.

/**
 * get the status of the given resource
 *
 * @throws SVNException
 */
private LocalResourceStatus getStatus(IResource resource, StatusUpdateStrategy strategy, boolean getStatusFromSvn) throws SVNException {
    if (!resource.exists() && !resource.isPhantom()) {
        return null;
    }
    LocalResourceStatus status = null;
    status = statusCache.getStatus(resource);
    // we get it using svn
    if (status == null && getStatusFromSvn) {
        status = basicGetStatus(resource, strategy);
    }
    return status;
}
Also used : LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)

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