Search in sources :

Example 11 with IConnection

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

the class SelectRouteDialog method createMessage.

private String createMessage(List<IRoute> routes) {
    StringBuilder message = new StringBuilder();
    if (!routes.isEmpty()) {
        IRoute route = routes.get(0);
        IConnection connection = ConnectionsRegistryUtil.safeGetConnectionFor(route);
        if (connection != null) {
            message.append("Server: ").append(connection.getUsername()).append(" ").append(connection.getHost()).append(StringUtils.getLineSeparator());
        }
        message.append("Project: ").append(route.getNamespaceName()).append(StringUtils.getLineSeparator());
        // Add more space between server/project info and instruction.
        message.append(StringUtils.getLineSeparator());
    }
    message.append("Select the route to open in a browser.");
    return message.toString();
}
Also used : IRoute(com.openshift.restclient.model.route.IRoute) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection)

Example 12 with IConnection

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

the class ChooseOpenshiftConnectionFragment method selectedConnectionChanged.

private void selectedConnectionChanged(IConnection newVal) {
    IConnection oldCon = selectedConnection;
    selectedConnection = newVal;
    setComplete(selectedConnection != null);
    handle.update();
    if (externalConnectionListener != null) {
        // re-fire event to external listener
        PropertyChangeEvent event = new PropertyChangeEvent(this, ConnectionWizardPageModel.PROPERTY_SELECTED_CONNECTION, oldCon, selectedConnection);
        externalConnectionListener.propertyChange(event);
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection)

Example 13 with IConnection

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

the class ConnectionRegistryTest method shouldSetRecentConnectionToLatestAddition.

@Test
public void shouldSetRecentConnectionToLatestAddition() {
    // pre-conditions
    IConnection recentConnection = registry.getRecentConnection();
    // operations
    registry.add(connection);
    // verifications
    assertTrue(recentConnection == null || !recentConnection.equals(connection));
    assertEquals(connection, registry.getRecentConnection());
}
Also used : IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) Test(org.junit.Test)

Example 14 with IConnection

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

the class ConnectionRegistryTest method shouldResetRecentConnectionOnRemoval.

@Test
public void shouldResetRecentConnectionOnRemoval() {
    // pre-conditions
    registry.add(connection);
    // operations
    registry.remove(connection);
    // verifications
    IConnection recentConnection = registry.getRecentConnection();
    assertEquals(null, recentConnection);
}
Also used : IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) Test(org.junit.Test)

Example 15 with IConnection

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

the class ConnectionRegistryTest method shouldGetConnectionByUrl.

@Test
public void shouldGetConnectionByUrl() throws UnsupportedEncodingException, MalformedURLException {
    // pre-conditions
    registry.add(connection);
    // operations
    ConnectionURL connectionUrl = ConnectionURL.forConnection(connection);
    IConnection queriedConnection = registry.getByUrl(connectionUrl);
    // verifications
    assertEquals(connection, queriedConnection);
}
Also used : ConnectionURL(org.jboss.tools.openshift.common.core.connection.ConnectionURL) 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