Search in sources :

Example 21 with SVNTeamProvider

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

the class CommitSynchronizeOperation method run.

// private IResource[] getUnaddedResources(SyncInfoSet set) {
// IResource[] resources = set.getResources();
// List result = new ArrayList();
// for (int i = 0; i < resources.length; i++) {
// IResource resource = resources[i];
// if (isAdded(resource)) {
// result.add(resource);
// }
// }
// return (IResource[]) result.toArray(new IResource[result.size()]);
// }
// private boolean isAdded(IResource resource) {
// ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
// try {
// if (svnResource.isIgnored())
// return false;
// // visit the children of shared resources
// if (svnResource.isManaged())
// return false;
// if ((resource.getType() == IResource.FOLDER) && isSymLink(resource)) // don't traverse into
// symlink folders
// return false;
// } catch (SVNException e) {
// SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
// return false;
// }
// return true;
// }
// private boolean isSymLink(IResource resource) {
// File file = resource.getLocation().toFile();
// try {
// if (!file.exists())
// return true;
// else {
// String cnnpath = file.getCanonicalPath();
// String abspath = file.getAbsolutePath();
// return !abspath.equals(cnnpath);
// }
// } catch(IOException ex) {
// return true;
// }
// }
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    // First, ask the user if they want to include conflicts
    SyncInfoSet syncSet = getSyncInfoSet();
    if (!promptForConflictHandling(getShell(), syncSet))
        return;
    // Divide the sync info by project
    final Map projectSyncInfos = getProjectSyncInfoSetMap(syncSet);
    Iterator iter = projectSyncInfos.keySet().iterator();
    final IProject project = (IProject) iter.next();
    SVNTeamProvider provider = (SVNTeamProvider) RepositoryProvider.getProvider(project, SVNUIPlugin.PROVIDER_ID);
    monitor.beginTask(null, projectSyncInfos.size() * 100);
    run(provider, syncSet, Policy.subMonitorFor(monitor, 100));
    monitor.done();
}
Also used : SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) Iterator(java.util.Iterator) SyncInfoSet(org.eclipse.team.core.synchronize.SyncInfoSet) HashMap(java.util.HashMap) Map(java.util.Map) IProject(org.eclipse.core.resources.IProject)

Example 22 with SVNTeamProvider

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

the class IgnoreSynchronizeOperation method run.

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    // First, ask the user if they want to include conflicts
    SyncInfoSet syncSet = getSyncInfoSet();
    if (!promptForConflictHandling(getShell(), syncSet))
        return;
    // Divide the sync info by project
    final Map projectSyncInfos = getProjectSyncInfoSetMap(syncSet);
    monitor.beginTask(null, projectSyncInfos.size() * 100);
    for (Iterator iter = projectSyncInfos.keySet().iterator(); iter.hasNext(); ) {
        final IProject project = (IProject) iter.next();
        // Pass the scheduling rule to the synchronizer so that sync change events
        // and cache commits to disk are batched
        SVNTeamProvider provider = (SVNTeamProvider) RepositoryProvider.getProvider(project, SVNUIPlugin.PROVIDER_ID);
        if (provider != null) {
            run(provider, (SyncInfoSet) projectSyncInfos.get(project), Policy.subMonitorFor(monitor, 100));
            break;
        }
    }
    monitor.done();
}
Also used : SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) Iterator(java.util.Iterator) SyncInfoSet(org.eclipse.team.core.synchronize.SyncInfoSet) Map(java.util.Map) IProject(org.eclipse.core.resources.IProject)

Example 23 with SVNTeamProvider

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

the class LockAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    if (action != null && !action.isEnabled()) {
        action.setEnabled(true);
    } else {
        if (getSelectedResources() != null && getSelectedResources().length > 0) {
            final IResource[] resources = getSelectedResources();
            SvnWizardLockPage lockPage = new SvnWizardLockPage(resources);
            SvnWizard wizard = new SvnWizard(lockPage);
            SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
            wizard.setParentDialog(dialog);
            if (dialog.open() == SvnWizardDialog.OK) {
                final String comment = lockPage.getComment();
                final boolean stealLock = lockPage.isStealLock();
                run(new WorkspaceModifyOperation() {

                    protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
                        try {
                            Hashtable table = getProviderMapping(getSelectedResources());
                            Set keySet = table.keySet();
                            Iterator iterator = keySet.iterator();
                            while (iterator.hasNext()) {
                                SVNTeamProvider provider = (SVNTeamProvider) iterator.next();
                                LockResourcesCommand command = new LockResourcesCommand(provider.getSVNWorkspaceRoot(), resources, stealLock, comment);
                                command.run(Policy.subMonitorFor(monitor, 1000));
                            }
                        } catch (TeamException e) {
                            throw new InvocationTargetException(e);
                        } finally {
                            monitor.done();
                        }
                    }
                }, true, /* cancelable */
                PROGRESS_DIALOG);
            }
        }
    }
}
Also used : Set(java.util.Set) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) Hashtable(java.util.Hashtable) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) SvnWizardLockPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardLockPage) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) CoreException(org.eclipse.core.runtime.CoreException) LockResourcesCommand(org.tigris.subversion.subclipse.core.commands.LockResourcesCommand) Iterator(java.util.Iterator) IResource(org.eclipse.core.resources.IResource)

Example 24 with SVNTeamProvider

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

the class SVNLightweightDecorator method decorate.

/**
 * This method should only be called by the decorator thread.
 *
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object,
 *     org.eclipse.jface.viewers.IDecoration)
 */
public void decorate(Object element, IDecoration decoration) {
    IResource resource = null;
    try {
        resource = getResource(element);
        if (resource != null && resource.getType() == IResource.ROOT)
            return;
        boolean isIgnored = false;
        SVNTeamProvider svnProvider = null;
        ISVNLocalResource svnResource = null;
        if (resource != null) {
            // get the team provider
            svnProvider = (SVNTeamProvider) RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
            if (svnProvider == null)
                return;
            // if the resource is ignored return an empty decoration. This will
            // force a decoration update event and clear the existing SVN decoration.
            svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                if (svnResource.isIgnored()) {
                    isIgnored = true;
                // return;
                }
            } catch (SVNException e) {
                // todo should log this error
                return;
            }
        }
        // determine a if resource has outgoing changes (e.g. is dirty).
        boolean isDirty = false;
        boolean isUnversioned = false;
        if (resource == null) {
            if (element instanceof ResourceMapping) {
                IProject[] projects = ((ResourceMapping) element).getProjects();
                if (projects != null) {
                    for (IProject project : projects) {
                        ISVNLocalResource svnProjectResource = SVNWorkspaceRoot.getSVNResourceFor(project);
                        if (svnProjectResource != null) {
                            try {
                                if (svnProjectResource.isDirty()) {
                                    decoration.addOverlay(dirty);
                                    return;
                                }
                            } catch (SVNException e) {
                                return;
                            }
                        }
                    }
                }
            }
            return;
        } else {
            LocalResourceStatus status = null;
            if (!isIgnored) {
                try {
                    status = svnResource.getStatusFromCache();
                    isDirty = SVNLightweightDecorator.isDirty(svnResource, status);
                } catch (SVNException e) {
                    if (!e.operationInterrupted()) {
                        SVNUIPlugin.log(e.getStatus());
                        isDirty = true;
                    }
                }
                if (status != null) {
                    isUnversioned = status.isUnversioned();
                }
                // if (resource.getType() == IResource.FILE || computeDeepDirtyCheck) {
                // //			        isDirty = SVNLightweightDecorator.isDirty(svnResource);
                // isDirty = SVNLightweightDecorator.isDirty(svnResource, status);
                // }
                // try {
                // status = svnResource.getStatusFromCache();
                // isUnversioned = status.isUnversioned();
                // } catch (SVNException e1) {
                // if (!e1.operationInterrupted()) {
                // SVNUIPlugin.log(e1.getStatus());
                // }
                // }
                decorateTextLabel(svnResource, status, decoration, isDirty);
            }
            computeColorsAndFonts(isIgnored, isDirty || isUnversioned, decoration);
            if (!isIgnored) {
                ImageDescriptor overlay = getOverlay(svnResource, status, isDirty, svnProvider);
                if (overlay != null) {
                    // actually sending null arg would work but this makes logic clearer
                    decoration.addOverlay(overlay);
                }
            }
        }
    } catch (Exception e) {
        SVNUIPlugin.log(IStatus.ERROR, "Error Decorating " + resource, e);
    }
}
Also used : SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) ResourceMapping(org.eclipse.core.resources.mapping.ResourceMapping) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException)

Aggregations

SVNTeamProvider (org.tigris.subversion.subclipse.core.SVNTeamProvider)24 IResource (org.eclipse.core.resources.IResource)14 Iterator (java.util.Iterator)12 ArrayList (java.util.ArrayList)11 List (java.util.List)9 TeamException (org.eclipse.team.core.TeamException)9 HashMap (java.util.HashMap)8 Set (java.util.Set)8 IProject (org.eclipse.core.resources.IProject)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 SVNException (org.tigris.subversion.subclipse.core.SVNException)8 Map (java.util.Map)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 Hashtable (java.util.Hashtable)5 CoreException (org.eclipse.core.runtime.CoreException)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 RepositoryProvider (org.eclipse.team.core.RepositoryProvider)5 SyncInfoSet (org.eclipse.team.core.synchronize.SyncInfoSet)5 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)5 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)5