PageRenderTime 42ms CodeModel.GetById 34ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/atlassian/jetbrains-bitbucket-connector/
Java | 65 lines | 46 code | 14 blank | 5 comment | 2 complexity | 273f2ef1e5f54d8b94a08cd248d6c1ab MD5 | raw file
 1package org.bitbucket.connectors.jetbrains.ui;
 2
 3import com.intellij.CommonBundle;
 4import com.intellij.openapi.project.Project;
 5import com.intellij.openapi.ui.DialogWrapper;
 6import org.bitbucket.connectors.jetbrains.BitbucketUtil;
 7
 8import javax.swing.*;
 9import java.awt.event.ActionEvent;
10
11/**
12 * User: leha2000
13 * Date: Sep 22, 2011
14 * Time: 11:14:26 AM
15 */
16abstract class BitbucketDialog extends DialogWrapper {
17
18    private Project myProject;
19    private DialogWrapperAction myOkAction = new EnableSshAction();
20
21    protected BitbucketDialog(Project project) {
22        super(project, true);
23        myProject = project;
24    }
25
26    protected Action[] createActions() {
27        return new Action[]{myOkAction, getCancelAction()};
28    }
29
30    @Override
31    protected void setOKActionEnabled(boolean isEnabled) {
32        myOkAction.setEnabled(isEnabled);
33    }
34
35    @Override
36    public boolean isOKActionEnabled() {
37        return myOkAction.isEnabled();
38    }
39
40    @Override
41    protected Action getOKAction() {
42        return myOkAction;
43    }
44
45    public abstract boolean isUseSsh();
46
47    protected class EnableSshAction extends DialogWrapperAction {
48
49        private EnableSshAction() {
50            super(CommonBundle.getOkButtonText());
51            putValue(DEFAULT_ACTION, Boolean.TRUE);
52        }
53
54        @Override
55        protected void doAction(ActionEvent e) {
56            if (isUseSsh()) {
57                if (!BitbucketUtil.enableSsh(myProject, BitbucketDialog.this.getContentPane())) {
58                    return;
59                }
60            }
61            doOKAction();
62        }
63    }
64
65}