Search in sources :

Example 11 with GitModelBlob

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

the class GitChangeSetSorterTest method blobShouldBeGreaterThanCache.

@Test
public void blobShouldBeGreaterThanCache() {
    // given
    Viewer viewer = mock(Viewer.class);
    GitChangeSetSorter sorter = new GitChangeSetSorter();
    GitModelBlob blob = mock(GitModelBlob.class);
    GitModelCache cache = mock(GitModelCache.class);
    // when
    int actual = sorter.compare(viewer, blob, cache);
    // 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) GitModelBlob(org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob) Test(org.junit.Test)

Example 12 with GitModelBlob

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

the class GitChangeSetSorterTest method shouldOrderBlobsAlphabetically.

@Test
public void shouldOrderBlobsAlphabetically() {
    // given
    CommonViewer viewer = mock(CommonViewer.class);
    GitChangeSetSorter sorter = new GitChangeSetSorter();
    GitModelBlob blob1 = mock(GitModelBlob.class);
    GitModelBlob blob2 = mock(GitModelBlob.class);
    ILabelProvider labelProvider = mock(ILabelProvider.class);
    when(labelProvider.getText(blob1)).thenReturn("aaa");
    when(labelProvider.getText(blob2)).thenReturn("zzz");
    when(viewer.getLabelProvider()).thenReturn(labelProvider);
    // when
    int actual1 = sorter.compare(viewer, blob1, blob2);
    int actual2 = sorter.compare(viewer, blob2, blob1);
    // then
    assertTrue(actual1 < 0);
    assertTrue(actual2 > 0);
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) GitModelBlob(org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob) Test(org.junit.Test)

Example 13 with GitModelBlob

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

the class GitOpenInCompareAction method run.

@Override
public void run() {
    ISelection selection = conf.getSite().getSelectionProvider().getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sel = ((IStructuredSelection) selection);
        boolean reuseEditor = sel.size() == 1;
        for (Iterator iterator = sel.iterator(); iterator.hasNext(); ) {
            Object obj = iterator.next();
            if (obj instanceof GitModelBlob)
                handleGitObjectComparison((GitModelBlob) obj, reuseEditor);
            else {
                oldAction.run();
                // meet not know object
                break;
            }
        }
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) Iterator(java.util.Iterator) GitModelObject(org.eclipse.egit.ui.internal.synchronize.model.GitModelObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GitModelBlob(org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob)

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