Search in sources :

Example 26 with ISVNLocalResource

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

the class ShowHistorySynchronizeAction method getSyncInfoFilter.

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

        public boolean select(SyncInfo info) {
            IStructuredSelection selection = getStructuredSelection();
            if (selection.size() != 1)
                return false;
            ISynchronizeModelElement element = (ISynchronizeModelElement) selection.getFirstElement();
            IResource resource = element.getResource();
            if (resource == null)
                return false;
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                return !resource.exists() || (svnResource.getStatus().isManaged() && !svnResource.getStatus().isAdded());
            } 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) FastSyncInfoFilter(org.eclipse.team.core.synchronize.FastSyncInfoFilter)

Example 27 with ISVNLocalResource

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

the class SvnPropertiesView method handlePartSelectionChanged.

/**
 * called when the selection changed on another part
 */
private void handlePartSelectionChanged(IWorkbenchPart part, ISelection selection) {
    if (!(selection instanceof IStructuredSelection))
        return;
    try {
        Object first = ((IStructuredSelection) selection).getFirstElement();
        if (first instanceof IAdaptable) {
            IAdaptable a = (IAdaptable) first;
            Object adapter = a.getAdapter(IResource.class);
            if (adapter instanceof IResource) {
                IResource resource = (IResource) adapter;
                // If the resource isn't open or doesn't exist it won't have properties
                if (!resource.isAccessible()) {
                    showSvnProperties(null);
                } else {
                    ISVNLocalResource svnResource = (ISVNLocalResource) resource.getAdapter(ISVNLocalResource.class);
                    showSvnProperties(svnResource);
                }
            }
        }
    } catch (SVNException e) {
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) 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)

Example 28 with ISVNLocalResource

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

the class SvnWizardSwitchPage method getCommonRoot.

private String getCommonRoot() {
    ArrayList<String> urlList = new ArrayList<String>();
    for (IResource resource : resources) {
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        try {
            String anUrl = svnResource.getStatus().getUrlString();
            if (anUrl != null)
                urlList.add(anUrl);
        } catch (SVNException e1) {
        }
    }
    urlStrings = new String[urlList.size()];
    urlList.toArray(urlStrings);
    if (urlStrings.length == 0)
        return null;
    String urlString = urlStrings[0];
    if (urlStrings.length == 1)
        return urlString;
    String commonRoot = null;
    tag1: for (int i = 0; i < urlString.length(); i++) {
        String partialPath = urlString.substring(0, i + 1);
        if (partialPath.endsWith("/")) {
            // $NON-NLS-1$
            for (int j = 1; j < urlStrings.length; j++) {
                if (!urlStrings[j].startsWith(partialPath))
                    break tag1;
            }
            commonRoot = partialPath.substring(0, i);
        }
    }
    switchResources = new SwitchResource[resources.length];
    for (int i = 0; i < resources.length; i++) {
        switchResources[i] = new SwitchResource(resources[i], urlStrings[i].substring(commonRoot.length() + 1));
    }
    return commonRoot;
}
Also used : ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

Example 29 with ISVNLocalResource

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

the class MarkMergedSynchronizeAction 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.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 false;
                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 30 with ISVNLocalResource

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

the class MarkMergedSynchronizeOperation method run.

protected void run(SVNTeamProvider provider, SyncInfoSet set, final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    final IResource[] resources = set.getResources();
    run(new WorkspaceModifyOperation() {

        protected void execute(IProgressMonitor mon) throws CoreException, InvocationTargetException, InterruptedException {
            for (int i = 0; i < resources.length; i++) {
                File tempFile = null;
                try {
                    tempFile = copyToTempFile(resources[i]);
                } catch (Exception e) {
                    SVNUIPlugin.log(e.getMessage());
                    showErrorMessage(e);
                    return;
                }
                if (monitor.isCanceled()) {
                    if (tempFile != null)
                        tempFile.delete();
                    return;
                }
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
                if (svnResource instanceof LocalResource)
                    ((LocalResource) svnResource).revert(false);
                else
                    svnResource.revert();
                new UpdateOperation(getPart(), resources[i], SVNRevision.HEAD).run(monitor);
                if (monitor.isCanceled()) {
                    if (tempFile != null)
                        tempFile.delete();
                    return;
                }
                File file = new File(resources[i].getLocation().toString());
                try {
                    copy(tempFile, file);
                } catch (Exception e1) {
                    SVNUIPlugin.log(e1.getMessage());
                    showErrorMessage(e1);
                }
                if (tempFile != null)
                    tempFile.delete();
            }
        }
    }, true, /* cancelable */
    PROGRESS_BUSYCURSOR);
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) UpdateOperation(org.tigris.subversion.subclipse.ui.operations.UpdateOperation) File(java.io.File) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResource(org.tigris.subversion.subclipse.core.resources.LocalResource)

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