Search in sources :

Example 26 with IConnection

use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.

the class AdvancedConnectionEditor method discoverRegistryPressed.

private void discoverRegistryPressed(Shell shell) {
    IConnection tmp = pageModel.createConnection();
    IStatus ret = RegistryProviderModel.getDefault().getRegistryURL(tmp);
    String oldVal = (String) registryURLObservable.getValue();
    String newVal = ret.getMessage();
    if (ret != null && ret.isOK()) {
        // If they're equal, do nothing
        if (!eq(oldVal, newVal)) {
            // Verify with user
            String title = "Overwrite registry URL?";
            String msg = "Are you sure you want to change the registry URL from " + oldVal + " to " + newVal + "?";
            MessageDialog dialog = new MessageDialog(shell, title, null, msg, MessageDialog.CONFIRM, new String[] { "OK", "Cancel" }, 0);
            String old = registryURLObservable.getValue().toString().trim();
            if (old.isEmpty() || dialog.open() == IDialogConstants.OK_ID) {
                registryURLObservable.setValue(ret.getMessage());
            }
        }
    } else {
        String title = "Registry URL not found";
        String msg = "No registry provider found for the given connection. If your Openshift connection is backed by a CDK or minishift installation, please ensure the CDK is running.";
        ErrorDialog ed = new ErrorDialog(shell, title, msg, ret, IStatus.ERROR | IStatus.WARNING | IStatus.INFO | IStatus.CANCEL);
        ed.open();
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 27 with IConnection

use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.

the class OAuthDetailView method setSelectedConnection.

@Override
public void setSelectedConnection(IConnection selectedConnection) {
    if (selectedConnection instanceof Connection) {
        Connection connection = (Connection) selectedConnection;
        tokenObservable.setValue(connection.getToken());
        rememberTokenObservable.setValue(connection.isRememberToken());
    } else if (selectedConnection instanceof NewConnectionMarker) {
        tokenObservable.setValue(null);
        rememberTokenObservable.setValue(Boolean.FALSE);
    }
}
Also used : NewConnectionMarker(org.jboss.tools.openshift.common.core.connection.NewConnectionMarker) Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection)

Example 28 with IConnection

use of org.jboss.tools.openshift.common.core.connection.IConnection 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)

Example 29 with IConnection

use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.

the class ServerResourceViewModelWithReplicationControllerTest method shouldReturnConnection.

@Test
public void shouldReturnConnection() {
    // given
    // when
    IConnection connection = model.getConnection();
    // then
    assertThat(connection).isEqualTo(this.connection);
}
Also used : IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) Test(org.junit.Test)

Example 30 with IConnection

use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.

the class ServerResourceViewModelWithServiceTest method shouldReturnConnection.

@Test
public void shouldReturnConnection() {
    // given
    // when
    IConnection connection = model.getConnection();
    // then
    assertThat(connection).isEqualTo(this.connection);
}
Also used : IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) Test(org.junit.Test)

Aggregations

IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)40 Test (org.junit.Test)13 Connection (org.jboss.tools.openshift.core.connection.Connection)9 IStatus (org.eclipse.core.runtime.IStatus)5 IServer (org.eclipse.wst.server.core.IServer)5 CDKOpenshiftUtility (org.jboss.tools.openshift.cdk.server.core.internal.listeners.CDKOpenshiftUtility)5 ServiceManagerEnvironment (org.jboss.tools.openshift.cdk.server.core.internal.listeners.ServiceManagerEnvironment)5 ArrayList (java.util.ArrayList)3 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)3 Label (org.eclipse.swt.widgets.Label)3 IRoute (com.openshift.restclient.model.route.IRoute)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)2 ISelection (org.eclipse.jface.viewers.ISelection)2 ConnectionsRegistry (org.jboss.tools.openshift.common.core.connection.ConnectionsRegistry)2 NewConnectionMarker (org.jboss.tools.openshift.common.core.connection.NewConnectionMarker)2 IClient (com.openshift.restclient.IClient)1 ResourceKind (com.openshift.restclient.ResourceKind)1 IAuthorizationContext (com.openshift.restclient.authorization.IAuthorizationContext)1