use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItemLabelProvider in project jbosstools-openshift by jbosstools.
the class DeployImagePage method createDockerConnectionControl.
private void createDockerConnectionControl(Composite parent, DataBindingContext dbc) {
createDockerConnectionLabel(parent);
StructuredViewer connectionViewer = new ComboViewer(parent);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(NUM_COLUMS - 2, 1).applyTo(connectionViewer.getControl());
connectionViewer.setContentProvider(new ObservableListContentProvider());
connectionViewer.setLabelProvider(new ObservableTreeItemLabelProvider() {
@Override
public String getText(Object element) {
return (element instanceof IDockerConnection) ? dockerConnectionToString((IDockerConnection) element) : "";
}
});
connectionViewer.setInput(BeanProperties.list(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTIONS).observe(model));
IObservableValue<IDockerConnection> dockerConnectionObservable = BeanProperties.value(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTION).observe(model);
DockerConnectionStatusProvider validator = new DockerConnectionStatusProvider(dockerConnectionObservable);
IObservableValue<?> selectedConnectionObservable = ViewerProperties.singleSelection().observe(connectionViewer);
Binding selectedConnectionBinding = ValueBindingBuilder.bind(selectedConnectionObservable).converting(new ObservableTreeItem2ModelConverter(IDockerConnection.class)).validatingAfterConvert(validator).to(BeanProperties.value(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTION).observe(model)).in(dbc);
ControlDecorationSupport.create(selectedConnectionBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
Button newDockerConnectionButton = new Button(parent, SWT.PUSH);
newDockerConnectionButton.setText("New...");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(newDockerConnectionButton);
UIUtils.setDefaultButtonWidth(newDockerConnectionButton);
newDockerConnectionButton.addSelectionListener(onNewDockerConnectionClicked());
dbc.addValidationStatusProvider(validator);
}
use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItemLabelProvider 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());
}
Aggregations