Search in sources :

Example 1 with UntrackOperation

use of org.eclipse.egit.core.op.UntrackOperation in project egit by eclipse.

the class TrackUntrackOperationTest method testTrackProject.

@Test
public void testTrackProject() throws Exception {
    final ArrayList<IContainer> containers = new ArrayList<IContainer>();
    containers.add(project);
    final ArrayList<IFile> files = new ArrayList<IFile>();
    project.accept(new IResourceVisitor() {

        @Override
        public boolean visit(IResource resource) throws CoreException {
            if (resource instanceof IFile)
                files.add((IFile) resource);
            return true;
        }
    });
    IFile[] fileArr = files.toArray(new IFile[files.size()]);
    assertTrackedState(fileArr, false);
    AddToIndexOperation trop = new AddToIndexOperation(containers);
    trop.execute(new NullProgressMonitor());
    assertTrackedState(fileArr, true);
    UntrackOperation utrop = new UntrackOperation(containers);
    utrop.execute(new NullProgressMonitor());
    assertTrackedState(fileArr, false);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IResourceVisitor(org.eclipse.core.resources.IResourceVisitor) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) AddToIndexOperation(org.eclipse.egit.core.op.AddToIndexOperation) CoreException(org.eclipse.core.runtime.CoreException) UntrackOperation(org.eclipse.egit.core.op.UntrackOperation) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) Test(org.junit.Test)

Example 2 with UntrackOperation

use of org.eclipse.egit.core.op.UntrackOperation in project egit by eclipse.

the class UntrackActionHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IResource[] resources = getSelectedResources();
    if (resources.length == 0)
        return null;
    JobUtil.scheduleUserJob(new UntrackOperation(Arrays.asList(resources)), UIText.Untrack_untrack, JobFamilies.UNTRACK);
    return null;
}
Also used : UntrackOperation(org.eclipse.egit.core.op.UntrackOperation) IResource(org.eclipse.core.resources.IResource)

Example 3 with UntrackOperation

use of org.eclipse.egit.core.op.UntrackOperation in project egit by eclipse.

the class TrackUntrackOperationTest method testTrackFiles.

@Test
public void testTrackFiles() throws Exception {
    final ArrayList<IFile> files = new ArrayList<IFile>();
    project.accept(new IResourceVisitor() {

        @Override
        public boolean visit(IResource resource) throws CoreException {
            if (resource instanceof IFile)
                files.add((IFile) resource);
            return true;
        }
    });
    IFile[] fileArr = files.toArray(new IFile[files.size()]);
    assertTrackedState(fileArr, false);
    AddToIndexOperation trop = new AddToIndexOperation(files);
    trop.execute(new NullProgressMonitor());
    assertTrackedState(fileArr, true);
    UntrackOperation utop = new UntrackOperation(Arrays.asList(fileArr));
    utop.execute(new NullProgressMonitor());
    assertTrackedState(fileArr, false);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IResourceVisitor(org.eclipse.core.resources.IResourceVisitor) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) UntrackOperation(org.eclipse.egit.core.op.UntrackOperation) IResource(org.eclipse.core.resources.IResource) AddToIndexOperation(org.eclipse.egit.core.op.AddToIndexOperation) Test(org.junit.Test)

Example 4 with UntrackOperation

use of org.eclipse.egit.core.op.UntrackOperation in project egit by eclipse.

the class StagingView method untrack.

private void untrack(@NonNull IStructuredSelection selection) {
    List<IPath> locations = new ArrayList<>();
    collectPaths(selection.toList(), locations);
    if (locations.isEmpty()) {
        return;
    }
    JobUtil.scheduleUserJob(new UntrackOperation(currentRepository, locations), UIText.Untrack_untrack, JobFamilies.UNTRACK);
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) UntrackOperation(org.eclipse.egit.core.op.UntrackOperation)

Aggregations

UntrackOperation (org.eclipse.egit.core.op.UntrackOperation)4 ArrayList (java.util.ArrayList)3 IResource (org.eclipse.core.resources.IResource)3 IFile (org.eclipse.core.resources.IFile)2 IResourceVisitor (org.eclipse.core.resources.IResourceVisitor)2 CoreException (org.eclipse.core.runtime.CoreException)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 AddToIndexOperation (org.eclipse.egit.core.op.AddToIndexOperation)2 Test (org.junit.Test)2 IContainer (org.eclipse.core.resources.IContainer)1 IPath (org.eclipse.core.runtime.IPath)1