Search in sources :

Example 1 with GitModelCache

use of org.eclipse.egit.ui.internal.synchronize.model.GitModelCache in project egit by eclipse.

the class GitChangeSetSorter method compare.

@Override
public int compare(Viewer viewer, Object e1, Object e2) {
    if (e1 instanceof GitModelBlob && !(e2 instanceof GitModelBlob))
        return 1;
    if (e2 instanceof GitModelBlob && !(e1 instanceof GitModelBlob))
        return -1;
    if (e1 instanceof GitModelWorkingTree)
        return -1;
    if (e2 instanceof GitModelWorkingTree)
        return 1;
    if (e1 instanceof GitModelCache)
        return -2;
    if (e2 instanceof GitModelCache)
        return 2;
    if ((e1 instanceof GitModelTree && e2 instanceof GitModelTree) || (e1 instanceof GitModelBlob && e2 instanceof GitModelBlob))
        return super.compare(viewer, e1, e2);
    if (e1 instanceof GitModelTree && e2 instanceof GitModelCommit)
        return 1;
    if (e1 instanceof GitModelCommit && e2 instanceof GitModelCommit) {
        Commit rc1 = ((GitModelCommit) e1).getCachedCommitObj();
        Commit rc2 = ((GitModelCommit) e2).getCachedCommitObj();
        return rc2.getCommitDate().compareTo(rc1.getCommitDate());
    }
    return super.compare(viewer, e1, e2);
}
Also used : GitModelCache(org.eclipse.egit.ui.internal.synchronize.model.GitModelCache) Commit(org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit) GitModelCommit(org.eclipse.egit.ui.internal.synchronize.model.GitModelCommit) GitModelTree(org.eclipse.egit.ui.internal.synchronize.model.GitModelTree) GitModelCommit(org.eclipse.egit.ui.internal.synchronize.model.GitModelCommit) GitModelBlob(org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob) GitModelWorkingTree(org.eclipse.egit.ui.internal.synchronize.model.GitModelWorkingTree)

Example 2 with GitModelCache

use of org.eclipse.egit.ui.internal.synchronize.model.GitModelCache in project egit by eclipse.

the class GitChangeSetSorterTest method commitTreeShouldBeGreaterThanCache.

@Test
public void commitTreeShouldBeGreaterThanCache() {
    // given
    Viewer viewer = mock(Viewer.class);
    GitChangeSetSorter sorter = new GitChangeSetSorter();
    GitModelCommit commit = mock(GitModelCommit.class);
    GitModelCache cache = mock(GitModelCache.class);
    // when
    int actual = sorter.compare(viewer, commit, cache);
    // then
    assertTrue(actual > 0);
}
Also used : GitModelCache(org.eclipse.egit.ui.internal.synchronize.model.GitModelCache) GitModelCommit(org.eclipse.egit.ui.internal.synchronize.model.GitModelCommit) CommonViewer(org.eclipse.ui.navigator.CommonViewer) Viewer(org.eclipse.jface.viewers.Viewer) Test(org.junit.Test)

Example 3 with GitModelCache

use of org.eclipse.egit.ui.internal.synchronize.model.GitModelCache in project egit by eclipse.

the class GitChangeSetSorterTest method cacheTreeShouldBeLessThanCommit.

@Test
public void cacheTreeShouldBeLessThanCommit() {
    // given
    Viewer viewer = mock(Viewer.class);
    GitChangeSetSorter sorter = new GitChangeSetSorter();
    GitModelCache cache = mock(GitModelCache.class);
    GitModelCommit commit = mock(GitModelCommit.class);
    // when
    int actual = sorter.compare(viewer, cache, commit);
    // then
    assertTrue(actual < 0);
}
Also used : GitModelCache(org.eclipse.egit.ui.internal.synchronize.model.GitModelCache) GitModelCommit(org.eclipse.egit.ui.internal.synchronize.model.GitModelCommit) CommonViewer(org.eclipse.ui.navigator.CommonViewer) Viewer(org.eclipse.jface.viewers.Viewer) Test(org.junit.Test)

Example 4 with GitModelCache

use of org.eclipse.egit.ui.internal.synchronize.model.GitModelCache in project egit by eclipse.

the class GitChangeSetSorterTest method cacheTreeShouldBeGreaterThanWorkingTree.

/*
	 * Tests for GitModelCache
	 */
@Test
public void cacheTreeShouldBeGreaterThanWorkingTree() {
    // given
    Viewer viewer = mock(Viewer.class);
    GitChangeSetSorter sorter = new GitChangeSetSorter();
    GitModelCache cache = mock(GitModelCache.class);
    GitModelWorkingTree workingTree = mock(GitModelWorkingTree.class);
    // when
    int actual = sorter.compare(viewer, cache, workingTree);
    // then
    assertTrue(actual > 0);
}
Also used : GitModelCache(org.eclipse.egit.ui.internal.synchronize.model.GitModelCache) CommonViewer(org.eclipse.ui.navigator.CommonViewer) Viewer(org.eclipse.jface.viewers.Viewer) GitModelWorkingTree(org.eclipse.egit.ui.internal.synchronize.model.GitModelWorkingTree) Test(org.junit.Test)

Example 5 with GitModelCache

use of org.eclipse.egit.ui.internal.synchronize.model.GitModelCache in project egit by eclipse.

the class GitChangeSetSorterTest method cacheTreeShouldBeLessThanTree.

@Test
public void cacheTreeShouldBeLessThanTree() {
    // given
    Viewer viewer = mock(Viewer.class);
    GitChangeSetSorter sorter = new GitChangeSetSorter();
    GitModelCache cache = mock(GitModelCache.class);
    GitModelTree tree = mock(GitModelTree.class);
    // when
    int actual = sorter.compare(viewer, cache, tree);
    // then
    assertTrue(actual < 0);
}
Also used : GitModelCache(org.eclipse.egit.ui.internal.synchronize.model.GitModelCache) GitModelTree(org.eclipse.egit.ui.internal.synchronize.model.GitModelTree) CommonViewer(org.eclipse.ui.navigator.CommonViewer) Viewer(org.eclipse.jface.viewers.Viewer) Test(org.junit.Test)

Aggregations

GitModelCache (org.eclipse.egit.ui.internal.synchronize.model.GitModelCache)10 Viewer (org.eclipse.jface.viewers.Viewer)8 CommonViewer (org.eclipse.ui.navigator.CommonViewer)8 Test (org.junit.Test)8 GitModelWorkingTree (org.eclipse.egit.ui.internal.synchronize.model.GitModelWorkingTree)4 GitModelBlob (org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob)3 GitModelCommit (org.eclipse.egit.ui.internal.synchronize.model.GitModelCommit)3 GitModelTree (org.eclipse.egit.ui.internal.synchronize.model.GitModelTree)3 Commit (org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1