Search in sources :

Example 6 with ObservableTreeItem

use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem in project jbosstools-openshift by jbosstools.

the class ProjectTreeSorterTest method testBuildConfigs.

@Test
public void testBuildConfigs() {
    ViewerComparator comparator = ProjectViewerComparator.createProjectTreeSorter(new OpenShiftExplorerLabelProvider());
    ObservableTreeItem i1 = new ObservableTreeItem(mockBuildConfig("n", "c1", "z"));
    ObservableTreeItem i2 = new ObservableTreeItem(mockBuildConfig("n", "c2", "x"));
    // compared by source uri!
    assertTrue(comparator.compare(null, i1, i2) < 0);
    assertTrue(comparator.compare(null, i2, i1) > 0);
    assertEquals(0, comparator.compare(null, i1, i1));
}
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) ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) Test(org.junit.Test)

Example 7 with ObservableTreeItem

use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem in project jbosstools-openshift by jbosstools.

the class ResourcesViewLabelProvider method update.

@Override
public void update(ViewerCell cell) {
    Object element = cell.getElement();
    if (!(element instanceof ObservableTreeItem)) {
        return;
    }
    if (!(((ObservableTreeItem) element).getModel() instanceof IResource)) {
        return;
    }
    IResource resource = (IResource) ((ObservableTreeItem) element).getModel();
    StyledString text = new StyledString();
    if (resource instanceof com.openshift.restclient.model.IProject) {
        createProjectLabel(text, (com.openshift.restclient.model.IProject) resource);
    } else if (resource instanceof IService) {
        createServiceLabel(text, (IService) resource);
    } else if (resource instanceof IReplicationController) {
        createReplicationControllerLabel(text, (IReplicationController) resource);
    }
    cell.setText(text.toString());
    cell.setStyleRanges(text.getStyleRanges());
    super.update(cell);
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) IResource(com.openshift.restclient.model.IResource) IService(com.openshift.restclient.model.IService) IReplicationController(com.openshift.restclient.model.IReplicationController)

Example 8 with ObservableTreeItem

use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem in project jbosstools-openshift by jbosstools.

the class NewApplicationWizardModel method loadResources.

@Override
public void loadResources() {
    if (connection == null) {
        return;
    }
    ObservableTreeItem connectionItem = ApplicationSourceTreeItems.INSTANCE.create(connection);
    connectionItem.load();
    List<ObservableTreeItem> projects = connectionItem.getChildren();
    setProjectItems(projects);
}
Also used : ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem)

Example 9 with ObservableTreeItem

use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem in project jbosstools-openshift by jbosstools.

the class ProjectTreeSorterTest method testProjectsInTree.

@Test
public void testProjectsInTree() {
    final ViewerComparator comparator = ProjectViewerComparator.createProjectTreeSorter();
    ObservableTreeItem i1 = new ObservableTreeItem(mockProject("default", null));
    ObservableTreeItem i2 = new ObservableTreeItem(mockProject("openshift", null));
    ObservableTreeItem i3 = new ObservableTreeItem(mockProject("a", null));
    ObservableTreeItem i4 = new ObservableTreeItem(mockProject("d", null));
    ObservableTreeItem[] items = new ObservableTreeItem[] { i2, i4, i3, i1 };
    Arrays.sort(items, new Comparator<ObservableTreeItem>() {

        @Override
        public int compare(ObservableTreeItem o1, ObservableTreeItem o2) {
            return comparator.compare(null, o1, o2);
        }
    });
    assertEquals(i1, items[0]);
    assertEquals(i2, items[1]);
    assertEquals(i3, items[2]);
    assertEquals(i4, items[3]);
}
Also used : ProjectViewerComparator(org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) Test(org.junit.Test)

Example 10 with ObservableTreeItem

use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem in project jbosstools-openshift by jbosstools.

the class ProjectTreeSorterTest method testServices.

@Test
public void testServices() {
    ViewerComparator comparator = ProjectViewerComparator.createProjectTreeSorter();
    ObservableTreeItem i1 = new ObservableTreeItem(mockService("s1", "z"));
    ObservableTreeItem i2 = new ObservableTreeItem(mockService("s2", "a"));
    assertTrue(comparator.compare(null, i1, i2) < 0);
    assertTrue(comparator.compare(null, i2, i1) > 0);
    assertEquals(0, comparator.compare(null, i1, i1));
}
Also used : ProjectViewerComparator(org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) Test(org.junit.Test)

Aggregations

ObservableTreeItem (org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem)16 Test (org.junit.Test)10 IProject (com.openshift.restclient.model.IProject)5 Connection (org.jboss.tools.openshift.core.connection.Connection)4 ProjectViewerComparator (org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator)4 ArrayList (java.util.ArrayList)3 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)3 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)3 IReplicationController (com.openshift.restclient.model.IReplicationController)2 IResource (com.openshift.restclient.model.IResource)2 IService (com.openshift.restclient.model.IService)2 MultiListProperty (org.eclipse.core.databinding.property.list.MultiListProperty)2 ObservableListTreeContentProvider (org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 OpenShiftExplorerLabelProvider (org.jboss.tools.openshift.internal.ui.explorer.OpenShiftExplorerLabelProvider)2 IBuildConfig (com.openshift.restclient.model.IBuildConfig)1 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)1 IRoute (com.openshift.restclient.model.route.IRoute)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1