Search in sources :

Example 1 with GitModelBlob

use of org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob 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 GitModelBlob

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

the class GitChangeSetSorterTest method workingTreeShouldBeLessThanBlob.

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

Example 3 with GitModelBlob

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

the class GitChangeSetSorterTest method commitTreeShouldBeLessThanBlob.

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

Example 4 with GitModelBlob

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

the class GitChangeSetSorterTest method blobShouldBeGreaterThanTree.

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

Example 5 with GitModelBlob

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

the class GitChangeSetSorterTest method commitTreeShouldBeLessThanTree.

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

Aggregations

GitModelBlob (org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob)13 CommonViewer (org.eclipse.ui.navigator.CommonViewer)10 Test (org.junit.Test)10 Viewer (org.eclipse.jface.viewers.Viewer)9 GitModelTree (org.eclipse.egit.ui.internal.synchronize.model.GitModelTree)5 GitModelCache (org.eclipse.egit.ui.internal.synchronize.model.GitModelCache)3 GitModelCommit (org.eclipse.egit.ui.internal.synchronize.model.GitModelCommit)3 GitModelWorkingTree (org.eclipse.egit.ui.internal.synchronize.model.GitModelWorkingTree)3 GitModelObject (org.eclipse.egit.ui.internal.synchronize.model.GitModelObject)2 File (java.io.File)1 Iterator (java.util.Iterator)1 IResource (org.eclipse.core.resources.IResource)1 ResourceMapping (org.eclipse.core.resources.mapping.ResourceMapping)1 Commit (org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit)1 GitHistoryPage (org.eclipse.egit.ui.internal.history.GitHistoryPage)1 RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)1 GitModelWorkbenchAdapter (org.eclipse.egit.ui.internal.synchronize.mapping.GitModelWorkbenchAdapter)1 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1