PageRenderTime 58ms CodeModel.GetById 55ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/src/org/bitbucket/connectors/jetbrains/ui/BitbucketLoginPanel.java

https://bitbucket.org/atlassian/jetbrains-bitbucket-connector/
Java | 55 lines | 37 code | 13 blank | 5 comment | 0 complexity | ecf24bbe4713d3f2aad5533ee7eeb4f3 MD5 | raw file
 1package org.bitbucket.connectors.jetbrains.ui;
 2
 3import com.intellij.ui.DocumentAdapter;
 4
 5import javax.swing.*;
 6import javax.swing.event.DocumentEvent;
 7import javax.swing.event.DocumentListener;
 8
 9/**
10 * User: leha2000
11 * Date: Apr 15, 2011
12 * Time: 10:08:24 AM
13 */
14public class BitbucketLoginPanel {
15
16    private JPanel myPane;
17
18    private JTextField myLoginTextField;
19    private JPasswordField myPasswordField;
20
21    public BitbucketLoginPanel(final BitbucketLoginDialog dialog) {
22        DocumentListener listener = new DocumentAdapter() {
23            protected void textChanged(DocumentEvent documentEvent) {
24                dialog.clearErrors();
25            }
26        };
27
28        myLoginTextField.getDocument().addDocumentListener(listener);
29        myPasswordField.getDocument().addDocumentListener(listener);
30    }
31
32    public JComponent getPanel() {
33        return myPane;
34    }
35
36    public void setLogin(String login) {
37        myLoginTextField.setText(login);
38    }
39
40    public void setPassword(String password) {
41        myPasswordField.setText(password);
42    }
43
44    public String getLogin() {
45        return myLoginTextField.getText().trim();
46    }
47
48    public String getPassword() {
49        return String.valueOf(myPasswordField.getPassword());
50    }
51
52    public JComponent getPreferrableFocusComponent() {
53        return myLoginTextField;
54    }
55}