Search in sources :

Example 6 with IObservableList

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);
        }
    }
}
Also used : IValueChangeListener(org.eclipse.core.databinding.observable.value.IValueChangeListener) StaleEvent(org.eclipse.core.databinding.observable.StaleEvent) ValueChangeEvent(org.eclipse.core.databinding.observable.value.ValueChangeEvent) IValueChangeListener(org.eclipse.core.databinding.observable.value.IValueChangeListener) IChangeListener(org.eclipse.core.databinding.observable.IChangeListener) Listener(org.eclipse.swt.widgets.Listener) IStaleListener(org.eclipse.core.databinding.observable.IStaleListener) IListChangeListener(org.eclipse.core.databinding.observable.list.IListChangeListener) IStaleListener(org.eclipse.core.databinding.observable.IStaleListener) Iterator(java.util.Iterator) IObservable(org.eclipse.core.databinding.observable.IObservable) StaleEvent(org.eclipse.core.databinding.observable.StaleEvent) ValueChangeEvent(org.eclipse.core.databinding.observable.value.ValueChangeEvent) Event(org.eclipse.swt.widgets.Event) ListChangeEvent(org.eclipse.core.databinding.observable.list.ListChangeEvent) ChangeEvent(org.eclipse.core.databinding.observable.ChangeEvent) ValidationStatusProvider(org.eclipse.core.databinding.ValidationStatusProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Example 7 with IObservableList

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);
        }
    }
}
Also used : Iterator(java.util.Iterator) IObservable(org.eclipse.core.databinding.observable.IObservable) ValidationStatusProvider(org.eclipse.core.databinding.ValidationStatusProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Example 8 with IObservableList

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;
}
Also used : Iterator(java.util.Iterator) IObservable(org.eclipse.core.databinding.observable.IObservable) ValidationStatusProvider(org.eclipse.core.databinding.ValidationStatusProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Example 9 with IObservableList

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;
}
Also used : IObservableMap(org.eclipse.core.databinding.observable.map.IObservableMap) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) ObservableMapLabelProvider(org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Example 10 with IObservableList

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;
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) SelectProjectComponentBuilder(org.jboss.tools.openshift.internal.common.ui.SelectProjectComponentBuilder) CoreException(org.eclipse.core.runtime.CoreException) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList) BooleanUtils(org.apache.commons.lang.BooleanUtils) ValidationStatus(org.eclipse.core.databinding.validation.ValidationStatus) OpenShiftIdentifierValidator(org.jboss.tools.openshift.internal.ui.validator.OpenShiftIdentifierValidator) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) DialogAdvancedPart(org.jboss.tools.openshift.internal.common.ui.utils.DialogAdvancedPart) BrowserUtility(org.jboss.tools.foundation.ui.util.BrowserUtility) Status(org.eclipse.core.runtime.Status) ValidationStatusProvider(org.eclipse.core.databinding.ValidationStatusProvider) Status2IconConverter(org.jboss.tools.openshift.internal.common.ui.databinding.Status2IconConverter) ProjectViewerComparator(org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator) DOWNLOAD_URL(org.jboss.tools.openshift.core.preferences.IOpenShiftCoreConstants.DOWNLOAD_URL) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) InvocationTargetException(java.lang.reflect.InvocationTargetException) ICompletable(org.jboss.ide.eclipse.as.ui.editor.DeploymentTypeUIUtil.ICompletable) Path(org.eclipse.core.runtime.Path) SWT(org.eclipse.swt.SWT) SelectExistingProjectDialog(org.jboss.tools.openshift.internal.common.ui.SelectExistingProjectDialog) SelectionListener(org.eclipse.swt.events.SelectionListener) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ImportApplicationWizard(org.jboss.tools.openshift.internal.ui.wizard.importapp.ImportApplicationWizard) IListProperty(org.eclipse.core.databinding.property.list.IListProperty) Converter(org.eclipse.core.databinding.conversion.Converter) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) NumericValidator(org.jboss.tools.openshift.internal.common.ui.databinding.NumericValidator) IBuildConfig(com.openshift.restclient.model.IBuildConfig) IWizard(org.eclipse.jface.wizard.IWizard) ProjectUtils(org.jboss.tools.openshift.common.core.utils.ProjectUtils) IValidator(org.eclipse.core.databinding.validation.IValidator) JFaceResources(org.eclipse.jface.resource.JFaceResources) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) IContainer(org.eclipse.core.resources.IContainer) WidgetProperties(org.eclipse.jface.databinding.swt.WidgetProperties) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) OpenShiftCommonUIMessages(org.jboss.tools.openshift.internal.common.ui.OpenShiftCommonUIMessages) IProject(org.eclipse.core.resources.IProject) GridData(org.eclipse.swt.layout.GridData) VariablesHelper(org.jboss.tools.openshift.common.core.utils.VariablesHelper) Link(org.eclipse.swt.widgets.Link) RsyncStatus(org.jboss.tools.openshift.internal.core.util.RSyncValidator.RsyncStatus) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Shell(org.eclipse.swt.widgets.Shell) IResource(com.openshift.restclient.model.IResource) MultiListProperty(org.eclipse.core.databinding.property.list.MultiListProperty) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) IServer(org.eclipse.wst.server.core.IServer) OpenShiftServerUtils(org.jboss.tools.openshift.core.server.OpenShiftServerUtils) File(java.io.File) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator) Dialog(org.eclipse.jface.dialogs.Dialog) ModifyListener(org.eclipse.swt.events.ModifyListener) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) FormPresenterSupport(org.jboss.tools.openshift.internal.common.ui.databinding.FormPresenterSupport) StringUtils(org.jboss.tools.openshift.common.core.utils.StringUtils) RouteLabelProvider(org.jboss.tools.openshift.internal.ui.dialog.SelectRouteDialog.RouteLabelProvider) ControlDecorationSupport(org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) ValueBindingBuilder(org.jboss.tools.common.ui.databinding.ValueBindingBuilder) AbstractOpenShiftWizardPage(org.jboss.tools.openshift.internal.common.ui.wizard.AbstractOpenShiftWizardPage) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) Model2ObservableTreeItemConverter(org.jboss.tools.openshift.internal.ui.treeitem.Model2ObservableTreeItemConverter) Button(org.eclipse.swt.widgets.Button) Collection(java.util.Collection) IViewerObservableValue(org.eclipse.jface.databinding.viewers.IViewerObservableValue) PreferencesUtil(org.eclipse.ui.dialogs.PreferencesUtil) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Binding(org.eclipse.core.databinding.Binding) BeanProperties(org.eclipse.core.databinding.beans.BeanProperties) IRoute(com.openshift.restclient.model.route.IRoute) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) Label(org.eclipse.swt.widgets.Label) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) RSyncValidator(org.jboss.tools.openshift.internal.core.util.RSyncValidator) Image(org.eclipse.swt.graphics.Image) HashMap(java.util.HashMap) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue) ObservableTreeItem2ModelConverter(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) ComboViewer(org.eclipse.jface.viewers.ComboViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) DataBindingUtils(org.jboss.tools.openshift.internal.common.ui.utils.DataBindingUtils) OPEN_SHIFT_PREFERENCE_PAGE_ID(org.jboss.tools.openshift.core.preferences.IOpenShiftCoreConstants.OPEN_SHIFT_PREFERENCE_PAGE_ID) UIUtils(org.jboss.tools.openshift.internal.common.ui.utils.UIUtils) ObservableListTreeContentProvider(org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider) InvertingBooleanConverter(org.jboss.tools.common.ui.databinding.InvertingBooleanConverter) FillLayout(org.eclipse.swt.layout.FillLayout) OpenShiftUIActivator(org.jboss.tools.openshift.internal.ui.OpenShiftUIActivator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Viewer(org.eclipse.jface.viewers.Viewer) Job(org.eclipse.core.runtime.jobs.Job) IFormPresenter(org.jboss.tools.openshift.internal.common.ui.databinding.FormPresenterSupport.IFormPresenter) ViewerProperties(org.eclipse.jface.databinding.viewers.ViewerProperties) Group(org.eclipse.swt.widgets.Group) OpenShiftCoreMessages(org.jboss.tools.openshift.core.OpenShiftCoreMessages) Connection(org.jboss.tools.openshift.core.connection.Connection) WritableValue(org.eclipse.core.databinding.observable.value.WritableValue) WizardUtils(org.jboss.tools.common.ui.WizardUtils) DisableableMultiValitdator(org.jboss.tools.openshift.internal.common.ui.databinding.DisableableMultiValitdator) OpenShiftCoreException(org.jboss.tools.openshift.common.core.OpenShiftCoreException) OpenShiftUIMessages(org.jboss.tools.openshift.internal.ui.OpenShiftUIMessages) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IListChangeListener(org.eclipse.core.databinding.observable.list.IListChangeListener) Collections(java.util.Collections) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) Model2ObservableTreeItemConverter(org.jboss.tools.openshift.internal.ui.treeitem.Model2ObservableTreeItemConverter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ObservableTreeItem2ModelConverter(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter) Text(org.eclipse.swt.widgets.Text) ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) IViewerObservableValue(org.eclipse.jface.databinding.viewers.IViewerObservableValue) IResource(com.openshift.restclient.model.IResource)

Aggregations

IObservableList (org.eclipse.core.databinding.observable.list.IObservableList)10 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)7 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)7 DataBindingContext (org.eclipse.core.databinding.DataBindingContext)6 ValidationStatusProvider (org.eclipse.core.databinding.ValidationStatusProvider)4 IObservableMap (org.eclipse.core.databinding.observable.map.IObservableMap)4 Iterator (java.util.Iterator)3 IObservable (org.eclipse.core.databinding.observable.IObservable)3 ObservableMapLabelProvider (org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider)3 UpdateValueStrategy (org.eclipse.core.databinding.UpdateValueStrategy)2 IListChangeListener (org.eclipse.core.databinding.observable.list.IListChangeListener)2 ISWTObservableValue (org.eclipse.jface.databinding.swt.ISWTObservableValue)2 IBuildConfig (com.openshift.restclient.model.IBuildConfig)1 IResource (com.openshift.restclient.model.IResource)1 IRoute (com.openshift.restclient.model.route.IRoute)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1