Search in sources :

Example 11 with Binding

use of org.eclipse.core.databinding.Binding in project portfolio by buchen.

the class AttributesPage method addAttributeBlock.

private void addAttributeBlock(Composite container, final AttributeDesignation attribute) {
    // label
    final Label label = new Label(container, SWT.NONE);
    label.setText(attribute.getType().getName());
    // input
    final Text value = new Text(container, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(value);
    // delete button
    final Button deleteButton = new Button(container, SWT.PUSH);
    deleteButton.setImage(Images.REMOVE.image());
    // model binding
    ToAttributeObjectConverter input2model = new ToAttributeObjectConverter(attribute);
    final Binding binding = // 
    bindings.getBindingContext().bindValue(// 
    WidgetProperties.text(SWT.Modify).observe(value), // $NON-NLS-1$
    BeanProperties.value("value").observe(attribute), new UpdateValueStrategy().setAfterGetValidator(input2model).setConverter(input2model), new UpdateValueStrategy().setConverter(new ToAttributeStringConverter(attribute)));
    // delete selection listener
    deleteButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            model.getAttributes().remove(attribute);
            bindings.getBindingContext().removeBinding(binding);
            Composite parent = deleteButton.getParent();
            label.dispose();
            value.dispose();
            deleteButton.dispose();
            parent.getParent().layout(true);
        }
    });
}
Also used : Binding(org.eclipse.core.databinding.Binding) UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text)

Example 12 with Binding

use of org.eclipse.core.databinding.Binding in project linuxtools by eclipse.

the class ContainerDataVolumeDialog method setupValidationSupport.

private void setupValidationSupport(final Label errorMessageIcon, final Label errorMessageLabel) {
    for (@SuppressWarnings("unchecked") Iterator<Binding> iterator = dbc.getBindings().iterator(); iterator.hasNext(); ) {
        final Binding binding = iterator.next();
        binding.getModel().addChangeListener(onDataVolumeSettingsChanged(errorMessageIcon, errorMessageLabel));
    }
}
Also used : Binding(org.eclipse.core.databinding.Binding)

Example 13 with Binding

use of org.eclipse.core.databinding.Binding in project linuxtools by eclipse.

the class DockerComposeUpDialog method setupValidationSupport.

private void setupValidationSupport(final Label errorMessageIcon, final Label errorMessageLabel) {
    for (@SuppressWarnings("unchecked") Iterator<Binding> iterator = dbc.getBindings().iterator(); iterator.hasNext(); ) {
        final Binding binding = iterator.next();
        binding.getModel().addChangeListener(onSettingsChanged(errorMessageIcon, errorMessageLabel));
    }
}
Also used : Binding(org.eclipse.core.databinding.Binding)

Example 14 with Binding

use of org.eclipse.core.databinding.Binding in project linuxtools by eclipse.

the class ImageBuildDialog method setupValidationSupport.

private void setupValidationSupport(final Label errorMessageIcon, final Label errorMessageLabel) {
    for (@SuppressWarnings("unchecked") Iterator<Binding> iterator = dbc.getBindings().iterator(); iterator.hasNext(); ) {
        final Binding binding = iterator.next();
        binding.getModel().addChangeListener(onBuildSettingsChanged(errorMessageIcon, errorMessageLabel));
    }
}
Also used : Binding(org.eclipse.core.databinding.Binding)

Example 15 with Binding

use of org.eclipse.core.databinding.Binding 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);
}
Also used : Binding(org.eclipse.core.databinding.Binding) Group(org.eclipse.swt.widgets.Group) IStatus(org.eclipse.core.runtime.IStatus) IExpansionListener(org.eclipse.ui.forms.events.IExpansionListener) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Label(org.eclipse.swt.widgets.Label) ObservableTreeItem2ModelConverter(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter) BuildConfigDetailViews(org.jboss.tools.openshift.internal.ui.server.BuildConfigDetailViews) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator) WritableValue(org.eclipse.core.databinding.observable.value.WritableValue) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) Model2ObservableTreeItemConverter(org.jboss.tools.openshift.internal.ui.wizard.importapp.BuildConfigTreeItems.Model2ObservableTreeItemConverter) IBuildConfig(com.openshift.restclient.model.IBuildConfig) Button(org.eclipse.swt.widgets.Button) Tree(org.eclipse.swt.widgets.Tree) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Aggregations

Binding (org.eclipse.core.databinding.Binding)21 Label (org.eclipse.swt.widgets.Label)14 RequiredControlDecorationUpdater (org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater)14 Button (org.eclipse.swt.widgets.Button)11 Text (org.eclipse.swt.widgets.Text)10 Composite (org.eclipse.swt.widgets.Composite)8 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)7 IStatus (org.eclipse.core.runtime.IStatus)6 IValidator (org.eclipse.core.databinding.validation.IValidator)4 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)4 ComboViewer (org.eclipse.jface.viewers.ComboViewer)4 ObservableTreeItem2ModelConverter (org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter)4 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)3 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)3 Group (org.eclipse.swt.widgets.Group)3 IProject (com.openshift.restclient.model.IProject)2 ValidationStatusProvider (org.eclipse.core.databinding.ValidationStatusProvider)2 TextContentAdapter (org.eclipse.jface.fieldassist.TextContentAdapter)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2