Search in sources :

Example 66 with Connection

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

the class DeleteResourcesHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IResourceWrapper<?, ?>[] wrappers = UIUtils.getElements(UIUtils.getCurrentSelection(event), IResourceWrapper.class);
    if (ArrayUtils.isEmpty(wrappers) || wrappers[0].getWrapped() == null) {
        return OpenShiftUIActivator.statusFactory().cancelStatus("Could not delete resources: " + "No resource selected that we can get the connection and namespace from.");
    }
    IResource selectedResource = wrappers[0].getWrapped();
    Connection connection = ConnectionsRegistryUtil.getConnectionFor(selectedResource);
    if (connection == null) {
        return OpenShiftUIActivator.statusFactory().cancelStatus(NLS.bind("Could not delete resources: No connection found for selected resource {0}", selectedResource.getName()));
    }
    String namespace = selectedResource.getNamespaceName();
    openDialog(connection, namespace, HandlerUtil.getActiveShell(event));
    return null;
}
Also used : IResourceWrapper(org.jboss.tools.openshift.internal.ui.models.IResourceWrapper) Connection(org.jboss.tools.openshift.core.connection.Connection) IResource(com.openshift.restclient.model.IResource)

Example 67 with Connection

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

the class OpenShiftExplorerLabelProvider method getAdaptedElement.

private Object getAdaptedElement(Object element) {
    if (element instanceof IAdaptable) {
        IAdaptable adaptable = (IAdaptable) element;
        IResource resource = adaptable.getAdapter(IResource.class);
        if (resource != null) {
            element = resource;
        }
        Connection connection = adaptable.getAdapter(Connection.class);
        if (connection != null) {
            element = connection;
        }
    }
    return element;
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) Connection(org.jboss.tools.openshift.core.connection.Connection) IResource(com.openshift.restclient.model.IResource)

Example 68 with Connection

use of org.jboss.tools.openshift.core.connection.Connection 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 69 with Connection

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

the class DeployImageWizardModel method setConnection.

@Override
public void setConnection(final Connection connection) {
    Connection oldConnection = this.connection;
    firePropertyChange(PROPERTY_CONNECTION, this.connection, this.connection = connection);
    initImageRegistry(connection);
    this.resourcesLoaded = resourcesLoaded && ObjectUtils.equals(oldConnection, connection);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Example 70 with Connection

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

the class ConnectionTest method should_equal_if_different_token.

@Test
public void should_equal_if_different_token() throws Exception {
    // given
    connection.setUsername("kung");
    connection.setToken("foo");
    Connection two = new Connection("https://localhost:8443", null, null);
    two.setUsername("kung");
    two.setToken("foo");
    // when
    // then
    assertThat(connection).isEqualTo(two);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) Test(org.junit.Test)

Aggregations

Connection (org.jboss.tools.openshift.core.connection.Connection)110 Test (org.junit.Test)48 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)30 IResource (com.openshift.restclient.model.IResource)27 IProject (com.openshift.restclient.model.IProject)18 IService (com.openshift.restclient.model.IService)11 IStatus (org.eclipse.core.runtime.IStatus)11 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)9 Collection (java.util.Collection)8 List (java.util.List)8 ISelection (org.eclipse.jface.viewers.ISelection)8 IPod (com.openshift.restclient.model.IPod)7 ArrayList (java.util.ArrayList)7 CoreException (org.eclipse.core.runtime.CoreException)7 OpenShiftException (com.openshift.restclient.OpenShiftException)6 ResourceKind (com.openshift.restclient.ResourceKind)6 IRoute (com.openshift.restclient.model.route.IRoute)6 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 Status (org.eclipse.core.runtime.Status)6