Search in sources :

Example 6 with FastSyncInfoFilter

use of org.eclipse.team.core.synchronize.FastSyncInfoFilter 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 7 with FastSyncInfoFilter

use of org.eclipse.team.core.synchronize.FastSyncInfoFilter 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 8 with FastSyncInfoFilter

use of org.eclipse.team.core.synchronize.FastSyncInfoFilter 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)

Example 9 with FastSyncInfoFilter

use of org.eclipse.team.core.synchronize.FastSyncInfoFilter in project subclipse by subclipse.

the class IgnoreSynchronizeAction 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.OUTGOING });
            if (!filter.select(info))
                return false;
            IStructuredSelection selection = getStructuredSelection();
            ISynchronizeModelElement element = (ISynchronizeModelElement) selection.getFirstElement();
            IResource resource = element.getResource();
            if (resource == null)
                return false;
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                // If the resource is a IProject then the action should not be enabled.
                if (svnResource.getIResource() instanceof IProject)
                    return false;
                // If the parent is not managed there is no way to set the svn:ignore property
                if (!svnResource.getParent().isManaged()) {
                    return false;
                }
                return !svnResource.getStatus().isManaged() && resource.exists();
            } catch (SVNException e) {
                return false;
            }
        }
    };
}
Also used : SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) 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) IProject(org.eclipse.core.resources.IProject) FastSyncInfoFilter(org.eclipse.team.core.synchronize.FastSyncInfoFilter)

Example 10 with FastSyncInfoFilter

use of org.eclipse.team.core.synchronize.FastSyncInfoFilter in project subclipse by subclipse.

the class AddSynchronizeAction method getSyncInfoFilter.

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

        public boolean select(SyncInfo info) {
            SyncInfoDirectionFilter filter = new SyncInfoDirectionFilter(new int[] { SyncInfo.OUTGOING });
            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)
                    return false;
                if (resource.isLinked())
                    return false;
                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

IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 FastSyncInfoFilter (org.eclipse.team.core.synchronize.FastSyncInfoFilter)10 SyncInfo (org.eclipse.team.core.synchronize.SyncInfo)10 ISynchronizeModelElement (org.eclipse.team.ui.synchronize.ISynchronizeModelElement)10 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)10 SVNException (org.tigris.subversion.subclipse.core.SVNException)10 IResource (org.eclipse.core.resources.IResource)9 Iterator (java.util.Iterator)6 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)1