Search in sources :

Example 21 with IConnection

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;
    }
}
Also used : HashMap(java.util.HashMap) JolokiaConnectionWrapper(org.jboss.tools.jmx.jolokia.JolokiaConnectionWrapper) Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection)

Example 22 with IConnection

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);
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig) Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection)

Example 23 with IConnection

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());
}
Also used : IAuthorizationContext(com.openshift.restclient.authorization.IAuthorizationContext) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection)

Example 24 with IConnection

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;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ConnectionWizard(org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizard) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) FillLayout(org.eclipse.swt.layout.FillLayout) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration)

Example 25 with IConnection

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;
}
Also used : IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IConnectionChangedListener(org.jboss.tools.openshift.internal.ui.server.ChooseOpenshiftConnectionComposite.IConnectionChangedListener)

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