Search in sources :

Example 1 with DockerImageValidator

use of org.jboss.tools.openshift.internal.ui.validator.DockerImageValidator 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

Binding (org.eclipse.core.databinding.Binding)1 ContentProposalAdapter (org.eclipse.jface.fieldassist.ContentProposalAdapter)1 TextContentAdapter (org.eclipse.jface.fieldassist.TextContentAdapter)1 Point (org.eclipse.swt.graphics.Point)1 Button (org.eclipse.swt.widgets.Button)1 Control (org.eclipse.swt.widgets.Control)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1 IsNotNull2BooleanConverter (org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNull2BooleanConverter)1 RequiredControlDecorationUpdater (org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater)1 TrimmingStringConverter (org.jboss.tools.openshift.internal.common.ui.databinding.TrimmingStringConverter)1 DockerImageValidator (org.jboss.tools.openshift.internal.ui.validator.DockerImageValidator)1 ResourceNameControl (org.jboss.tools.openshift.internal.ui.wizard.common.ResourceNameControl)1