use of org.jboss.tools.openshift.internal.ui.wizard.importapp.BuildConfigTreeItems.Model2ObservableTreeItemConverter in project jbosstools-openshift by jbosstools.
the class BuildConfigWizardPage method doCreateControls.
@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(parent);
GridLayoutFactory.fillDefaults().applyTo(parent);
Group buildConfigsGroup = new Group(parent, SWT.NONE);
buildConfigsGroup.setText("Existing Build Configs:");
GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(buildConfigsGroup);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(buildConfigsGroup);
// build configs tree
TreeViewer buildConfigsViewer = createBuildConfigsViewer(new Tree(buildConfigsGroup, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL), model, dbc);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 200).span(1, 2).applyTo(buildConfigsViewer.getControl());
final IObservableValue selectedItem = BeanProperties.value(IBuildConfigPageModel.PROPERTY_SELECTED_ITEM).observe(model);
Binding selectedBuildConfigBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(buildConfigsViewer)).converting(new ObservableTreeItem2ModelConverter()).to(selectedItem).converting(new Model2ObservableTreeItemConverter()).in(dbc);
dbc.addValidationStatusProvider(new MultiValidator() {
@Override
protected IStatus validate() {
if (!(selectedItem.getValue() instanceof IBuildConfig)) {
return ValidationStatus.cancel("Please select the existing build config that you want to import");
} else {
return ValidationStatus.ok();
}
}
});
IObservableValue connectionObservable = BeanProperties.value(IBuildConfigPageModel.PROPERTY_CONNECTION).observe(model);
DataBindingUtils.addDisposableValueChangeListener(onConnectionChanged(buildConfigsViewer, model), connectionObservable, buildConfigsViewer.getTree());
ControlDecorationSupport.create(selectedBuildConfigBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
// refresh button
Button refreshButton = new Button(buildConfigsGroup, SWT.PUSH);
refreshButton.setText("&Refresh");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(100, SWT.DEFAULT).applyTo(refreshButton);
refreshButton.addSelectionListener(onRefresh(buildConfigsViewer, model));
// filler
Label fillerLabel = new Label(buildConfigsGroup, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, true).applyTo(fillerLabel);
// details
ExpandableComposite expandable = new ExpandableComposite(buildConfigsGroup, SWT.None);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(expandable);
expandable.setText("Build config Details");
expandable.setExpanded(true);
GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).spacing(0, 0).applyTo(expandable);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(expandable);
Composite detailsContainer = new Composite(expandable, SWT.NONE);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(detailsContainer);
IObservableValue selectedService = new WritableValue();
ValueBindingBuilder.bind(selectedItem).to(selectedService).notUpdatingParticipant().in(dbc);
new BuildConfigDetailViews(selectedService, detailsContainer, dbc).createControls();
expandable.setClient(detailsContainer);
expandable.addExpansionListener(new IExpansionListener() {
@Override
public void expansionStateChanging(ExpansionEvent e) {
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
buildConfigsGroup.update();
buildConfigsGroup.layout(true);
}
});
loadBuildConfigs(model);
}
Aggregations