PageRenderTime 353ms CodeModel.GetById 262ms app.highlight 5ms RepoModel.GetById 85ms app.codeStats 0ms

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

https://bitbucket.org/atlassian/jetbrains-bitbucket-connector/
Java | 79 lines | 57 code | 17 blank | 5 comment | 1 complexity | 5e04217b7d6fac2cd56ab85dd66659d6 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 java.awt.*;
 8
 9/**
10 * User: leha2000
11 * Date: Apr 16, 2011
12 * Time: 10:59:20 AM
13 */
14public class BitbucketSharePanel {
15
16    private JPanel myPanel;
17
18    private JTextField myNameTextField;
19    private JCheckBox myPrivateCheckBox;
20    private JTextPane myDescriptionTextPane;
21    private JCheckBox mySshRepositoryAccessCheckBox;
22    private JCheckBox myGITCheckBox;
23
24    public BitbucketSharePanel(final BitbucketShareDialog dialog) {
25        myNameTextField.getDocument().addDocumentListener(new DocumentAdapter() {
26            protected void textChanged(DocumentEvent documentEvent) {
27                dialog.updateOkButton();
28            }
29        });
30        myNameTextField.setPreferredSize(new Dimension(myNameTextField.getFontMetrics(myNameTextField.getFont()).charWidth('W') * 30, -1));
31    }
32
33    public JPanel getPanel() {
34        return myPanel;
35    }
36
37    public JComponent getPreferredFocusComponent() {
38        return myNameTextField;
39    }
40
41    public String getRepositoryName() {
42        return myNameTextField.getText().trim();
43    }
44
45    public void setRepositoryName(String name) {
46        myNameTextField.setText(name);
47    }
48
49    public boolean isPrivate() {
50        return myPrivateCheckBox.isSelected();
51    }
52
53    public boolean isSshRepositoryAccess() {
54        return mySshRepositoryAccessCheckBox.isSelected();
55    }
56
57    public String getDescription() {
58        return myDescriptionTextPane.getText().trim();
59    }
60
61    public void setCanCreatePrivate(boolean canCreatePrivate) {
62        if (!canCreatePrivate) {
63            myPrivateCheckBox.setEnabled(false);
64            myPrivateCheckBox.setToolTipText("Your account doesn't support private repositories");
65        }
66    }
67
68    public boolean isGit() {
69        return myGITCheckBox.isSelected();
70    }
71
72    public void setGit(boolean select) {
73        myGITCheckBox.setSelected(select);
74    }
75
76    public void enableGit(boolean enable) {
77        myGITCheckBox.setEnabled(enable);
78    }
79}