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));
}
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);
}
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);
}
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]);
}
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));
}
Aggregations