public void addActionListener(final ActionListener actionListener) { myProxyLoginTextField.addActionListener(actionListener); DocumentListener docListener = new DocumentListener() { public void insertUpdate(DocumentEvent e) { actionListener.actionPerformed(null); } public void removeUpdate(DocumentEvent e) { actionListener.actionPerformed(null); } public void changedUpdate(DocumentEvent e) { actionListener.actionPerformed(null); } }; myProxyPasswordTextField.getDocument().addDocumentListener(docListener); myProxyAuthCheckBox.addActionListener(actionListener); myProxyPortTextField.getDocument().addDocumentListener(docListener); myProxyHostTextField.getDocument().addDocumentListener(docListener); myUseHTTPProxyRb.addActionListener(actionListener); myRememberProxyPasswordCheckBox.addActionListener(actionListener); }
public GithubLoginPanel(final GithubLoginDialog dialog) { DocumentListener listener = new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { dialog.clearErrors(); } }; myLoginTextField.getDocument().addDocumentListener(listener); myPasswordField.getDocument().addDocumentListener(listener); mySignupTextField.setText( "<html>Do not have an account at github.com? <a href=\"https://github.com\">Sign up</a>.</html>"); mySignupTextField.setMargin(new Insets(5, 0, 0, 0)); mySignupTextField.addHyperlinkListener( new HyperlinkAdapter() { @Override protected void hyperlinkActivated(final HyperlinkEvent e) { BrowserUtil.browse(e.getURL()); } }); mySignupTextField.setBackground(UIUtil.TRANSPARENT_COLOR); mySignupTextField.setCursor(new Cursor(Cursor.HAND_CURSOR)); }
public ConfigurationPanel(final Project project) { serverUrl.setName("serverUrl"); buildDelay.setName("buildDelay"); jobRefreshPeriod.setName("jobRefreshPeriod"); rssRefreshPeriod.setName("rssRefreshPeriod"); username.setName("_username_"); passwordField.setName("passwordFile"); crumbDataField.setName("crumbDataFile"); testConnexionButton.setName("testConnexionButton"); connectionStatusLabel.setName("connectionStatusLabel"); successOrStableCheckBox.setName("successOrStableCheckBox"); unstableOrFailCheckBox.setName("unstableOrFailCheckBox"); abortedCheckBox.setName("abortedCheckBox"); rssStatusFilterPanel.setBorder(IdeBorderFactory.createTitledBorder("Event Log Settings", true)); debugPanel.setVisible(false); initDebugTextPane(); buildDelay.setDocument(new NumberDocument()); jobRefreshPeriod.setDocument(new NumberDocument()); rssRefreshPeriod.setDocument(new NumberDocument()); uploadPatchSettingsPanel.setBorder( IdeBorderFactory.createTitledBorder("Upload a Patch Settings", true)); passwordField .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { myPasswordModified = true; } @Override public void removeUpdate(DocumentEvent e) { myPasswordModified = true; } @Override public void changedUpdate(DocumentEvent e) { myPasswordModified = true; } }); testConnexionButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { try { debugPanel.setVisible(false); new NotNullValidator().validate(serverUrl); new UrlValidator().validate(serverUrl); JenkinsSettings jenkinsSettings = JenkinsSettings.getSafeInstance(project); String password = isPasswordModified() ? getPassword() : jenkinsSettings.getPassword(); RequestManager.getInstance(project) .authenticate( serverUrl.getText(), username.getText(), password, crumbDataField.getText()); setConnectionFeedbackLabel(CONNECTION_TEST_SUCCESSFUL_COLOR, "Successful"); setPassword(password); } catch (Exception ex) { setConnectionFeedbackLabel(CONNECTION_TEST_FAILED_COLOR, "[Fail] " + ex.getMessage()); if (ex instanceof AuthenticationException) { AuthenticationException authenticationException = (AuthenticationException) ex; String responseBody = authenticationException.getResponseBody(); if (StringUtils.isNotBlank(responseBody)) { debugPanel.setVisible(true); debugTextPane.setText(responseBody); } } } } }); formValidator = FormValidator.init(this) .addValidator( username, new UIValidator<JTextField>() { public void validate(JTextField component) throws ConfigurationException { if (StringUtils.isNotBlank(component.getText())) { String password = getPassword(); if (StringUtils.isBlank(password)) { throw new ConfigurationException( String.format("'%s' must be set", passwordField.getName())); } } } }); }