Search in sources :

Example 1 with SvnWizardMarkResolvedPage

use of org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardMarkResolvedPage 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 2 with SvnWizardMarkResolvedPage

use of org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardMarkResolvedPage 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)

Aggregations

IContainer (org.eclipse.core.resources.IContainer)2 IResource (org.eclipse.core.resources.IResource)2 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)2 SVNException (org.tigris.subversion.subclipse.core.SVNException)2 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)2 SvnWizard (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard)2 SvnWizardDialog (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog)2 SvnWizardMarkResolvedPage (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardMarkResolvedPage)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 TeamException (org.eclipse.team.core.TeamException)1 WorkspaceModifyOperation (org.eclipse.ui.actions.WorkspaceModifyOperation)1 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)1 ResolveTreeConflictWizard (org.tigris.subversion.subclipse.ui.conflicts.ResolveTreeConflictWizard)1 SizePersistedWizardDialog (org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog)1 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)1 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)1