PageRenderTime 253ms CodeModel.GetById 243ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/atlassian/jetbrains-bitbucket-connector/
Java | 76 lines | 56 code | 15 blank | 5 comment | 8 complexity | cf60d208e759c41568d9e357166ac07e MD5 | raw file
 1package org.bitbucket.connectors.jetbrains.ui;
 2
 3import com.intellij.openapi.options.ConfigurationException;
 4import com.intellij.openapi.options.SearchableConfigurable;
 5import org.bitbucket.connectors.jetbrains.BitbucketSettings;
 6import org.bitbucket.connectors.jetbrains.BitbucketUtil;
 7import org.jetbrains.annotations.NotNull;
 8
 9import javax.swing.*;
10
11/**
12 * User: leha2000
13 * Date: Apr 7, 2011
14 * Time: 2:01:11 PM
15 */
16public class BitbucketSettingsConfigurable implements SearchableConfigurable {
17
18    private BitbucketSettingsPanel mySettingsPane;
19    private final BitbucketSettings mySettings;
20
21    public BitbucketSettingsConfigurable() {
22      mySettings = BitbucketSettings.getInstance();
23    }
24
25    public String getDisplayName() {
26      return BitbucketUtil.BITBUCKET;
27    }
28
29    public Icon getIcon() {
30      return BitbucketUtil.ICON;
31    }
32
33    public String getHelpTopic() {
34      return "settings.bitbucket";
35    }
36
37    public JComponent createComponent() {
38      if (mySettingsPane == null) {
39        mySettingsPane = new BitbucketSettingsPanel();
40      }
41      reset();
42      return mySettingsPane.getPanel();
43    }
44
45    public boolean isModified() {
46      return mySettingsPane == null || !mySettings.getLogin().equals(mySettingsPane.getLogin()) ||
47             !mySettings.getPassword().equals(mySettingsPane.getPassword());
48    }
49
50    public void apply() throws ConfigurationException {
51      if (mySettingsPane != null) {
52        mySettings.setLogin(mySettingsPane.getLogin());
53        mySettings.setPassword(mySettingsPane.getPassword());
54      }
55    }
56
57    public void reset() {
58      if (mySettingsPane != null) {
59        mySettingsPane.setLogin(mySettings.getLogin());
60        mySettingsPane.setPassword(mySettings.getPassword());
61      }
62    }
63
64    public void disposeUIResources() {
65      mySettingsPane = null;
66    }
67
68    @NotNull
69    public String getId() {
70      return getHelpTopic();
71    }
72
73    public Runnable enableSearch(String option) {
74      return null;
75    }
76}