Search in sources :

Example 6 with ProjectViewerComparator

use of org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator in project jbosstools-openshift by jbosstools.

the class ProjectTreeSorterTest method testProjectsWithLabelProvider.

@Test
public void testProjectsWithLabelProvider() {
    final ViewerComparator comparator = new ProjectViewerComparator(new OpenShiftExplorerLabelProvider());
    IProject p1 = mockProject("default", "z");
    IProject p2 = mockProject("openshift", "y");
    IProject p3 = mockProject("a", "c");
    IProject p4 = mockProject("b2", null);
    IProject p5 = mockProject("d", "b");
    IProject[] projects = new IProject[] { p3, p5, p2, p1, p4 };
    Arrays.sort(projects, new Comparator<IProject>() {

        @Override
        public int compare(IProject o1, IProject o2) {
            return comparator.compare(null, o1, o2);
        }
    });
    assertEquals(p1, projects[0]);
    assertEquals(p2, projects[1]);
    assertEquals(p5, projects[2]);
    assertEquals(p4, projects[3]);
    assertEquals(p3, projects[4]);
}
Also used : ProjectViewerComparator(org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) OpenShiftExplorerLabelProvider(org.jboss.tools.openshift.internal.ui.explorer.OpenShiftExplorerLabelProvider) ProjectViewerComparator(org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator) IProject(com.openshift.restclient.model.IProject) Test(org.junit.Test)

Aggregations

ProjectViewerComparator (org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator)6 OpenShiftExplorerLabelProvider (org.jboss.tools.openshift.internal.ui.explorer.OpenShiftExplorerLabelProvider)4 IProject (com.openshift.restclient.model.IProject)3 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)3 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)3 Button (org.eclipse.swt.widgets.Button)3 Binding (org.eclipse.core.databinding.Binding)2 ComboViewer (org.eclipse.jface.viewers.ComboViewer)2 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)2 Label (org.eclipse.swt.widgets.Label)2 RequiredControlDecorationUpdater (org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater)2 ObservableTreeItem2ModelConverter (org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter)2 Test (org.junit.Test)2 IValidator (org.eclipse.core.databinding.validation.IValidator)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1 IsNotNull2BooleanConverter (org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNull2BooleanConverter)1 Model2ObservableTreeItemConverter (org.jboss.tools.openshift.internal.ui.treeitem.Model2ObservableTreeItemConverter)1 ObservableTreeItem (org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem)1