use of org.jboss.tools.openshift.internal.ui.explorer.OpenShiftExplorerLabelProvider in project jbosstools-openshift by jbosstools.
the class BuildConfigWizardPage method createBuildConfigsViewer.
private TreeViewer createBuildConfigsViewer(Tree tree, IBuildConfigPageModel model, DataBindingContext dbc) {
TreeViewer buildConfigsViewer = new TreeViewer(tree);
IListProperty childrenProperty = new MultiListProperty(new IListProperty[] { BeanProperties.list(IBuildConfigPageModel.PROPERTY_BUILDCONFIGS), BeanProperties.list(ObservableTreeItem.PROPERTY_CHILDREN) });
ObservableListTreeContentProvider contentProvider = new ObservableListTreeContentProvider(childrenProperty.listFactory(), null);
buildConfigsViewer.setContentProvider(contentProvider);
buildConfigsViewer.setLabelProvider(new ObservableTreeItemStyledCellLabelProvider());
buildConfigsViewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
buildConfigsViewer.setComparator(ProjectViewerComparator.createProjectTreeSorter(new OpenShiftExplorerLabelProvider()));
buildConfigsViewer.setInput(model);
return buildConfigsViewer;
}
use of org.jboss.tools.openshift.internal.ui.explorer.OpenShiftExplorerLabelProvider in project jbosstools-openshift by jbosstools.
the class ProjectTreeSorterTest method testProjectItemsWithLabelProvider.
@Test
public void testProjectItemsWithLabelProvider() {
final Comparator<ObservableTreeItem> comparator = new ProjectViewerComparator(new OpenShiftExplorerLabelProvider()).asItemComparator();
ObservableTreeItem p1 = new ObservableTreeItem(mockProject("default", "z"));
ObservableTreeItem p2 = new ObservableTreeItem(mockProject("openshift", "y"));
ObservableTreeItem p3 = new ObservableTreeItem(mockProject("a", "c"));
ObservableTreeItem p4 = new ObservableTreeItem(mockProject("b2", null));
ObservableTreeItem p5 = new ObservableTreeItem(mockProject("d", "b"));
ObservableTreeItem[] projects = new ObservableTreeItem[] { p3, p5, p2, p1, p4 };
Arrays.sort(projects, comparator);
assertEquals(p1, projects[0]);
assertEquals(p2, projects[1]);
assertEquals(p5, projects[2]);
assertEquals(p4, projects[3]);
assertEquals(p3, projects[4]);
}
use of org.jboss.tools.openshift.internal.ui.explorer.OpenShiftExplorerLabelProvider 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.explorer.OpenShiftExplorerLabelProvider in project jbosstools-openshift by jbosstools.
the class AbstractProjectPage method createProjectControls.
private void createProjectControls(Composite parent, DataBindingContext dbc) {
Label projectLabel = new Label(parent, SWT.NONE);
projectLabel.setText("OpenShift project: ");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(projectLabel);
StructuredViewer projectsViewer = new ComboViewer(parent);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(projectsViewer.getControl());
final OpenShiftExplorerLabelProvider labelProvider = new OpenShiftExplorerLabelProvider();
projectsViewer.setContentProvider(new ObservableListContentProvider());
projectsViewer.setLabelProvider(new ObservableTreeItemLabelProvider());
projectsViewer.setInput(BeanProperties.list(IProjectPageModel.PROPERTY_PROJECT_ITEMS).observe(model));
projectsViewer.setComparator(ProjectViewerComparator.createProjectTreeSorter(labelProvider));
model.setProjectsComparator(new ProjectViewerComparator(labelProvider).asItemComparator());
IObservableValue selectedProjectObservable = ViewerProperties.singleSelection().observe(projectsViewer);
Binding selectedProjectBinding = ValueBindingBuilder.bind(selectedProjectObservable).converting(new ObservableTreeItem2ModelConverter(IProject.class)).validatingAfterConvert(new IValidator() {
@Override
public IStatus validate(Object value) {
if (value instanceof IProject) {
return ValidationStatus.ok();
}
return ValidationStatus.cancel("Please choose an OpenShift project.");
}
}).to(BeanProperties.value(IProjectPageModel.PROPERTY_PROJECT).observe(model)).converting(new Model2ObservableTreeItemConverter(null)).in(dbc);
ControlDecorationSupport.create(selectedProjectBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
IObservableValue connectionObservable = BeanProperties.value(IProjectPageModel.PROPERTY_CONNECTION).observe(model);
DataBindingUtils.addDisposableValueChangeListener(onConnectionChanged(), connectionObservable, projectsViewer.getControl());
Button newProjectButton = new Button(parent, SWT.PUSH);
newProjectButton.setText("New...");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.FILL).applyTo(newProjectButton);
UIUtils.setDefaultButtonWidth(newProjectButton);
newProjectButton.addSelectionListener(onNewProjectClicked());
}
use of org.jboss.tools.openshift.internal.ui.explorer.OpenShiftExplorerLabelProvider in project jbosstools-openshift by jbosstools.
the class DeployImagePage method createProjectControl.
private void createProjectControl(Composite parent, DataBindingContext dbc) {
Label lblProject = new Label(parent, SWT.NONE);
lblProject.setText("OpenShift Project: ");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(lblProject);
StructuredViewer cmboProject = new ComboViewer(parent);
GridDataFactory.fillDefaults().span(NUM_COLUMS - 2, 1).applyTo(cmboProject.getControl());
final OpenShiftExplorerLabelProvider labelProvider = new OpenShiftExplorerLabelProvider();
cmboProject.setContentProvider(new ObservableListContentProvider());
cmboProject.setLabelProvider(labelProvider);
cmboProject.setInput(BeanProperties.list(IDeployImagePageModel.PROPERTY_PROJECTS).observe(model));
ProjectViewerComparator comparator = new ProjectViewerComparator(labelProvider);
cmboProject.setComparator(comparator);
model.setProjectsComparator(comparator.asProjectComparator());
IObservableValue<IProject> projectObservable = BeanProperties.value(IDeployImagePageModel.PROPERTY_PROJECT).observe(model);
ProjectStatusProvider validator = new ProjectStatusProvider(projectObservable);
IObservableValue selectedProjectObservable = ViewerProperties.singleSelection().observe(cmboProject);
Binding selectedProjectBinding = ValueBindingBuilder.bind(selectedProjectObservable).converting(new ObservableTreeItem2ModelConverter(IProject.class)).validatingAfterConvert(validator).to(projectObservable).in(dbc);
ControlDecorationSupport.create(selectedProjectBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
Button newProjectButton = new Button(parent, SWT.PUSH);
newProjectButton.setText("New...");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(newProjectButton);
UIUtils.setDefaultButtonWidth(newProjectButton);
newProjectButton.addSelectionListener(onNewProjectClicked());
dbc.addValidationStatusProvider(validator);
cmboProject.getControl().forceFocus();
}
Aggregations