Search in sources :

Example 86 with ISVNLocalResource

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

the class ShowPropertiesSynchronizeOperation method run.

protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    run(new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) {
            getShell().getDisplay().syncExec(new Runnable() {

                public void run() {
                    try {
                        SvnPropertiesView view = (SvnPropertiesView) showView(SvnPropertiesView.VIEW_ID);
                        if (view != null) {
                            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                            view.showSvnProperties(svnResource);
                        }
                    } catch (SVNException e) {
                        SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
                    }
                }
            });
        }
    }, false, /* cancelable */
    PROGRESS_BUSYCURSOR);
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SvnPropertiesView(org.tigris.subversion.subclipse.ui.svnproperties.SvnPropertiesView) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 87 with ISVNLocalResource

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

the class UpdateSynchronizeAction method getSyncInfoFilter.

/* (non-Javadoc)
   * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSyncInfoFilter()
   */
protected FastSyncInfoFilter getSyncInfoFilter() {
    return new FastSyncInfoFilter() {

        public boolean select(SyncInfo info) {
            SyncInfoDirectionFilter filter = new SyncInfoDirectionFilter(new int[] { SyncInfo.INCOMING, SyncInfo.CONFLICTING });
            if (!filter.select(info))
                return false;
            IStructuredSelection selection = getStructuredSelection();
            Iterator iter = selection.iterator();
            while (iter.hasNext()) {
                ISynchronizeModelElement element = (ISynchronizeModelElement) iter.next();
                IResource resource = element.getResource();
                if (resource == null || !resource.exists())
                    return true;
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                try {
                    if (!svnResource.isManaged() || svnResource.isAdded())
                        return false;
                } catch (SVNException e) {
                    return false;
                }
            }
            return true;
        }
    };
}
Also used : SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) Iterator(java.util.Iterator) 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) IResource(org.eclipse.core.resources.IResource) FastSyncInfoFilter(org.eclipse.team.core.synchronize.FastSyncInfoFilter)

Example 88 with ISVNLocalResource

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

the class OverrideAndUpdateSynchronizeAction method getSyncInfoFilter.

protected FastSyncInfoFilter getSyncInfoFilter() {
    return new FastSyncInfoFilter() {

        public boolean select(SyncInfo info) {
            SyncInfoDirectionFilter filter = new SyncInfoDirectionFilter(new int[] { SyncInfo.OUTGOING, SyncInfo.CONFLICTING });
            if (!filter.select(info))
                return false;
            IStructuredSelection selection = getStructuredSelection();
            boolean removeUnAdded = SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_REMOVE_UNADDED_RESOURCES_ON_REPLACE);
            Iterator iter = selection.iterator();
            while (iter.hasNext()) {
                ISynchronizeModelElement element = (ISynchronizeModelElement) iter.next();
                IResource resource = element.getResource();
                if (resource == null) {
                    return false;
                }
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                if (svnResource == null) {
                    return false;
                }
                try {
                    if (!resource.exists() && !svnResource.getStatusFromCache().isDeleted()) {
                        return false;
                    }
                    if (svnResource.isAdded())
                        return false;
                    if (!removeUnAdded && !svnResource.isManaged())
                        return false;
                } catch (SVNException e) {
                    return false;
                }
            }
            return true;
        }
    };
}
Also used : SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) Iterator(java.util.Iterator) 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) IResource(org.eclipse.core.resources.IResource) FastSyncInfoFilter(org.eclipse.team.core.synchronize.FastSyncInfoFilter)

Example 89 with ISVNLocalResource

use of org.tigris.subversion.subclipse.core.ISVNLocalResource 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 90 with ISVNLocalResource

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

the class RevertSynchronizeAction method getSyncInfoFilter.

/* (non-Javadoc)
   * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSyncInfoFilter()
   */
protected FastSyncInfoFilter getSyncInfoFilter() {
    return new FastSyncInfoFilter() {

        @SuppressWarnings("rawtypes")
        public boolean select(SyncInfo info) {
            SyncInfoDirectionFilter outgoingFilter = new SyncInfoDirectionFilter(new int[] { SyncInfo.OUTGOING, SyncInfo.CONFLICTING });
            if (!outgoingFilter.select(info))
                return false;
            IStructuredSelection selection = getStructuredSelection();
            Iterator iter = selection.iterator();
            boolean removeUnAdded = SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_REMOVE_UNADDED_RESOURCES_ON_REPLACE);
            while (iter.hasNext()) {
                ISynchronizeModelElement element = (ISynchronizeModelElement) iter.next();
                IResource resource = element.getResource();
                if (resource == null)
                    continue;
                if (resource.isLinked())
                    return false;
                if (!removeUnAdded) {
                    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                    try {
                        if (!svnResource.isManaged())
                            return false;
                    } catch (SVNException e) {
                        return false;
                    }
                }
            }
            return true;
        }
    };
}
Also used : SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) Iterator(java.util.Iterator) 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) IResource(org.eclipse.core.resources.IResource) FastSyncInfoFilter(org.eclipse.team.core.synchronize.FastSyncInfoFilter)

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