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