use of org.jboss.tools.openshift.internal.common.ui.databinding.TabFolderSelectionProperty in project jbosstools-openshift by jbosstools.
the class ApplicationSourceListPage method doCreateControls.
@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
super.doCreateControls(parent, dbc);
IObservableValue selectedEclipseProject = createEclipseProjectControls(parent, dbc);
SashForm listAndDetailsContainer = new SashForm(parent, SWT.VERTICAL);
GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(listAndDetailsContainer);
GridLayoutFactory.fillDefaults().applyTo(listAndDetailsContainer);
TabFolder tabContainer = new TabFolder(listAndDetailsContainer, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(tabContainer);
tabContainer.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
// JBIDE-21072: force re-layout of the parent upon tab switching
parent.layout(true, true);
}
});
IObservableValue useLocalTemplateObservable = BeanProperties.value(IApplicationSourceListPageModel.PROPERTY_USE_LOCAL_APP_SOURCE).observe(model);
ValueBindingBuilder.bind(new TabFolderSelectionProperty().observe(tabContainer)).converting(new Converter(Integer.class, Boolean.class) {
@Override
public Object convert(Object fromObject) {
return Integer.valueOf(LOCAL_TEMPLATE_TAB_INDEX).equals(fromObject);
}
}).to(useLocalTemplateObservable).converting(new Converter(Boolean.class, Integer.class) {
@Override
public Object convert(Object fromObject) {
return (fromObject != null && (Boolean) fromObject) ? LOCAL_TEMPLATE_TAB_INDEX : 0;
}
}).in(dbc);
model.setUseLocalAppSource(false);
TabFolderTraverseListener tabFolderTraverseListener = new TabFolderTraverseListener(tabContainer);
IObservableValue serverTemplate = createServerTemplateControls(tabContainer, tabFolderTraverseListener, useLocalTemplateObservable, dbc);
IObservableValue localTemplateFilename = createLocalTemplateControls(tabContainer, tabFolderTraverseListener, useLocalTemplateObservable, dbc);
dbc.addValidationStatusProvider(new MultiValidator() {
@Override
protected IStatus validate() {
return (IStatus) BeanProperties.value(IApplicationSourceListPageModel.PROPERTY_APP_SOURCE_STATUS, IStatus.class).observe(model).getValue();
}
});
createDetailsGroup(listAndDetailsContainer, dbc);
// template list initially takes twice the height of the details pane
listAndDetailsContainer.setWeights(new int[] { 2, 1 });
// validate required template
IObservableValue selectedTemplate = BeanProperties.value(IApplicationSourceListPageModel.PROPERTY_SELECTED_APP_SOURCE).observe(model);
TemplateListPageValidator pageValidator = new TemplateListPageValidator(useLocalTemplateObservable, localTemplateFilename, serverTemplate, selectedTemplate, selectedEclipseProject, parent);
dbc.addValidationStatusProvider(pageValidator);
ControlDecorationSupport.create(pageValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
ProjectNameValidator projectNameValidator = new ProjectNameValidator(selectedEclipseProject, parent);
dbc.addValidationStatusProvider(projectNameValidator);
ControlDecorationSupport.create(projectNameValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
}
Aggregations