Java 类com.intellij.openapi.ui.DialogWrapper 实例源码

项目:commit-template-idea-plugin    文件:CreateCommitAction.java   
@Override
public void actionPerformed(AnActionEvent actionEvent) {
    final CommitMessageI commitPanel = getCommitPanel(actionEvent);
    if (commitPanel == null)
        return;

    CommitDialog dialog = new CommitDialog(actionEvent.getProject());
    dialog.show();
    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        commitPanel.setCommitMessage(dialog.getCommitMessage());
    }
}
项目:GitCommitMessage    文件:Panel.java   
Panel(Project project) {

        String branch = CommitMessage.extractBranchName(project);
        if (branch != null) {
            // Branch name  matches Ticket Name
            setTextFieldsBasedOnBranch(branch);
        }

        changeTemplateButton.addActionListener(e -> {
            DialogWrapper dialog = createTemplateDialog(project);
            if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
                dialog.getExitCode();
            }

        });
    }
项目:educational-plugin    文件:EduBrowseCoursesAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  EduCoursesPanel panel = new EduCoursesPanel();
  DialogBuilder dialogBuilder = new DialogBuilder().title("Select Course").centerPanel(panel);
  dialogBuilder.addOkAction().setText("Join");
  panel.addCourseValidationListener(new EduCoursesPanel.CourseValidationListener() {
    @Override
    public void validationStatusChanged(boolean canStartCourse) {
      dialogBuilder.setOkActionEnabled(canStartCourse);
    }
  });
  dialogBuilder.setOkOperation(() -> {
    dialogBuilder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
    Course course = panel.getSelectedCourse();
    String location = panel.getLocationString();
    EduCreateNewProjectDialog.createProject(EduPluginConfigurator.INSTANCE.forLanguage(course.getLanguageById()).getEduCourseProjectGenerator(), course, location);
  });
  dialogBuilder.show();
}
项目:deltahex-intellij-plugin    文件:DeltaHexOptionsPanel.java   
private void selectFontButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectFontButtonActionPerformed
    final TextFontPanel textFontPanel = new TextFontPanel();

    DefaultControlPanel textFontControlPanel = new DefaultControlPanel();
    textFontPanel.setStoredFont(deltaHexFont);
    textFontPanel.setVisible(true);
    JPanel dialogPanel = WindowUtils.createDialogPanel(textFontPanel, textFontControlPanel);
    WindowUtils.assignGlobalKeyListener(dialogPanel, textFontControlPanel.createOkCancelListener());
    final DialogWrapper dialog = DialogUtils.createDialog(dialogPanel, "Select Font");

    textFontControlPanel.setHandler(new DefaultControlHandler() {
        @Override
        public void controlActionPerformed(DefaultControlHandler.ControlActionType actionType) {
            if (actionType == DefaultControlHandler.ControlActionType.OK) {
                deltaHexFont = textFontPanel.getStoredFont();
                updateFontTextField();
                useDefaultFontCheckBox.setSelected(false);
            }

            dialog.close(0);
        }
    });
    dialog.showAndGet();
}
项目:intellij-ce-playground    文件:CreateExternalAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final ActionExecuteHelper helper = new ActionExecuteHelper();
  checkState(e, helper);
  if (! helper.isOk()) return;

  final DataContext dc = e.getDataContext();
  final Project project = CommonDataKeys.PROJECT.getData(dc);
  final VirtualFile vf = CommonDataKeys.VIRTUAL_FILE.getData(dc);

  //1 select target
  final SelectCreateExternalTargetDialog dialog = new SelectCreateExternalTargetDialog(project, vf);
  dialog.show();
  if (DialogWrapper.OK_EXIT_CODE != dialog.getExitCode()) return;

  final String url = dialog.getSelectedURL();
  final boolean checkout = dialog.isCheckout();
  final String target = dialog.getLocalTarget().trim();

  ProgressManager.getInstance().run(new Task.Backgroundable(project, "Creating External", true, null) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      doInBackground(project, vf, url, checkout, target);
    }
  });
}
项目:intellij-ce-playground    文件:ShowSettingsUtilImpl.java   
public static void showSettingsDialog(@Nullable Project project, final String id2Select, final String filter) {
  ConfigurableGroup[] group = getConfigurableGroups(project, true);

  group = filterEmptyGroups(group);
  final Configurable configurable2Select = id2Select == null ? null : new ConfigurableVisitor.ByID(id2Select).find(group);

  if (Registry.is("ide.new.settings.view")) {
    new SettingsDialog(getProject(project), group, configurable2Select, filter).show();
    return;
  }
  final DialogWrapper dialog = getDialog(project, group, configurable2Select);

  new UiNotifyConnector.Once(dialog.getContentPane(), new Activatable.Adapter() {
    @Override
    public void showNotify() {
      final OptionsEditor editor = (OptionsEditor)((DataProvider)dialog).getData(OptionsEditor.KEY.getName());
      LOG.assertTrue(editor != null);
      editor.select(configurable2Select, filter);
    }
  });
  dialog.show();
}
项目:intellij-ce-playground    文件:IdeaDialogFixture.java   
@Nullable
protected static <T extends DialogWrapper> T getDialogWrapperFrom(@NotNull JDialog dialog, Class<T> dialogWrapperType) {
  try {
    WeakReference<DialogWrapper> dialogWrapperRef = field("myDialogWrapper").ofType(new TypeRef<WeakReference<DialogWrapper>>() {})
                                                                            .in(dialog)
                                                                            .get();
    assertNotNull(dialogWrapperRef);
    DialogWrapper wrapper = dialogWrapperRef.get();
    if (dialogWrapperType.isInstance(wrapper)) {
      return dialogWrapperType.cast(wrapper);
    }
  }
  catch (ReflectionError ignored) {
  }
  return null;
}
项目:intellij-ce-playground    文件:JBMacMessages.java   
@Override
public int showYesNoDialog(@NotNull String title,
                           String message,
                           @NotNull String yesButton,
                           @NotNull String noButton,
                           @Nullable Window window,
                           @Nullable DialogWrapper.DoNotAskOption doNotAskDialogOption) {
  if (window == null) {
    window = getForemostWindow(null);
  }
  SheetMessage sheetMessage = new SheetMessage(window, title, message, UIUtil.getQuestionIcon(),
                                               new String [] {yesButton, noButton}, doNotAskDialogOption, yesButton, noButton);
  int result = sheetMessage.getResult().equals(yesButton) ? Messages.YES : Messages.NO;
  if (doNotAskDialogOption != null && (result == Messages.YES || doNotAskDialogOption.shouldSaveOptionsOnCancel())) {
    doNotAskDialogOption.setToBeShown(sheetMessage.toBeShown(), result);
  }
  return result;
}
项目:intellij-ce-playground    文件:SuperMethodWarningUtil.java   
public static PsiMethod checkSuperMethod(@NotNull PsiMethod method, @NotNull String actionString) {
  PsiClass aClass = method.getContainingClass();
  if (aClass == null) return method;

  PsiMethod superMethod = method.findDeepestSuperMethod();
  if (superMethod == null) return method;

  if (ApplicationManager.getApplication().isUnitTestMode()) return superMethod;

  PsiClass containingClass = superMethod.getContainingClass();

  SuperMethodWarningDialog dialog =
      new SuperMethodWarningDialog(
          method.getProject(),
          DescriptiveNameUtil.getDescriptiveName(method), actionString, containingClass.isInterface() || superMethod.hasModifierProperty(PsiModifier.ABSTRACT),
          containingClass.isInterface(), aClass.isInterface(), containingClass.getQualifiedName()
      );
  dialog.show();

  if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) return superMethod;
  if (dialog.getExitCode() == SuperMethodWarningDialog.NO_EXIT_CODE) return method;

  return null;
}
项目:intellij-ce-playground    文件:XJumpToSourceActionBase.java   
@Override
protected void perform(final XValueNodeImpl node, @NotNull final String nodeName, final AnActionEvent e) {
  XValue value = node.getValueContainer();
  final XDebuggerEvaluationDialog dialog = e.getData(XDebuggerEvaluationDialog.KEY);
  XNavigatable navigatable = new XNavigatable() {
    @Override
    public void setSourcePosition(@Nullable final XSourcePosition sourcePosition) {
      if (sourcePosition != null) {
        final Project project = node.getTree().getProject();
        AppUIUtil.invokeOnEdt(new Runnable() {
          @Override
          public void run() {
            sourcePosition.createNavigatable(project).navigate(true);
            if (dialog != null && Registry.is("debugger.close.dialog.on.navigate")) {
              dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
            }
          }
        }, project.getDisposed());
      }
    }
  };
  startComputingSourcePosition(value, navigatable);
}
项目:intellij-ce-playground    文件:RepositoryAttachHandler.java   
@Nullable
public static NewLibraryConfiguration chooseLibraryAndDownload(final @NotNull Project project,
                                                               final @Nullable String initialFilter,
                                                               JComponent parentComponent) {
  RepositoryAttachDialog dialog = new RepositoryAttachDialog(project, initialFilter);
  dialog.setTitle("Download Library From Maven Repository");
  dialog.show();
  if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
    return null;
  }

  String copyTo = dialog.getDirectoryPath();
  String coord = dialog.getCoordinateText();
  boolean attachJavaDoc = dialog.getAttachJavaDoc();
  boolean attachSources = dialog.getAttachSources();
  List<MavenRepositoryInfo> repositories = dialog.getRepositories();
  NewLibraryConfiguration configuration = resolveAndDownload(project, coord, attachJavaDoc, attachSources, copyTo, repositories);
  if (configuration == null) {
    Messages.showErrorDialog(parentComponent, ProjectBundle.message("maven.downloading.failed", coord), CommonBundle.getErrorTitle());
  }
  return configuration;
}
项目:intellij-ce-playground    文件:GitPushOperationSingleRepoTest.java   
public void test_rejected_push_to_tracked_branch_proposes_to_update() throws IOException {
  pushCommitFromBro();

  final Ref<Boolean> dialogShown = Ref.create(false);
  myDialogManager.registerDialogHandler(GitRejectedPushUpdateDialog.class, new TestDialogHandler<GitRejectedPushUpdateDialog>() {
    @Override
    public int handleDialog(GitRejectedPushUpdateDialog dialog) {
      dialogShown.set(true);
      return DialogWrapper.CANCEL_EXIT_CODE;
    }
  });

  GitPushResult result = push("master", "origin/master");

  assertTrue("Rejected push dialog wasn't shown", dialogShown.get());
  assertResult(REJECTED, -1, "master", "origin/master", result);
}
项目:intellij-ce-playground    文件:JavaLanguageInjectionSupport.java   
private static BaseInjection showInjectionUI(final Project project, final MethodParameterInjection methodParameterInjection) {
  final AbstractInjectionPanel panel = new MethodParameterPanel(methodParameterInjection, project);
  panel.reset();
  final DialogBuilder builder = new DialogBuilder(project);
  builder.setHelpId("reference.settings.injection.language.injection.settings.java.parameter");
  builder.addOkAction();
  builder.addCancelAction();
  builder.setCenterPanel(panel.getComponent());
  builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE);
  builder.setOkOperation(new Runnable() {
    public void run() {
      panel.apply();
      builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
    }
  });
  if (builder.show() == DialogWrapper.OK_EXIT_CODE) {
    return new BaseInjection(methodParameterInjection.getSupportId()).copyFrom(methodParameterInjection);
  }
  return null;
}
项目:intellij-ce-playground    文件:GitPushOperationSingleRepoTest.java   
public void test_dont_propose_to_update_if_force_push_is_rejected() throws IOException {
  final Ref<Boolean> dialogShown = Ref.create(false);
  myDialogManager.registerDialogHandler(GitRejectedPushUpdateDialog.class, new TestDialogHandler<GitRejectedPushUpdateDialog>() {
    @Override
    public int handleDialog(GitRejectedPushUpdateDialog dialog) {
      dialogShown.set(true);
      return DialogWrapper.CANCEL_EXIT_CODE;
    }
  });

  Pair<String, GitPushResult> remoteTipAndPushResult = forcePushWithReject();
  assertResult(REJECTED, -1, "master", "origin/master", remoteTipAndPushResult.second);
  assertFalse("Rejected push dialog should not be shown", dialogShown.get());
  cd(myParentRepo.getPath());
  assertEquals("The commit pushed from bro should be the last one", remoteTipAndPushResult.first, last());
}
项目:intellij-ce-playground    文件:JBMacMessages.java   
@Override
public int showYesNoCancelDialog(@NotNull String title,
                                 String message,
                                 @NotNull String defaultButton,
                                 String alternateButton,
                                 String otherButton,
                                 @Nullable Window window,
                                 @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  if (window == null) {
    window = getForemostWindow(null);
  }
  SheetMessage sheetMessage = new SheetMessage(window, title, message, UIUtil.getQuestionIcon(),
                                               new String [] {defaultButton, otherButton, alternateButton},
                                               doNotAskOption, defaultButton, alternateButton);

  String resultString = sheetMessage.getResult();
  int result = resultString.equals(defaultButton) ? Messages.YES : resultString.equals(alternateButton) ? Messages.NO : Messages.CANCEL;
  if (doNotAskOption != null) {
      doNotAskOption.setToBeShown(sheetMessage.toBeShown(), result);
  }
  return result;
}
项目:intellij-ce-playground    文件:DialogWrapperPeerImpl.java   
private void disposeFocusTrackbackIfNoChildWindowFocused(@Nullable IdeFocusManager focusManager) {
  if (myFocusTrackback == null) return;

  final DialogWrapper wrapper = myDialogWrapper.get();
  if (wrapper == null || !wrapper.isShowing()) {
    myFocusTrackback.dispose();
    return;
  }

  if (focusManager != null) {
    final Component c = focusManager.getFocusedDescendantFor(wrapper.getContentPane());
    if (c == null) {
      myFocusTrackback.dispose();
    }
  }
  else {
    final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    if (owner == null || !SwingUtilities.isDescendingFrom(owner, wrapper.getContentPane())) {
      myFocusTrackback.dispose();
    }
  }
}
项目:intellij-ce-playground    文件:GitPushOperation.java   
@Nullable
private PushUpdateSettings showDialogAndGetExitCode(@NotNull final Set<GitRepository> repositories,
                                                    @NotNull final PushUpdateSettings initialSettings,
                                                    final boolean rebaseOverMergeProblemDetected) {
  final Ref<PushUpdateSettings> updateSettings = Ref.create();
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      GitRejectedPushUpdateDialog dialog = new GitRejectedPushUpdateDialog(myProject, repositories, initialSettings,
                                                                           rebaseOverMergeProblemDetected);
      DialogManager.show(dialog);
      int exitCode = dialog.getExitCode();
      if (exitCode != DialogWrapper.CANCEL_EXIT_CODE) {
        mySettings.setAutoUpdateIfPushRejected(dialog.shouldAutoUpdateInFuture());
        updateSettings.set(new PushUpdateSettings(dialog.shouldUpdateAll(), convertUpdateMethodFromDialogExitCode(exitCode)));
      }
    }
  });
  return updateSettings.get();
}
项目:intellij-ce-playground    文件:XmlTagRenameDialog.java   
@Override
protected void doAction() {
  LOG.assertTrue(myElement.isValid());

  CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          try {
            myTag.setName(getNewName());
          }
          catch (IncorrectOperationException e) {
            LOG.error(e);
          }
        }
      });
    }
  }, RefactoringBundle.message("rename.title"), null);

  close(DialogWrapper.OK_EXIT_CODE);
}
项目:intellij-ce-playground    文件:GitPushOperationSingleRepoTest.java   
public void test_respect_branch_default_setting_for_rejected_push_dialog() throws IOException {
  generateUpdateNeeded();
  myGitSettings.setUpdateType(UpdateMethod.BRANCH_DEFAULT);
  git("config branch.master.rebase true");

  final Ref<String> defaultActionName = Ref.create();
  myDialogManager.registerDialogHandler(GitRejectedPushUpdateDialog.class, new TestDialogHandler<GitRejectedPushUpdateDialog>() {
    @Override
    public int handleDialog(@NotNull GitRejectedPushUpdateDialog dialog) {
      defaultActionName.set((String)dialog.getDefaultAction().getValue(Action.NAME));
      return DialogWrapper.CANCEL_EXIT_CODE;
    }
  });

  push("master", "origin/master");
  assertTrue("Default action in rejected-push dialog is incorrect: " + defaultActionName.get(),
             defaultActionName.get().toLowerCase().contains("rebase"));

  git("config branch.master.rebase false");
  push("master", "origin/master");
  assertTrue("Default action in rejected-push dialog is incorrect: " + defaultActionName.get(),
             defaultActionName.get().toLowerCase().contains("merge"));
}
项目:react-native-console    文件:RNUpgradeAction.java   
@Override
public boolean beforeAction() {
    String exePath = RNPathUtil.getExecuteFileFullPath(EXEC);

    if (exePath == null || EXEC.equals(RNPathUtil.getExecuteFileFullPath(EXEC))) {
        int options = Messages.showIdeaMessageDialog(getProject(),
                "Would you like to install " + EXEC + " globally now?\n" +
                        "This might take one or two minutes without any console update, please wait for the final result.\n" +
                        "After that, you'll need to click this button again.",
                "Can Not Found " + EXEC, new String[]{"Yes", "No"}, 0,
                AllIcons.General.QuestionDialog, new DialogWrapper.DoNotAskOption.Adapter() {
                    @Override
                    public void rememberChoice(boolean b, int i) {

                    }
                });
        if (options == 0) {
            cmd = INSTALL_CMD;
            return true;
        } else {
            RNConsoleImpl consoleView = terminal.getRNConsole(getText(), getIcon());

            if (consoleView != null) {
                consoleView.clear();
                consoleView.print(
                        "Can't found " + EXEC + ", if you were first running this command, make sure you have " + EXEC + " installed globally.\n" +
                                "To install, please run in terminal with command: \n" +
                                INSTALL_CMD +
                                "\n\n",
                        ConsoleViewContentType.ERROR_OUTPUT);

            }
            return false;
        }

    }

    cmd = EXEC;
    return true;
}
项目:react-native-console    文件:ReactDevToolsAction.java   
@Override
    public boolean beforeAction() {
        String exePath = RNPathUtil.getExecuteFileFullPath(EXEC);
        if (exePath == null || EXEC.equals(RNPathUtil.getExecuteFileFullPath(EXEC))) {
//            GlobalPropertyBasedDoNotAskOption dontAsk = new GlobalPropertyBasedDoNotAskOption("react-devtools.to.show"); // TODO no use so far
            int options = Messages.showIdeaMessageDialog(getProject(),
                    "Would you like to install react-devtools globally now?\n" +
                            "This might take one or two minutes without any console update, please wait for the final result.\n" +
                            "After that, you'll need to click this button again.",
                    "Can Not Found React-Devtools", new String[]{"Yes", "No"}, 0,
                    AllIcons.General.QuestionDialog, new DialogWrapper.DoNotAskOption.Adapter() {
                        @Override
                        public void rememberChoice(boolean b, int i) {

                        }
                    });
            if (options == 0) {
                cmd = "npm install -g react-devtools";
                return true;
            } else {
                RNConsoleImpl consoleView = terminal.getRNConsole(getText(), getIcon());

                if (consoleView != null) {
                    consoleView.clear();
                    consoleView.print(
                            "Can't found " + EXEC + ", if you were first running this command, make sure you have react-devtools installed globally.\n" +
                                    "To install by yourself, please run in terminal with command: \n" +
                                    "npm install -g react-devtools\n\n",
                            ConsoleViewContentType.ERROR_OUTPUT);

                }
                return false;
            }

        }

        cmd = EXEC;
        return true;
    }
项目:JNomad-Plugin    文件:JNomadPluginRegistration.java   
@Override
public void initComponent() {
    ActionManager am = ActionManager.getInstance();
    AnAction action = new AnAction("JNomad Configuration") {
        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            Project project = Objects.requireNonNull(anActionEvent.getData(PlatformDataKeys.PROJECT));
            JNomadConfigurationPanel configPanel = new JNomadConfigurationPanel();
            DialogBuilder builder = new DialogBuilder(project);
            builder.setTitle("JNomad Configuration");
            builder.setCenterPanel(configPanel);
            builder.setOkActionEnabled(true);
            if (configPanel.getPluginConfiguration().getEnvironmentList().isEmpty()) {
                builder.setPreferredFocusComponent(configPanel.getEnvironmentNameTextField());
            } else {
                builder.setPreferredFocusComponent(configPanel.getDatabaseHostTextField());
            }

            if (DialogWrapper.OK_EXIT_CODE == builder.show()) {
                JNomadPluginConfiguration pluginConfiguration = configPanel.getPluginConfiguration();
                pluginConfiguration.setSlowQueryThreshold(configPanel.getSlowQueryThreshold());
                pluginConfiguration.setRecommendIndexThreshold(configPanel.getRecommendIndexThreshold());

                PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
                propertiesComponent.setValue("jnomad.plugin.configuration", new Gson().toJson(pluginConfiguration));
                JNomadInspection.resetJNomadSetup();
            }
        }
    };
    am.registerAction("JNomadPluginAction", action);

    //add to analyze menu
    DefaultActionGroup windowM = (DefaultActionGroup) am.getAction("AnalyzeMenu");
    windowM.addSeparator();
    windowM.add(action);
}
项目:GitCommitMessage    文件:Panel.java   
public DialogWrapper createTemplateDialog(Project project) {
    Template template = new Template(project);

    DialogBuilder builder = new DialogBuilder(project);
    builder.setTitle("Git / Hg Mercurial Commit Message Template.");
    builder.setCenterPanel(template.getMainPanel());
    builder.removeAllActions();
    builder.addOkAction();
    builder.addCancelAction();
    boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE;
    if (isOk) {
        TemplateFileHandler.storeFile(project, template.getTemplateContent());
    }
    return builder.getDialogWrapper();
}
项目:GitCommitMessage    文件:OpenPanelAction.java   
@Override
public void actionPerformed(AnActionEvent actionEvent) {

    final CommitMessageI commitPanel = getCommitPanel(actionEvent);
    if (commitPanel == null)
        return;

    PanelDialog dialog = new PanelDialog(actionEvent.getProject());
    dialog.show();
    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        commitPanel.setCommitMessage(dialog.getCommitMessage(actionEvent.getProject()));
    }

}
项目:hybris-integration-intellij-idea-plugin    文件:PermissionToSendStatisticsDialog.java   
public PermissionToSendStatisticsDialog(@Nullable final Project project) {
    super(project, false, DialogWrapper.IdeModalityType.PROJECT);
    myProject = project;
    setTitle(HybrisI18NBundleUtils.message("hybris.stats.permission.label"));
    setCancelButtonText(HybrisI18NBundleUtils.message("hybris.stats.permission.cancel"));
    permissionToSendStatisticsCheckBox.addItemListener(e -> setOKActionEnabled(e.getStateChange() == ItemEvent.SELECTED));
    init();
}
项目:educational-plugin    文件:StudyTwitterUtils.java   
public static void createTwitterDialogAndShow(@NotNull Project project, 
                                              @NotNull final StudyTwitterPluginConfigurator configurator,
                                              @NotNull Task task) {
  ApplicationManager.getApplication().invokeLater(() -> {
    DialogWrapper.DoNotAskOption doNotAskOption = createDoNotAskOption(project, configurator);
    StudyTwitterUtils.TwitterDialogPanel panel = configurator.getTweetDialogPanel(task);
    if (panel != null) {
      TwitterDialogWrapper wrapper = new TwitterDialogWrapper(project, panel, doNotAskOption);
      wrapper.setDoNotAskOption(doNotAskOption);
      panel.addTextFieldVerifier(createTextFieldLengthDocumentListener(wrapper, panel));

      if (wrapper.showAndGet()) {
        try {
          boolean isAuthorized = !configurator.getTwitterAccessToken(project).isEmpty();
          Twitter twitter = getTwitter(configurator.getConsumerKey(project), configurator.getConsumerSecret(project));
          if (!isAuthorized) {
            authorizeAndUpdateStatus(project, twitter, panel);
          }
          else {
            setAuthInfoInTwitter(twitter, configurator.getTwitterAccessToken(project), configurator.getTwitterTokenSecret(project));
            updateStatus(panel, twitter);
          }
        }
        catch (TwitterException | IOException e) {
          LOG.warn(e.getMessage());
          Messages.showErrorDialog("Status wasn\'t updated. Please, check internet connection and try again", "Twitter");
        }
      }
      else {
        LOG.warn("Panel is null");
      }
    }
  });
}
项目:educational-plugin    文件:StudyTwitterUtils.java   
private static DialogWrapper.DoNotAskOption createDoNotAskOption(@NotNull final Project project,
                                                                 @NotNull final StudyTwitterPluginConfigurator configurator) {
  return new DialogWrapper.DoNotAskOption() {
    @Override
    public boolean isToBeShown() {
      return true;
    }

    @Override
    public void setToBeShown(boolean toBeShown, int exitCode) {
      if (exitCode == DialogWrapper.CANCEL_EXIT_CODE || exitCode == DialogWrapper.OK_EXIT_CODE) {
        configurator.setAskToTweet(project, toBeShown);
      }
    }

    @Override
    public boolean canBeHidden() {
      return true;
    }

    @Override
    public boolean shouldSaveOptionsOnCancel() {
      return true;
    }

    @NotNull
    @Override
    public String getDoNotShowMessage() {
      return "Never ask me to tweet";
    }
  };
}
项目:educational-plugin    文件:CCCreateCourseArchive.java   
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final Module module = e.getData(LangDataKeys.MODULE);
  if (project == null || module == null) {
    return;
  }
  CreateCourseArchiveDialog dlg = new CreateCourseArchiveDialog(project, this);
  dlg.show();
  if (dlg.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
    return;
  }
  createCourseArchive(project, module, myZipName, myLocationDir, true);
  EduUsagesCollector.createdCourseArchive();
}
项目:educational-plugin    文件:CCCreateStudyItemActionBase.java   
@Nullable
protected StudyItem getItem(@NotNull final PsiDirectory sourceDirectory,
                            @NotNull final Project project,
                            @NotNull final Course course,
                            @Nullable IdeView view,
                            @Nullable StudyItem parentItem) {

  String itemName;
  int itemIndex;
  if (isAddedAsLast(sourceDirectory, project, course)) {
    itemIndex = getSiblingsSize(course, parentItem) + 1;
    String suggestedName = getItemName() + itemIndex;
    itemName = view == null ? suggestedName : Messages.showInputDialog("Name:", getTitle(),
                                                                       null, suggestedName, null);
  }
  else {
    StudyItem thresholdItem = getThresholdItem(course, sourceDirectory);
    if (thresholdItem == null) {
      return null;
    }
    final int index = thresholdItem.getIndex();
    CCCreateStudyItemDialog dialog = new CCCreateStudyItemDialog(project, getItemName(), thresholdItem.getName(), index);
    dialog.show();
    if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
      return null;
    }
    itemName = dialog.getName();
    itemIndex = index + dialog.getIndexDelta();
  }
  if (itemName == null) {
    return null;
  }
  return createAndInitItem(course, parentItem, itemName, itemIndex);
}
项目:mule-intellij-plugins    文件:EncryptPropertyAction.java   
@Override
    public void actionPerformed(AnActionEvent anActionEvent)
    {
        final Project project = (Project)anActionEvent.getData(CommonDataKeys.PROJECT);

        PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE);

        IProperty selectedProperty = getSelectedProperty(anActionEvent.getDataContext());
        if (selectedProperty == null)
            return;

        final EncryptDialog form = new EncryptDialog();
        form.setTitle("Encrypt Property: " + selectedProperty.getKey());
        form.show();
        boolean isOk = form.getExitCode() == DialogWrapper.OK_EXIT_CODE;

//        System.out.println("******** IS OK " + isOk);
        logger.debug("**** ALGORITHM " + form.getAlgorithm().getSelectedItem());
        logger.debug("**** MODE " + form.getMode().getSelectedItem());

        if (isOk) {
            new WriteCommandAction.Simple(project, psiFile) {
                @Override
                protected void run() throws Throwable {
                    EncryptionAlgorithm algorithm = (EncryptionAlgorithm) form.getAlgorithm().getSelectedItem();
                    EncryptionMode mode = (EncryptionMode) form.getMode().getSelectedItem();

                    byte[] encryptedBytes = algorithm.getBuilder().forKey(form.getEncryptionKey().getText()).using(mode)
                            .build().encrypt(selectedProperty.getValue().getBytes());
                    StringBuilder result = new StringBuilder();
                    result.append(ENCRYPT_PREFIX);
                    result.append(new String(Base64.encode(encryptedBytes)));
                    result.append(ENCRYPT_SUFFIX);
                    selectedProperty.setValue(result.toString());
                }
            }.execute();
        }
    }
项目:intellij-ce-playground    文件:ConfigureFormFactorStep.java   
private static void showDownloadWizard(IPkgDesc pack) {
  List<IPkgDesc> requestedPackages = Lists.newArrayList(pack);
  SdkQuickfixWizard sdkQuickfixWizard = new SdkQuickfixWizard(null, null, requestedPackages,
                                                              new DialogWrapperHost(null, DialogWrapper.IdeModalityType.PROJECT));
  sdkQuickfixWizard.init();
  sdkQuickfixWizard.show();
}
项目:ADB-Duang    文件:BaseAction.java   
private static DeviceResult askUserForDevice(AnActionEvent anActionEvent, AndroidFacet facet, String packageName) {
    final DeviceChooserDialog chooser = new DeviceChooserDialog(facet);
    chooser.show();

    if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
        return null;
    }

    IDevice[] selectedDevices = chooser.getSelectedDevices();
    if (selectedDevices.length == 0) {
        return null;
    }

    return new DeviceResult(anActionEvent, selectedDevices[0], facet, packageName);
}
项目:PackageTemplates    文件:BaseDialog.java   
@Override
public void show() {
    preShow();
    super.show();

    switch (getExitCode()) {
        case DialogWrapper.OK_EXIT_CODE:
            onOKAction();
            break;
        case DialogWrapper.CANCEL_EXIT_CODE:
            onCancelAction();
            break;
    }
}
项目:PackageTemplates    文件:SelectPackageTemplateDialog.java   
@Override
public void show() {
    super.show();

    switch (getExitCode()) {
        case DialogWrapper.OK_EXIT_CODE:
            presenter.onSuccess(PackageTemplateHelper.getPackageTemplate(getSelectedPath()));
            break;
        case DialogWrapper.CANCEL_EXIT_CODE:
            presenter.onCancel();
            break;
    }
}
项目:intellij-ce-playground    文件:CCCreateStudyItemActionBase.java   
@Nullable
protected StudyItem getItem(@NotNull final PsiDirectory sourceDirectory,
                            @NotNull final Project project,
                            @NotNull final Course course,
                            @Nullable IdeView view,
                            @Nullable StudyItem parentItem) {

  String itemName;
  int itemIndex;
  if (isAddedAsLast(sourceDirectory, project, course)) {
    itemIndex = getSiblingsSize(course, parentItem) + 1;
    String suggestedName = getItemName() + itemIndex;
    itemName = view == null ? suggestedName : Messages.showInputDialog("Name:", getTitle(),
                                                                       null, suggestedName, null);
  }
  else {
    StudyItem thresholdItem = getThresholdItem(course, sourceDirectory);
    if (thresholdItem == null) {
      return null;
    }
    final int index = thresholdItem.getIndex();
    CCCreateStudyItemDialog dialog = new CCCreateStudyItemDialog(project, getItemName(), thresholdItem.getName(), index);
    dialog.show();
    if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
      return null;
    }
    itemName = dialog.getName();
    itemIndex = index + dialog.getIndexDelta();
  }
  if (itemName == null) {
    return null;
  }
  return createAndInitItem(course, parentItem, itemName, itemIndex);
}
项目:intellij-ce-playground    文件:ColorPicker.java   
@Nullable
public static Color showDialog(@NotNull Component parent,
                               String caption,
                               Color preselectedColor,
                               boolean enableOpacity,
                               List<ColorPickerListener> listeners,
                               boolean opacityInPercent) {
  final ColorPickerDialog dialog = new ColorPickerDialog(parent, caption, preselectedColor, enableOpacity, listeners, opacityInPercent);
  dialog.show();
  if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
    return dialog.getColor();
  }

  return null;
}
项目:intellij-ce-playground    文件:PsiElementRenameHandler.java   
public static void rename(PsiElement element, final Project project, PsiElement nameSuggestionContext, Editor editor, String defaultName) {
  RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(element);
  PsiElement substituted = processor.substituteElementToRename(element, editor);
  if (substituted == null || !canRename(project, editor, substituted)) return;

  RenameDialog dialog = processor.createRenameDialog(project, substituted, nameSuggestionContext, editor);

  if (defaultName == null && ApplicationManager.getApplication().isUnitTestMode()) {
    String[] strings = dialog.getSuggestedNames();
    if (strings != null && strings.length > 0) {
      Arrays.sort(strings);
      defaultName = strings[0];
    } else {
      defaultName = "undefined"; // need to avoid show dialog in test
    }
  }

  if (defaultName != null) {
    try {
      dialog.performRename(defaultName);
    }
    finally {
      dialog.close(DialogWrapper.CANCEL_EXIT_CODE); // to avoid dialog leak
    }
  }
  else {
    dialog.show();
  }
}
项目:intellij-ce-playground    文件:ForceEarlyReturnAction.java   
private static void forceEarlyReturnWithFinally(final Value value,
                                                final JavaStackFrame frame,
                                                final DebugProcessImpl debugProcess,
                                                @Nullable final DialogWrapper dialog) {
  //noinspection SSBasedInspection
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      if (PopFrameAction.evaluateFinallyBlocks(debugProcess.getProject(),
                                               UIUtil.removeMnemonic(ActionsBundle.actionText("Debugger.ForceEarlyReturn")),
                                               frame,
                                               new XDebuggerEvaluator.XEvaluationCallback() {
                                                 @Override
                                                 public void evaluated(@NotNull XValue result) {
                                                   forceEarlyReturn(value, frame.getDescriptor().getFrameProxy().threadProxy(), debugProcess, dialog);
                                                 }

                                                 @Override
                                                 public void errorOccurred(@NotNull String errorMessage) {
                                                   showError(debugProcess.getProject(),
                                                             DebuggerBundle.message("error.executing.finally", errorMessage));
                                                 }
                                               })) {
        return;
      }
      forceEarlyReturn(value, frame.getDescriptor().getFrameProxy().threadProxy(), debugProcess, dialog);
    }
  });
}
项目:intellij-ce-playground    文件:ForceEarlyReturnAction.java   
private static void forceEarlyReturn(final Value value,
                                     final ThreadReferenceProxyImpl thread,
                                     final DebugProcessImpl debugProcess,
                                     @Nullable final DialogWrapper dialog) {
  debugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {
    @Override
    protected void action() throws Exception {
      try {
        thread.forceEarlyReturn(value);
      }
      catch (Exception e) {
        showError(debugProcess.getProject(), DebuggerBundle.message("error.early.return", e.getLocalizedMessage()));
        return;
      }
      //noinspection SSBasedInspection
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          if (dialog != null) {
            dialog.close(DialogWrapper.OK_EXIT_CODE);
          }
          debugProcess.getSession().stepInto(true, null);
        }
      });
    }
  });
}
项目:intellij-ce-playground    文件:DvcsTaskHandler.java   
@Override
public TaskInfo startNewTask(@NotNull final String taskName) {
  List<R> repositories = myRepositoryManager.getRepositories();
  List<R> problems = ContainerUtil.filter(repositories, new Condition<R>() {
    @Override
    public boolean value(R repository) {
      return hasBranch(repository, taskName);
    }
  });
  List<R> map = new ArrayList<R>();
  if (!problems.isEmpty()) {
    if (ApplicationManager.getApplication().isUnitTestMode() ||
        Messages.showDialog(myProject,
                            "<html>The following repositories already have specified " + myBranchType + "<b>" + taskName + "</b>:<br>" +
                            StringUtil.join(problems, "<br>") + ".<br>" +
                            "Do you want to checkout existing " + myBranchType + "?", StringUtil.capitalize(myBranchType) + " Already Exists",
                            new String[]{Messages.YES_BUTTON, Messages.NO_BUTTON}, 0,
                            Messages.getWarningIcon(), new DialogWrapper.PropertyDoNotAskOption("git.checkout.existing.branch")) == 0) {
      checkout(taskName, problems, null);
      map.addAll(problems);
    }
  }
  repositories.removeAll(problems);
  if (!repositories.isEmpty()) {
    checkoutAsNewBranch(taskName, repositories);
  }

  map.addAll(repositories);
  return new TaskInfo(taskName, ContainerUtil.map(map, new Function<R, String>() {
    @Override
    public String fun(R r) {
      return r.getPresentableUrl();
    }
  }));
}