Search in sources :

Example 1 with ObjectToStringConverter

use of org.eclipse.core.internal.databinding.conversion.ObjectToStringConverter in project jbosstools-openshift by jbosstools.

the class DeployImagePage method createDockerConnectionInfoControl.

private void createDockerConnectionInfoControl(Composite parent, DataBindingContext dbc) {
    Label lblConnection = createDockerConnectionLabel(parent);
    final Text connectionText = new Text(parent, SWT.READ_ONLY | SWT.NO_FOCUS);
    connectionText.setBackground(lblConnection.getBackground());
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(NUM_COLUMS - 1, 1).grab(true, false).applyTo(connectionText);
    final IObservableValue<String> connnectionTextObservable = WidgetProperties.text(SWT.None).observe(connectionText);
    final IObservableValue<IDockerConnection> connnectionObservable = BeanProperties.value(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTION).observe(model);
    ValueBindingBuilder.bind(connnectionTextObservable).notUpdatingParticipant().to(connnectionObservable).converting(new ObjectToStringConverter(IDockerConnection.class) {

        ConnectionColumLabelProvider labelProvider = new ConnectionColumLabelProvider();

        @Override
        public Object convert(Object source) {
            return (source instanceof IDockerConnection) ? dockerConnectionToString((IDockerConnection) source) : "";
        }
    }).in(dbc);
}
Also used : ConnectionColumLabelProvider(org.jboss.tools.openshift.internal.common.ui.connection.ConnectionColumLabelProvider) Label(org.eclipse.swt.widgets.Label) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) ObjectToStringConverter(org.eclipse.core.internal.databinding.conversion.ObjectToStringConverter) Text(org.eclipse.swt.widgets.Text)

Example 2 with ObjectToStringConverter

use of org.eclipse.core.internal.databinding.conversion.ObjectToStringConverter in project jbosstools-openshift by jbosstools.

the class DeployImagePage method createOpenShiftConnectionControl.

private void createOpenShiftConnectionControl(Composite parent, DataBindingContext dbc) {
    Label lblConnection = new Label(parent, SWT.NONE);
    lblConnection.setText("OpenShift Connection: ");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(lblConnection);
    final Text connectionText = new Text(parent, SWT.READ_ONLY | SWT.NO_FOCUS);
    connectionText.setBackground(lblConnection.getBackground());
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(NUM_COLUMS - 1, 1).grab(true, false).applyTo(connectionText);
    final IObservableValue<String> connnectionTextObservable = WidgetProperties.text(SWT.None).observe(connectionText);
    final IObservableValue<IConnection> connnectionObservable = BeanProperties.value(IDeployImagePageModel.PROPERTY_CONNECTION).observe(model);
    ValueBindingBuilder.bind(connnectionTextObservable).notUpdatingParticipant().to(connnectionObservable).converting(new ObjectToStringConverter(Connection.class) {

        ConnectionColumLabelProvider labelProvider = new ConnectionColumLabelProvider();

        @Override
        public Object convert(Object source) {
            return source == null ? "" : labelProvider.getText(source);
        }
    }).in(dbc);
}
Also used : ConnectionColumLabelProvider(org.jboss.tools.openshift.internal.common.ui.connection.ConnectionColumLabelProvider) Label(org.eclipse.swt.widgets.Label) ObjectToStringConverter(org.eclipse.core.internal.databinding.conversion.ObjectToStringConverter) Text(org.eclipse.swt.widgets.Text) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection)

Aggregations

ObjectToStringConverter (org.eclipse.core.internal.databinding.conversion.ObjectToStringConverter)2 Label (org.eclipse.swt.widgets.Label)2 Text (org.eclipse.swt.widgets.Text)2 ConnectionColumLabelProvider (org.jboss.tools.openshift.internal.common.ui.connection.ConnectionColumLabelProvider)2 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)1 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)1