use of org.eclipse.core.databinding.observable.list.IObservableList in project jbosstools-openshift by jbosstools.
the class FormPresenterSupport method init.
/**
* @noreference This method is not intended to be referenced by clients.
*/
protected void init() {
ObservableTracker.setIgnore(true);
try {
aggregateStatusProvider = new MaxSeverityValidationStatusProvider(dbc);
} finally {
ObservableTracker.setIgnore(false);
}
aggregateStatusProvider.addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
statusProviderChanged();
}
});
formPresenter.getControl().addListener(SWT.Dispose, new Listener() {
@Override
public void handleEvent(Event event) {
dispose();
}
});
aggregateStatusProvider.addStaleListener(new IStaleListener() {
@Override
public void handleStale(StaleEvent staleEvent) {
currentStatusStale = true;
handleStatusChanged();
}
});
statusProviderChanged();
dbc.getValidationStatusProviders().addListChangeListener(validationStatusProvidersListener);
for (Iterator it = dbc.getValidationStatusProviders().iterator(); it.hasNext(); ) {
ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider) it.next();
IObservableList targets = validationStatusProvider.getTargets();
targets.addListChangeListener(validationStatusProviderTargetsListener);
for (Iterator iter = targets.iterator(); iter.hasNext(); ) {
((IObservable) iter.next()).addChangeListener(uiChangeListener);
}
}
}
use of org.eclipse.core.databinding.observable.list.IObservableList in project jbosstools-openshift by jbosstools.
the class FormPresenterSupport method handleUIChanged.
/**
* @noreference This method is not intended to be referenced by clients.
*/
protected void handleUIChanged() {
uiChanged = true;
if (currentStatus != null) {
handleStatusChanged();
}
dbc.getValidationStatusProviders().removeListChangeListener(validationStatusProvidersListener);
for (Iterator it = dbc.getValidationStatusProviders().iterator(); it.hasNext(); ) {
ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider) it.next();
IObservableList targets = validationStatusProvider.getTargets();
targets.removeListChangeListener(validationStatusProviderTargetsListener);
for (Iterator iter = targets.iterator(); iter.hasNext(); ) {
((IObservable) iter.next()).removeChangeListener(uiChangeListener);
}
}
}
use of org.eclipse.core.databinding.observable.list.IObservableList in project jbosstools-openshift by jbosstools.
the class FormPresenterSupport method dispose.
/**
* Disposes of this wizard page support object, removing any listeners it
* may have attached.
*/
public void dispose() {
if (aggregateStatusProvider != null)
aggregateStatusProvider.dispose();
if (dbc != null && !uiChanged) {
for (Iterator it = dbc.getValidationStatusProviders().iterator(); it.hasNext(); ) {
ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider) it.next();
IObservableList targets = validationStatusProvider.getTargets();
if (targets != null) {
targets.removeListChangeListener(validationStatusProviderTargetsListener);
for (Iterator iter = targets.iterator(); iter.hasNext(); ) {
((IObservable) iter.next()).removeChangeListener(uiChangeListener);
}
}
}
dbc.getValidationStatusProviders().removeListChangeListener(validationStatusProvidersListener);
}
aggregateStatusProvider = null;
dbc = null;
uiChangeListener = null;
validationStatusProvidersListener = null;
validationStatusProviderTargetsListener = null;
formPresenter = null;
}
use of org.eclipse.core.databinding.observable.list.IObservableList in project eclipse-pmd by acanda.
the class AddRuleSetConfigurationWizardPage method initDataBindings.
private DataBindingContext initDataBindings() {
final DataBindingContext bindingContext = new DataBindingContext();
//
final IObservableValue locationObserveText = SWTObservables.observeDelayedValue(200, SWTObservables.observeText(location, SWT.Modify));
final IObservableValue locationObserveValue = BeansObservables.observeValue(controller.getModel(), "location");
bindingContext.bindValue(locationObserveText, locationObserveValue, null, null);
//
final ObservableListContentProvider rulesContentProvider = new ObservableListContentProvider();
final IObservableMap rulesObserveMap = PojoObservables.observeMap(rulesContentProvider.getKnownElements(), Rule.class, "name");
tableViewer.setLabelProvider(new ObservableMapLabelProvider(rulesObserveMap));
tableViewer.setContentProvider(rulesContentProvider);
//
final IObservableList rulesObserveList = BeansObservables.observeList(Realm.getDefault(), controller.getModel(), "rules");
tableViewer.setInput(rulesObserveList);
//
final IObservableValue nameObserveTextObserveWidget = SWTObservables.observeDelayedValue(100, SWTObservables.observeText(name, SWT.Modify));
final IObservableValue controllergetModelNameObserveValue = BeansObservables.observeValue(controller.getModel(), "name");
bindingContext.bindValue(nameObserveTextObserveWidget, controllergetModelNameObserveValue, null, null);
//
final IObservableValue observeVisibleBrowseObserveWidget = WidgetProperties.visible().observe(browse);
final IObservableValue browseEnabledControllergetModelObserveValue = BeanProperties.value("browseEnabled").observe(controller.getModel());
bindingContext.bindValue(observeVisibleBrowseObserveWidget, browseEnabledControllergetModelObserveValue, null, null);
//
return bindingContext;
}
use of org.eclipse.core.databinding.observable.list.IObservableList in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPage method createResourceTree.
@SuppressWarnings("unchecked")
private IViewerObservableValue createResourceTree(ServerSettingsWizardPageModel model, SashForm resourceControlsContainer, DataBindingContext dbc) {
Composite resourceTreeContainer = new Composite(resourceControlsContainer, SWT.None);
GridLayoutFactory.fillDefaults().applyTo(resourceTreeContainer);
// filter
Text selectorText = UIUtils.createSearchText(resourceTreeContainer);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(selectorText);
// resource tree
final TreeViewer resourcesViewer = createResourcesTreeViewer(resourceTreeContainer, model, selectorText);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(RESOURCE_TREE_WIDTH, RESOURCE_TREE_HEIGHT).applyTo(resourcesViewer.getControl());
resourcesViewer.addDoubleClickListener(onDoubleClickService());
IObservableList<ObservableTreeItem> resourceItemsObservable = BeanProperties.list(ServerSettingsWizardPageModel.PROPERTY_RESOURCE_ITEMS).observe(model);
DataBindingUtils.addDisposableListChangeListener(onResourceItemsChanged(resourcesViewer), resourceItemsObservable, resourcesViewer.getTree());
selectorText.addModifyListener(onFilterTextModified(resourcesViewer));
IViewerObservableValue selectedResourceTreeItem = ViewerProperties.singleSelection().observe(resourcesViewer);
ValueBindingBuilder.bind(selectedResourceTreeItem).converting(new ObservableTreeItem2ModelConverter(IResource.class)).validatingAfterConvert(value -> {
if ((value instanceof IResource) && OpenShiftServerUtils.isAllowedForServerAdapter((IResource) value)) {
return ValidationStatus.ok();
}
return ValidationStatus.cancel("Please select a resource that this adapter will be bound to.");
}).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_RESOURCE).observe(model)).converting(new Model2ObservableTreeItemConverter(new ServerSettingsWizardPageModel.ResourceTreeItemsFactory())).in(dbc);
return selectedResourceTreeItem;
}
Aggregations