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);
}
Aggregations