@Override protected void doOKAction() { String answerPlaceholderText = myPanel.getAnswerPlaceholderText(); myAnswerPlaceholder.setTaskText(StringUtil.notNullize(answerPlaceholderText)); myAnswerPlaceholder.setLength(StringUtil.notNullize(answerPlaceholderText).length()); final List<String> hints = myPanel.getHints(); if (hints.size() == 1 && hints.get(0).isEmpty()) { myAnswerPlaceholder.setHints(Collections.emptyList()); } else { myAnswerPlaceholder.setHints(hints); } super.doOKAction(); }
public CCCreateAnswerPlaceholderDialog( @NotNull final Project project, @NotNull final AnswerPlaceholder answerPlaceholder) { super(project, true); setTitle(ourTitle); myAnswerPlaceholder = answerPlaceholder; myPanel = new CCCreateAnswerPlaceholderPanel(); if (!answerPlaceholder.getHints().isEmpty()) { setHintText(answerPlaceholder); } myProject = project; String answerPlaceholderTaskText = answerPlaceholder.getTaskText(); myPanel.setAnswerPlaceholderText( answerPlaceholderTaskText != null ? answerPlaceholderTaskText : ""); init(); initValidation(); }
@Nullable @Override public JComponent getPreferredFocusedComponent() { return myPanel.getPreferredFocusedComponent(); }
@Nullable @Override public ValidationInfo doValidate() { return !myPanel.getHints().isEmpty() ? null : new ValidationInfo("Type hint"); }
@Nullable @Override protected JComponent createCenterPanel() { return myPanel.getMailPanel(); }
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") private void setHintText(AnswerPlaceholder answerPlaceholder) { List<String> hintTexts = answerPlaceholder.getHints(); myPanel.setHintText(hintTexts.get(0)); myPanel.setHints(hintTexts); }