use of org.jboss.tools.openshift.internal.common.ui.utils.TableViewerCellDecorationManager in project jbosstools-openshift by jbosstools.
the class TemplateParametersPage method createTable.
public TableViewer createTable(final Composite tableContainer, IObservableList<IParameter> parametersObservable, DataBindingContext dbc) {
final Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
table.setLinesVisible(true);
table.setHeaderVisible(true);
Image decorationImage = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage();
final ObservableMap<String, IStatus> cellsValidationStatusObservable = new WritableMap<>(String.class, IStatus.class);
final TableViewerCellDecorationManager decorations = new TableViewerCellDecorationManager(decorationImage, table);
DataBindingUtils.addDisposableListChangeListener(onParametersChanged(decorations, cellsValidationStatusObservable), parametersObservable, table);
TableViewer tableViewer = buildTableViewer(table, tableContainer, cellsValidationStatusObservable, decorations);
// cells validity
dbc.addValidationStatusProvider(new MultiValidator() {
@Override
protected IStatus validate() {
for (Iterator<IStatus> iterator = (Iterator<IStatus>) cellsValidationStatusObservable.values().iterator(); iterator.hasNext(); ) {
IStatus cellValidationStatus = iterator.next();
if (cellValidationStatus != null && !cellValidationStatus.isOK()) {
return cellValidationStatus;
}
}
return ValidationStatus.ok();
}
});
return tableViewer;
}
Aggregations