public HTTPProxyControl()

in source/com.microsoft.tfs.client.common.ui/src/com/microsoft/tfs/client/common/ui/controls/connect/HTTPProxyControl.java [88:309]


    public HTTPProxyControl(final Composite parent, final int style) {
        super(parent, style);

        final boolean rightAlign = WindowSystem.isCurrentWindowSystem(WindowSystem.AQUA);
        final int labelHorizontalAlignment = rightAlign ? SWT.RIGHT : SWT.LEFT;
        final int verticalSectionSpacing = ControlSize.convertCharHeightToPixels(this, 1);

        final GridLayout layout = new GridLayout(4, false);
        layout.horizontalSpacing = getHorizontalSpacing();
        layout.verticalSpacing = getVerticalSpacing();
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        setLayout(layout);

        useHttpProxyButton =
            SWTUtil.createButton(this, SWT.CHECK, Messages.getString("HTTPProxyControl.UseHttpProxyButtonText")); //$NON-NLS-1$
        AutomationIDHelper.setWidgetID(useHttpProxyButton, USE_HTTP_PROXY_BUTTON_ID);
        useHttpProxyButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                HTTPProxyControl.this.onUseHTTPProxyButtonSelected(e);
            }
        });
        GridDataBuilder.newInstance().hSpan(layout).applyTo(useHttpProxyButton);

        SWTUtil.createHorizontalGridLayoutSpacer(this, 25, 1);

        httpProxyUrlLabel = SWTUtil.createLabel(this, Messages.getString("HTTPProxyControl.UrlButtonText")); //$NON-NLS-1$
        GridDataBuilder.newInstance().hAlign(labelHorizontalAlignment).applyTo(httpProxyUrlLabel);

        httpProxyUrlText = new Text(this, SWT.BORDER);
        AutomationIDHelper.setWidgetID(httpProxyUrlText, HTTP_PROXY_URL_TEXT_ID);
        SWTUtil.setSelectAllOnFocusGained(httpProxyUrlText);
        GridDataBuilder.newInstance().hGrab().hFill().wCHint(httpProxyUrlText, URL_TEXT_WIDTH_CHARS).applyTo(
            httpProxyUrlText);
        httpProxyUrlText.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(final ModifyEvent e) {
                HTTPProxyControl.this.onHTTPProxyURLTextModified(e);
            }
        });

        httpProxyUrlErrorLabel = new ErrorLabel(this, SWT.NONE);

        /*
         * Use a multi-validator so that the password url-requirement validator
         * can add its validation into this for decoration.
         */
        httpProxyUrlValidator = new MultiValidator(httpProxyUrlText);
        httpProxyUrlValidator.addValidator(
            new TextControlURLValidator(
                httpProxyUrlText,
                Messages.getString("HTTPProxyControl.UrlValidatorText"), //$NON-NLS-1$
                false));

        httpProxyUrlErrorLabel.getValidatorBinding().bind(httpProxyUrlValidator);
        multiValidator.addValidator(httpProxyUrlValidator);

        SWTUtil.createHorizontalGridLayoutSpacer(this, 2);

        httpProxyUrlExampleLabel =
            SWTUtil.createLabel(this, Messages.getString("HTTPProxyControl.ProxyUrlExampleLabelText")); //$NON-NLS-1$
        GridDataBuilder.newInstance().hFill().hSpan(2).hIndent(getHorizontalSpacing()).applyTo(
            httpProxyUrlExampleLabel);

        if (supportsDefaultCredentials) {
            useHttpProxyDefaultCredentials = true;
        }

        if (supportsDefaultCredentials && supportsSpecifiedCredentials) {
            httpProxyAuthenticationSpacer = SWTUtil.createHorizontalGridLayoutSpacer(this, 2);

            httpProxyAuthenticationCombo = new Combo(this, SWT.READ_ONLY);
            AutomationIDHelper.setWidgetID(httpProxyAuthenticationCombo, AUTHENTICATION_COMBO_ID);
            httpProxyAuthenticationCombo.add(Messages.getString("HTTPProxyControl.AuthCurrentUserChoice")); //$NON-NLS-1$
            httpProxyAuthenticationCombo.add(Messages.getString("HTTPProxyControl.AuthWithTheseCredentialsChoice")); //$NON-NLS-1$
            GridDataBuilder.newInstance().hGrab().hFill().applyTo(httpProxyAuthenticationCombo);
            httpProxyAuthenticationCombo.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent e) {
                    HTTPProxyControl.this.onHTTPProxyAuthenticationChanged(e);
                }
            });

            SWTUtil.createHorizontalGridLayoutSpacer(this, 1);
        } else {
            httpProxyAuthenticationCombo = null;
        }

        if (supportsDefaultCredentials && !supportsSpecifiedCredentials) {
            httpProxyAuthenticationSpacer = SWTUtil.createHorizontalGridLayoutSpacer(this, 2);

            httpProxyAuthenticationLabel = new Label(this, SWT.NONE);
            httpProxyAuthenticationLabel.setText(
                MessageFormat.format(
                    Messages.getString("HTTPProxyControl.AuthenticateAsDomainUserFormat"), //$NON-NLS-1$
                    UserNameUtil.getCurrentUserDomain(),
                    UserNameUtil.getCurrentUserName()));
            GridDataBuilder.newInstance().hFill().hSpan(2).hIndent(getHorizontalSpacing()).applyTo(
                httpProxyAuthenticationLabel);

            SWTUtil.createHorizontalGridLayoutSpacer(this, 1);
        } else {
            httpProxyAuthenticationLabel = null;
        }

        if (supportsSpecifiedCredentials) {
            final Control httpProxyUsernameSpacer = SWTUtil.createHorizontalGridLayoutSpacer(this, 1);

            if (httpProxyAuthenticationSpacer == null) {
                httpProxyAuthenticationSpacer = httpProxyUsernameSpacer;
            }

            httpProxyUsernameLabel =
                SWTUtil.createLabel(this, Messages.getString("HTTPProxyControl.UsernameLabelText")); //$NON-NLS-1$

            GridDataBuilder.newInstance().hAlign(labelHorizontalAlignment).applyTo(httpProxyUsernameLabel);

            httpProxyUsernameText = new Text(this, SWT.BORDER);
            AutomationIDHelper.setWidgetID(httpProxyUsernameText, USERNAME_TEXT_ID);
            SWTUtil.setSelectAllOnFocusGained(httpProxyUsernameText);
            GridDataBuilder.newInstance().hGrab().hFill().wCHint(
                httpProxyUsernameText,
                CREDENTIALS_TEXT_WIDTH_CHARS).applyTo(httpProxyUsernameText);
            httpProxyUsernameText.addModifyListener(new ModifyListener() {
                @Override
                public void modifyText(final ModifyEvent e) {
                    HTTPProxyControl.this.onHTTPProxyUsernameTextModified(e);
                }
            });

            httpProxyUsernameErrorLabel = new ErrorLabel(this, SWT.NONE);

            SWTUtil.createHorizontalGridLayoutSpacer(this, 1);

            httpProxyDomainLabel = SWTUtil.createLabel(this, Messages.getString("HTTPProxyControl.DomainLabelText")); //$NON-NLS-1$
            GridDataBuilder.newInstance().hAlign(labelHorizontalAlignment).applyTo(httpProxyDomainLabel);

            httpProxyDomainText = new Text(this, SWT.BORDER);
            AutomationIDHelper.setWidgetID(httpProxyDomainText, DOMAIN_TEXT_ID);
            SWTUtil.setSelectAllOnFocusGained(httpProxyDomainText);
            GridDataBuilder.newInstance().hGrab().hFill().wCHint(
                httpProxyDomainText,
                CREDENTIALS_TEXT_WIDTH_CHARS).applyTo(httpProxyDomainText);
            httpProxyDomainText.addModifyListener(new ModifyListener() {
                @Override
                public void modifyText(final ModifyEvent e) {
                    HTTPProxyControl.this.onHTTPProxyDomainTextModified(e);
                }
            });

            SWTUtil.createHorizontalGridLayoutSpacer(this, 1);

            SWTUtil.createHorizontalGridLayoutSpacer(this, 1);

            httpProxyPasswordLabel =
                SWTUtil.createLabel(this, Messages.getString("HTTPProxyControl.PasswordLabelText")); //$NON-NLS-1$
            GridDataBuilder.newInstance().hAlign(labelHorizontalAlignment).applyTo(httpProxyPasswordLabel);

            httpProxyPasswordText = new Text(this, SWT.BORDER | SWT.PASSWORD);
            AutomationIDHelper.setWidgetID(httpProxyPasswordText, PASSWORD_TEXT_ID);
            SWTUtil.setSelectAllOnFocusGained(httpProxyPasswordText);
            GridDataBuilder.newInstance().hGrab().hFill().wCHint(
                httpProxyPasswordText,
                CREDENTIALS_TEXT_WIDTH_CHARS).applyTo(httpProxyPasswordText);
            httpProxyPasswordText.addModifyListener(new ModifyListener() {
                @Override
                public void modifyText(final ModifyEvent e) {
                    HTTPProxyControl.this.onHTTPProxyPasswordTextModified(e);
                }
            });

            /*
             * Add a validator such that the URL and username texts are required
             * when specifying an HTTP proxy password.
             */
            httpProxyUsernameValidator = new TextControlRequiredWhenOtherTextSpecifiedValidator(
                httpProxyUsernameText,
                httpProxyPasswordText,
                Messages.getString("HTTPProxyControl.ProxyPasswordValidatorText")); //$NON-NLS-1$

            httpProxyUsernameErrorLabel.getValidatorBinding().bind(httpProxyUsernameValidator);
            multiValidator.addValidator(httpProxyUsernameValidator);

            httpProxyUrlForPasswordValidator = new TextControlRequiredWhenOtherTextSpecifiedValidator(
                httpProxyUrlText,
                httpProxyPasswordText,
                Messages.getString("HTTPProxyControl.ProxyPasswordValidatorText")); //$NON-NLS-1$
            httpProxyUrlValidator.addValidator(httpProxyUrlForPasswordValidator);
        } else {
            httpProxyUrlForPasswordValidator = null;
            httpProxyUsernameLabel = null;
            httpProxyUsernameText = null;
            httpProxyUsernameErrorLabel = null;
            httpProxyUsernameValidator = null;
            httpProxyDomainLabel = null;
            httpProxyDomainText = null;
            httpProxyPasswordLabel = null;
            httpProxyPasswordText = null;
        }

        if (supportsDefaultCredentials && supportsSpecifiedCredentials) {
            SWTUtil.addGridLayoutVerticalIndent(new Control[] {
                httpProxyAuthenticationSpacer,
                httpProxyAuthenticationCombo
            }, verticalSectionSpacing);
        } else if (supportsDefaultCredentials) {
            SWTUtil.addGridLayoutVerticalIndent(new Control[] {
                httpProxyAuthenticationSpacer,
                httpProxyAuthenticationLabel
            }, verticalSectionSpacing);
        } else if (supportsSpecifiedCredentials) {
            SWTUtil.addGridLayoutVerticalIndent(new Control[] {
                httpProxyAuthenticationSpacer,
                httpProxyUsernameLabel,
                httpProxyUsernameText,
                httpProxyUsernameErrorLabel
            }, verticalSectionSpacing);
        }

        updateEnablementAndValidation();
    }