Search in sources :

Example 1 with RequiredControlDecorationUpdater

use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.

the class OAuthDetailView method bindWidgetsToInternalModel.

private void bindWidgetsToInternalModel(DataBindingContext dbc) {
    IValidator validator = new RequiredStringValidator("token");
    this.tokenBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(tokenText)).converting(new TrimmingStringConverter()).validatingAfterConvert(validator).to(tokenObservable).validatingBeforeSet(validator).in(dbc);
    ControlDecorationSupport.create(tokenBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    org.jboss.tools.common.ui.databinding.DataBindingUtils.addDisposableValueChangeListener(changeListener, tokenObservable, tokenText);
}
Also used : RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) TrimmingStringConverter(org.jboss.tools.openshift.internal.common.ui.databinding.TrimmingStringConverter) IValidator(org.eclipse.core.databinding.validation.IValidator) RequiredStringValidator(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredStringValidator)

Example 2 with RequiredControlDecorationUpdater

use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.

the class ResourceNameControl method doCreateControl.

@SuppressWarnings({ "rawtypes", "unchecked" })
public void doCreateControl(Composite parent, DataBindingContext dbc, Object model) {
    // Resource Name
    final Label resourceNameLabel = new Label(parent, SWT.NONE);
    resourceNameLabel.setText(label);
    resourceNameLabel.setToolTipText("The name used to identify the resources that will support the deployed image.");
    layoutLabel(resourceNameLabel);
    final Text resourceNameText = new Text(parent, SWT.BORDER);
    layoutText(resourceNameText);
    final IObservableValue resourceNameTextObservable = WidgetProperties.text(SWT.Modify).observe(resourceNameText);
    ResourceNameValidator validator = new ResourceNameValidator(resourceNameTextObservable);
    final Binding nameBinding = ValueBindingBuilder.bind(resourceNameTextObservable).validatingAfterConvert(validator).to(BeanProperties.value(PROPERTY_RESOURCE_NAME).observe(model)).in(dbc);
    dbc.addValidationStatusProvider(validator);
    ControlDecorationSupport.create(nameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
}
Also used : Binding(org.eclipse.core.databinding.Binding) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) ResourceNameValidator(org.jboss.tools.openshift.internal.ui.validator.ResourceNameValidator)

Example 3 with RequiredControlDecorationUpdater

use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.

the class ConnectionEditor method bindWidgetsToInternalModel.

private void bindWidgetsToInternalModel(DataBindingContext dbc) {
    // auth protocol
    this.selectedAuthTypeBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(authTypeViewer)).validatingAfterGet(new IsNotNullValidator(ValidationStatus.cancel("Please select an authorization protocol."))).to(selectedDetailViewObservable).in(dbc);
    ControlDecorationSupport.create(selectedAuthTypeBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
}
Also used : RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) IsNotNullValidator(org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNullValidator)

Example 4 with RequiredControlDecorationUpdater

use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.

the class BasicAuthenticationDetailView method bindWidgetsToInternalModel.

private void bindWidgetsToInternalModel(DataBindingContext dbc) {
    // username
    this.usernameBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(usernameText)).converting(new TrimmingStringConverter()).validatingAfterConvert(new RequiredStringValidator("v3 username")).to(usernameObservable).in(dbc);
    ControlDecorationSupport.create(usernameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    org.jboss.tools.common.ui.databinding.DataBindingUtils.addDisposableValueChangeListener(changeListener, usernameObservable, usernameText);
    // password
    this.passwordBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(passwordText)).converting(new TrimmingStringConverter()).validatingAfterConvert(new RequiredStringValidator("v3 password")).to(passwordObservable).in(dbc);
    ControlDecorationSupport.create(passwordBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    org.jboss.tools.common.ui.databinding.DataBindingUtils.addDisposableValueChangeListener(changeListener, passwordObservable, passwordText);
    connectionAuthProvider = new ConnectionAuthenticationProvider();
}
Also used : RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) TrimmingStringConverter(org.jboss.tools.openshift.internal.common.ui.databinding.TrimmingStringConverter) IConnectionAuthenticationProvider(org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPageModel.IConnectionAuthenticationProvider) RequiredStringValidator(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredStringValidator)

Example 5 with RequiredControlDecorationUpdater

use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.

the class DeployImagePage method createImageNameControls.

private void createImageNameControls(final Composite parent, final DataBindingContext dbc) {
    // Image
    final Label imageNameLabel = new Label(parent, SWT.NONE);
    imageNameLabel.setText("Image Name: ");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(imageNameLabel);
    final Text imageNameText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(imageNameText);
    final IObservableValue<String> imageNameTextObservable = WidgetProperties.text(SWT.Modify).observeDelayed(500, imageNameText);
    final IObservableValue<String> imageNameObservable = BeanProperties.value(IDeployImagePageModel.PROPERTY_IMAGE_NAME).observe(model);
    Binding imageBinding = ValueBindingBuilder.bind(imageNameTextObservable).converting(new TrimmingStringConverter()).validatingAfterConvert(new DockerImageValidator()).to(imageNameObservable).in(dbc);
    ControlDecorationSupport.create(imageBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    imageNameProposalAdapter = new ContentProposalAdapter(imageNameText, // move the cursor to the end of the selected value
    new TextContentAdapter() {

        @Override
        public void insertControlContents(Control control, String text, int cursorPosition) {
            final Text imageNameText = (Text) control;
            final Point selection = imageNameText.getSelection();
            imageNameText.setText(text);
            selection.x = text.length();
            selection.y = selection.x;
            imageNameText.setSelection(selection);
        }
    }, getImageNameContentProposalProvider(imageNameText), null, null);
    // List local Docker images
    Button btnDockerBrowse = new Button(parent, SWT.NONE);
    btnDockerBrowse.setText("Browse...");
    btnDockerBrowse.setToolTipText("Look-up an image by browsing the Docker daemon");
    btnDockerBrowse.addSelectionListener(onBrowseImage());
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(btnDockerBrowse);
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(btnDockerBrowse)).notUpdatingParticipant().to(BeanProperties.value(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTION).observe(model)).converting(new IsNotNull2BooleanConverter()).in(dbc);
    // search on Docker registry (Docker Hub)
    Button btnDockerSearch = new Button(parent, SWT.NONE);
    btnDockerSearch.setText("Search...");
    btnDockerSearch.setToolTipText("Search an image on the Docker registry");
    btnDockerSearch.addSelectionListener(onSearchImage(imageNameText));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(btnDockerSearch);
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(btnDockerSearch)).notUpdatingParticipant().to(BeanProperties.value(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTION).observe(model)).converting(new IsNotNull2BooleanConverter()).in(dbc);
}
Also used : Binding(org.eclipse.core.databinding.Binding) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) TextContentAdapter(org.eclipse.jface.fieldassist.TextContentAdapter) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) TrimmingStringConverter(org.jboss.tools.openshift.internal.common.ui.databinding.TrimmingStringConverter) ResourceNameControl(org.jboss.tools.openshift.internal.ui.wizard.common.ResourceNameControl) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) IsNotNull2BooleanConverter(org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNull2BooleanConverter) DockerImageValidator(org.jboss.tools.openshift.internal.ui.validator.DockerImageValidator)

Aggregations

RequiredControlDecorationUpdater (org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater)23 Label (org.eclipse.swt.widgets.Label)18 Button (org.eclipse.swt.widgets.Button)15 Binding (org.eclipse.core.databinding.Binding)14 Text (org.eclipse.swt.widgets.Text)13 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)9 IStatus (org.eclipse.core.runtime.IStatus)8 Composite (org.eclipse.swt.widgets.Composite)8 IValidator (org.eclipse.core.databinding.validation.IValidator)5 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)5 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)5 ComboViewer (org.eclipse.jface.viewers.ComboViewer)5 InvertingBooleanConverter (org.jboss.tools.common.ui.databinding.InvertingBooleanConverter)5 ObservableTreeItem2ModelConverter (org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter)5 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)4 Group (org.eclipse.swt.widgets.Group)4 ValidationStatusProvider (org.eclipse.core.databinding.ValidationStatusProvider)3 TrimmingStringConverter (org.jboss.tools.openshift.internal.common.ui.databinding.TrimmingStringConverter)3 IProject (com.openshift.restclient.model.IProject)2 Converter (org.eclipse.core.databinding.conversion.Converter)2