use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class OpenshiftJMXConnectionProvider method createConnection.
@Override
protected IConnectionWrapper createConnection(IServer server) {
IConnection openshiftCon = OpenShiftServerUtils.getConnection(server);
String url = computeJolokiaURL(server);
if (url != null) {
JolokiaConnectionWrapper cw = new JolokiaConnectionWrapper() {
@Override
public IConnectionProvider getProvider() {
return ExtensionManager.getProvider(PROVIDER_ID);
}
};
cw.setId(server.getName());
cw.setUrl(url);
cw.setType("POST");
cw.setIgnoreSSLErrors(true);
Map<String, String> headers = new HashMap<>();
headers.put(AUTHORIZATION_HEADER_KEY, AUTHORIZATION_HEADER_VALUE_PREFIX + ((Connection) openshiftCon).getToken());
cw.setHeaders(headers);
return cw;
} else {
return null;
}
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class OpenshiftEapProfileDetector method getBuildConfig.
private IBuildConfig getBuildConfig(IConnection connection, IResource resource) {
if (resource == null || resource.getProject() == null || !(connection instanceof Connection)) {
return null;
}
Connection connectionInstance = (Connection) connection;
List<IBuildConfig> buildConfigs = connectionInstance.getResources(ResourceKind.BUILD_CONFIG, resource.getProject().getName());
if (buildConfigs == null) {
return null;
}
return ResourceUtils.getBuildConfigFor(resource, buildConfigs);
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class Connection method update.
@Override
public void update(IConnection connection) {
Assert.isLegal(connection instanceof Connection);
Connection otherConnection = (Connection) connection;
this.client = otherConnection.client;
this.credentialsPrompter = otherConnection.credentialsPrompter;
this.rememberToken = otherConnection.rememberToken;
this.rememberPassword = otherConnection.rememberPassword;
this.tokenLoaded = otherConnection.tokenLoaded;
this.rememberPassword = otherConnection.rememberPassword;
this.extendedProperties = otherConnection.getExtendedProperties();
IAuthorizationContext otherContext = otherConnection.client.getAuthorizationContext();
IAuthorizationContext context = this.client.getAuthorizationContext();
context.setUserName(otherContext.getUserName());
context.setPassword(otherContext.getPassword());
context.setToken(otherContext.getToken());
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class ChooseOpenshiftConnectionComposite method createComposite.
public Composite createComposite(Composite main) {
main.setLayout(new GridLayout(5, true));
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
main.setLayoutData(gd);
Label connLabel = new Label(main, SWT.NONE);
connLabel.setText("Connection: ");
connectionCombo = new Combo(main, SWT.READ_ONLY);
GridDataFactory.fillDefaults().span(3, 1).applyTo(connectionCombo);
Composite btnWrapper = new Composite(main, SWT.NONE);
btnWrapper.setLayout(new FillLayout());
Button editConBtn = new Button(btnWrapper, SWT.PUSH);
editConBtn.setText("Edit...");
Button addConBtn = new Button(btnWrapper, SWT.PUSH);
addConBtn.setText("New...");
GridDataFactory.fillDefaults().applyTo(btnWrapper);
addConBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final ConnectionWizard connectionWizard = new ConnectionWizard((IConnection) null);
int ret = WizardUtils.openWizardDialog(connectionWizard, addConBtn.getShell());
if (ret == Window.OK) {
refreshConnections();
IConnection c = connectionWizard.getConnection();
int ind = connections.indexOf(c);
if (ind != -1) {
connectionCombo.select(ind);
}
}
}
});
editConBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final ConnectionWizard connectionWizard = new ConnectionWizard(selectedConnection, ConnectionWizard.EDIT_CONNECTION_TITLE);
WizardUtils.openWizardDialog(connectionWizard, editConBtn.getShell());
refreshConnections();
IConnection c = connectionWizard.getConnection();
int ind = connections.indexOf(c);
if (ind != -1) {
connectionCombo.select(ind);
setSelectedConnection(c);
}
}
});
Label serverLbl = new Label(main, SWT.NONE);
serverLbl.setText("Server: ");
serverValueLbl = new Label(main, SWT.NONE);
GridDataFactory.fillDefaults().span(4, 1).applyTo(serverValueLbl);
Group authGroup = new Group(main, SWT.NONE);
authGroup.setText("Authentication");
GridDataFactory.fillDefaults().span(5, 1).indent(0, 5).applyTo(authGroup);
authGroup.setLayout(new GridLayout(6, true));
Label protocolLbl = new Label(authGroup, SWT.NONE);
protocolLbl.setText("Protocol: ");
protocolValLbl = new Label(authGroup, SWT.NONE);
GridDataFactory.fillDefaults().span(5, 1).applyTo(protocolValLbl);
userLbl = new Label(authGroup, SWT.NONE);
userLbl.setText("Username: ");
usernameValLbl = new Label(authGroup, SWT.NONE);
GridDataFactory.fillDefaults().span(5, 1).applyTo(usernameValLbl);
Group advancedGroup = new Group(main, SWT.NONE);
advancedGroup.setText("Advanced");
GridDataFactory.fillDefaults().span(5, 1).indent(0, 5).applyTo(advancedGroup);
advancedGroup.setLayout(new GridLayout(6, true));
Label imageRegistryLbl = new Label(advancedGroup, SWT.NONE);
imageRegistryLbl.setText("Image Registry URL: ");
imageRegistryValLbl = new Label(advancedGroup, SWT.NONE);
GridDataFactory.fillDefaults().span(5, 1).applyTo(imageRegistryValLbl);
Label clusterNamespaceLbl = new Label(advancedGroup, SWT.NONE);
clusterNamespaceLbl.setText("Cluster namespace: ");
clusterNamespaceValLbl = new Label(advancedGroup, SWT.NONE);
GridDataFactory.fillDefaults().span(5, 1).applyTo(clusterNamespaceValLbl);
Label ocLocationLbl = new Label(advancedGroup, SWT.NONE);
ocLocationLbl.setText("OC Binary Location: ");
ocLocationValLbl = new Label(advancedGroup, SWT.NONE);
ocLocationDecorator = new ControlDecoration(ocLocationValLbl, SWT.TOP | SWT.LEFT);
GridDataFactory.fillDefaults().span(5, 1).applyTo(ocLocationValLbl);
// Load the model
refreshConnections();
connectionCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int selIndex = connectionCombo.getSelectionIndex();
if (selIndex != -1 && selIndex < connections.size()) {
setSelectedConnection(connections.get(selIndex));
}
editConBtn.setEnabled(selIndex != -1);
}
});
if (connectionCombo.getItemCount() > 0) {
connectionCombo.select(0);
setSelectedConnection(connections.get(0));
}
int selIndex = connectionCombo.getSelectionIndex();
editConBtn.setEnabled(selIndex != -1);
return main;
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class ChooseOpenshiftConnectionFragment method createComposite.
@Override
public Composite createComposite(Composite parent, final IWizardHandle handle) {
this.handle = handle;
initWizardHandle();
chooseConnectionComposite = new ChooseOpenshiftConnectionComposite(parent);
chooseConnectionComposite.setConnectionChangeListener(new IConnectionChangedListener() {
@Override
public void connectionChanged(IConnection newVal) {
selectedConnectionChanged(newVal);
}
});
getContainer(getPage(handle)).addPageChangingListener(onPageChanging(handle));
selectedConnectionChanged(chooseConnectionComposite.getConnection());
return chooseConnectionComposite;
}
Aggregations