PageRenderTime 47ms CodeModel.GetById 25ms 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
  1. package org.bitbucket.connectors.jetbrains.ui;
  2. import com.intellij.CommonBundle;
  3. import com.intellij.openapi.project.Project;
  4. import com.intellij.openapi.ui.DialogWrapper;
  5. import org.bitbucket.connectors.jetbrains.BitbucketUtil;
  6. import javax.swing.*;
  7. import java.awt.event.ActionEvent;
  8. /**
  9. * User: leha2000
  10. * Date: Sep 22, 2011
  11. * Time: 11:14:26 AM
  12. */
  13. abstract class BitbucketDialog extends DialogWrapper {
  14. private Project myProject;
  15. private DialogWrapperAction myOkAction = new EnableSshAction();
  16. protected BitbucketDialog(Project project) {
  17. super(project, true);
  18. myProject = project;
  19. }
  20. protected Action[] createActions() {
  21. return new Action[]{myOkAction, getCancelAction()};
  22. }
  23. @Override
  24. protected void setOKActionEnabled(boolean isEnabled) {
  25. myOkAction.setEnabled(isEnabled);
  26. }
  27. @Override
  28. public boolean isOKActionEnabled() {
  29. return myOkAction.isEnabled();
  30. }
  31. @Override
  32. protected Action getOKAction() {
  33. return myOkAction;
  34. }
  35. public abstract boolean isUseSsh();
  36. protected class EnableSshAction extends DialogWrapperAction {
  37. private EnableSshAction() {
  38. super(CommonBundle.getOkButtonText());
  39. putValue(DEFAULT_ACTION, Boolean.TRUE);
  40. }
  41. @Override
  42. protected void doAction(ActionEvent e) {
  43. if (isUseSsh()) {
  44. if (!BitbucketUtil.enableSsh(myProject, BitbucketDialog.this.getContentPane())) {
  45. return;
  46. }
  47. }
  48. doOKAction();
  49. }
  50. }
  51. }