public void reset() { myNoProxyRb.setSelected(true); // default HttpConfigurable httpConfigurable = myHttpConfigurable; myAutoDetectProxyRb.setSelected(httpConfigurable.USE_PROXY_PAC); myPacUrlCheckBox.setSelected(httpConfigurable.USE_PAC_URL); myPacUrlTextField.setText(httpConfigurable.PAC_URL); myUseHTTPProxyRb.setSelected(httpConfigurable.USE_HTTP_PROXY); myProxyAuthCheckBox.setSelected(httpConfigurable.PROXY_AUTHENTICATION); enableProxy(httpConfigurable.USE_HTTP_PROXY); myProxyLoginTextField.setText(httpConfigurable.PROXY_LOGIN); myProxyPasswordTextField.setText(httpConfigurable.getPlainProxyPassword()); myProxyPortTextField.setText(Integer.toString(httpConfigurable.PROXY_PORT)); myProxyHostTextField.setText(httpConfigurable.PROXY_HOST); myProxyExceptions.setText(httpConfigurable.PROXY_EXCEPTIONS); myRememberProxyPasswordCheckBox.setSelected(httpConfigurable.KEEP_PROXY_PASSWORD); mySocks.setSelected(httpConfigurable.PROXY_TYPE_IS_SOCKS); myHTTP.setSelected(!httpConfigurable.PROXY_TYPE_IS_SOCKS); final boolean showError = !StringUtil.isEmptyOrSpaces(httpConfigurable.LAST_ERROR); myErrorLabel.setVisible(showError); myErrorLabel.setText(showError ? errorText(httpConfigurable.LAST_ERROR) : ""); final String oldStyleText = CommonProxy.getMessageFromProps(CommonProxy.getOldStyleProperties()); myOtherWarning.setVisible(oldStyleText != null); if (oldStyleText != null) { myOtherWarning.setText(oldStyleText); myOtherWarning.setUI(new MultiLineLabelUI()); myOtherWarning.setIcon(Messages.getWarningIcon()); } }
@Override public void reset(@NotNull HttpConfigurable settings) { myNoProxyRb.setSelected(true); // default myAutoDetectProxyRb.setSelected(settings.USE_PROXY_PAC); myPacUrlCheckBox.setSelected(settings.USE_PAC_URL); myPacUrlTextField.setText(settings.PAC_URL); myUseHTTPProxyRb.setSelected(settings.USE_HTTP_PROXY); myProxyAuthCheckBox.setSelected(settings.PROXY_AUTHENTICATION); enableProxy(settings.USE_HTTP_PROXY); myProxyLoginTextField.setText(settings.getProxyLogin()); myProxyPasswordTextField.setText(settings.getPlainProxyPassword()); myProxyPortTextField.setNumber(settings.PROXY_PORT); myProxyHostTextField.setText(settings.PROXY_HOST); myProxyExceptions.setText(StringUtil.notNullize(settings.PROXY_EXCEPTIONS)); myRememberProxyPasswordCheckBox.setSelected(settings.KEEP_PROXY_PASSWORD); mySocks.setSelected(settings.PROXY_TYPE_IS_SOCKS); myHTTP.setSelected(!settings.PROXY_TYPE_IS_SOCKS); boolean showError = !StringUtil.isEmptyOrSpaces(settings.LAST_ERROR); myErrorLabel.setVisible(showError); myErrorLabel.setText(showError ? errorText(settings.LAST_ERROR) : null); final String oldStyleText = CommonProxy.getMessageFromProps(CommonProxy.getOldStyleProperties()); myOtherWarning.setVisible(oldStyleText != null); if (oldStyleText != null) { myOtherWarning.setText(oldStyleText); myOtherWarning.setIcon(Messages.getWarningIcon()); } }
private void initReplaceFieldsWithGetters(JavaRefactoringSettings settings) { final PsiField[] usedFields = GroovyIntroduceParameterUtil.findUsedFieldsWithGetters( myInfo.getStatements(), getContainingClass()); myGetterPanel.setVisible(usedFields.length > 0); switch (settings.INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS) { case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL: myReplaceAllFieldsRadioButton.setSelected(true); break; case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE: myReplaceFieldsInaccessibleInRadioButton.setSelected(true); break; case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE: myDoNotReplaceRadioButton.setSelected(true); break; } }
public HttpProxySettingsUi(@NotNull final HttpConfigurable settings) { ButtonGroup group = new ButtonGroup(); group.add(myUseHTTPProxyRb); group.add(myAutoDetectProxyRb); group.add(myNoProxyRb); myNoProxyRb.setSelected(true); ButtonGroup proxyTypeGroup = new ButtonGroup(); proxyTypeGroup.add(myHTTP); proxyTypeGroup.add(mySocks); myHTTP.setSelected(true); Boolean property = Boolean.getBoolean(JavaProxyProperty.USE_SYSTEM_PROXY); mySystemProxyDefined.setVisible(Boolean.TRUE.equals(property)); if (Boolean.TRUE.equals(property)) { mySystemProxyDefined.setIcon(Messages.getWarningIcon()); RelativeFont.BOLD.install(mySystemProxyDefined); } myProxyAuthCheckBox.addActionListener( new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { enableProxyAuthentication(myProxyAuthCheckBox.isSelected()); } }); myPacUrlCheckBox.addActionListener( new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { myPacUrlTextField.setEnabled(myPacUrlCheckBox.isSelected()); } }); ActionListener listener = new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { enableProxy(myUseHTTPProxyRb.isSelected()); } }; myUseHTTPProxyRb.addActionListener(listener); myAutoDetectProxyRb.addActionListener(listener); myNoProxyRb.addActionListener(listener); myClearPasswordsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { settings.clearGenericPasswords(); //noinspection DialogTitleCapitalization Messages.showMessageDialog( myMainPanel, "Proxy passwords were cleared.", "Auto-detected Proxy", Messages.getInformationIcon()); } }); configureCheckButton(); }
public HTTPProxySettingsPanel(final HttpConfigurable httpConfigurable) { final ButtonGroup group = new ButtonGroup(); group.add(myUseHTTPProxyRb); group.add(myAutoDetectProxyRb); group.add(myNoProxyRb); myNoProxyRb.setSelected(true); final ButtonGroup proxyTypeGroup = new ButtonGroup(); proxyTypeGroup.add(myHTTP); proxyTypeGroup.add(mySocks); myHTTP.setSelected(true); myProxyExceptions.setBorder(UIUtil.getTextFieldBorder()); final Boolean property = Boolean.getBoolean(JavaProxyProperty.USE_SYSTEM_PROXY); mySystemProxyDefined.setVisible(Boolean.TRUE.equals(property)); if (Boolean.TRUE.equals(property)) { mySystemProxyDefined.setIcon(Messages.getWarningIcon()); mySystemProxyDefined.setFont(mySystemProxyDefined.getFont().deriveFont(Font.BOLD)); mySystemProxyDefined.setUI(new MultiLineLabelUI()); } myProxyAuthCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { enableProxyAuthentication(myProxyAuthCheckBox.isSelected()); } }); myPacUrlCheckBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myPacUrlTextField.setEnabled(myPacUrlCheckBox.isSelected()); } }); final ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { enableProxy(myUseHTTPProxyRb.isSelected()); } }; myUseHTTPProxyRb.addActionListener(listener); myAutoDetectProxyRb.addActionListener(listener); myNoProxyRb.addActionListener(listener); myHttpConfigurable = httpConfigurable; myClearPasswordsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myHttpConfigurable.clearGenericPasswords(); Messages.showMessageDialog( myMainPanel, "Proxy passwords were cleared.", "Auto-detected proxy", Messages.getInformationIcon()); } }); if (HttpConfigurable.getInstance() != null) { myCheckButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String title = "Check Proxy Settings"; final String answer = Messages.showInputDialog( myMainPanel, "Warning: your settings will be saved.\n\nEnter any URL to check connection to:", title, Messages.getQuestionIcon(), "http://", null); if (!StringUtil.isEmptyOrSpaces(answer)) { apply(); final HttpConfigurable instance = HttpConfigurable.getInstance(); final AtomicReference<IOException> exc = new AtomicReference<IOException>(); myCheckButton.setEnabled(false); myCheckButton.setText("Check connection (in progress...)"); myConnectionCheckInProgress = true; final Application application = ApplicationManager.getApplication(); application.executeOnPooledThread( new Runnable() { @Override public void run() { HttpURLConnection connection = null; try { // already checked for null above //noinspection ConstantConditions connection = instance.openHttpConnection(answer); connection.setReadTimeout(3 * 1000); connection.setConnectTimeout(3 * 1000); connection.connect(); final int code = connection.getResponseCode(); if (HttpURLConnection.HTTP_OK != code) { exc.set(new IOException("Error code: " + code)); } } catch (IOException e1) { exc.set(e1); } finally { if (connection != null) { connection.disconnect(); } } //noinspection SSBasedInspection SwingUtilities.invokeLater( new Runnable() { @Override public void run() { myConnectionCheckInProgress = false; reset(); // since password might have been set Component parent = null; if (myMainPanel.isShowing()) { parent = myMainPanel; myCheckButton.setText("Check connection"); myCheckButton.setEnabled(canEnableConnectionCheck()); } else { final IdeFrame frame = IdeFocusManager.findInstance().getLastFocusedFrame(); if (frame == null) { return; } parent = frame.getComponent(); } //noinspection ThrowableResultOfMethodCallIgnored final IOException exception = exc.get(); if (exception == null) { Messages.showMessageDialog( parent, "Connection successful", title, Messages.getInformationIcon()); } else { final String message = exception.getMessage(); if (instance.USE_HTTP_PROXY) { instance.LAST_ERROR = message; } Messages.showErrorDialog(parent, errorText(message)); } } }); } }); } } }); } else { myCheckButton.setVisible(false); } }