use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class PodLogsHandler method getPodFromBuild.
private IPod getPodFromBuild(ExecutionEvent event) {
IBuild build = getSelectedElement(event, IBuild.class);
if (build != null) {
final String buildName = build.getName();
Connection connection = ConnectionsRegistryUtil.safeGetConnectionFor(build);
List<IPod> pods = connection.getResources(ResourceKind.POD, build.getNamespaceName());
for (IPod pod : pods) {
if (buildName.equals(pod.getAnnotation(OpenShiftAPIAnnotations.BUILD_NAME))) {
return pod;
}
}
}
return null;
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class NewProjectHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
Connection connection = UIUtils.getFirstElement(selection, Connection.class);
if (connection == null) {
IProject project = UIUtils.getFirstElement(selection, IProject.class);
if (project != null) {
connection = ConnectionsRegistryUtil.getConnectionFor(project);
}
}
if (connection == null) {
// $NON-NLS-1$
return OpenShiftUIActivator.statusFactory().cancelStatus("No connection selected");
}
openNewProjectDialog(connection, HandlerUtil.getActiveShell(event));
return null;
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ConnectionValidatorFactory method createBasicAuthenticationValidator.
/**
* Returns new validator that checks that there is no connection other than the selected one
* with host and username provided by the observable values.
* @param pageModel
* @param usernameObservable
* @param urlObservable
* @return
*/
public static MultiValidator createBasicAuthenticationValidator(ConnectionWizardPageModel pageModel, IObservableValue usernameObservable, IObservableValue<?> urlObservable) {
return new MultiValidator() {
@Override
protected IStatus validate() {
String user1 = (String) usernameObservable.getValue();
String mHost = (String) urlObservable.getValue();
IConnection current = pageModel.getSelectedConnection();
for (Connection c : ConnectionsRegistrySingleton.getInstance().getAll(Connection.class)) {
if (c != current && IAuthorizationContext.AUTHSCHEME_BASIC.equals(c.getAuthScheme())) {
String host = c.getHost();
String user = c.getUsername();
if (host != null && host.equals(mHost) && user != null && user.equals(user1)) {
return ValidationStatus.error("Connection for the server with this username already exists.");
}
}
}
return ValidationStatus.ok();
}
};
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ConnectionValidatorFactory method createOAuthAuthenticationValidator.
/**
* Returns new validator that checks that there is no connection other than the selected one
* with host and token provided by the observable values.
* @param pageModel
* @param tokenObservable
* @param urlObservable
* @return
*/
public static MultiValidator createOAuthAuthenticationValidator(ConnectionWizardPageModel pageModel, IObservableValue tokenObservable, IObservableValue<?> urlObservable) {
return new MultiValidator() {
@Override
protected IStatus validate() {
String token1 = (String) tokenObservable.getValue();
String mHost = (String) urlObservable.getValue();
IConnection current = pageModel.getSelectedConnection();
for (Connection c : ConnectionsRegistrySingleton.getInstance().getAll(Connection.class)) {
if (c != current && IAuthorizationContext.AUTHSCHEME_OAUTH.equals(c.getAuthScheme())) {
String host = c.getHost();
String token = c.getToken();
if (host != null && host.equals(mHost) && token != null && token.equals(token1)) {
return ValidationStatus.error("Connection for the server with this token already exists.");
}
}
}
return ValidationStatus.ok();
}
};
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class BasicAuthenticationDetailView method setSelectedConnection.
@Override
public void setSelectedConnection(IConnection conn) {
if (conn instanceof Connection) {
Connection selectedConnection = (Connection) conn;
usernameObservable.setValue(selectedConnection.getUsername());
passwordObservable.setValue(selectedConnection.getPassword());
rememberPasswordObservable.setValue(selectedConnection.isRememberPassword());
} else if (conn instanceof NewConnectionMarker) {
usernameObservable.setValue(null);
passwordObservable.setValue(null);
}
}
Aggregations