@Nullable
  private MoveDestination selectDestination() {
    final String packageName = getTargetPackage().trim();
    if (packageName.length() > 0
        && !JavaPsiFacade.getInstance(myManager.getProject())
            .getNameHelper()
            .isQualifiedName(packageName)) {
      Messages.showErrorDialog(
          myProject,
          RefactoringBundle.message("please.enter.a.valid.target.package.name"),
          RefactoringBundle.message("move.title"));
      return null;
    }
    RecentsManager.getInstance(myProject).registerRecentEntry(RECENTS_KEY, packageName);
    PackageWrapper targetPackage = new PackageWrapper(myManager, packageName);
    if (!targetPackage.exists()) {
      final int ret =
          Messages.showYesNoDialog(
              myProject,
              RefactoringBundle.message("package.does.not.exist", packageName),
              RefactoringBundle.message("move.title"),
              Messages.getQuestionIcon());
      if (ret != 0) return null;
    }

    return ((DestinationFolderComboBox) myDestinationFolderCB).selectDirectory(targetPackage, true);
  }
  protected void doOKAction() {
    // myTargetDirectoryField.getChildComponent().addCurrentTextToHistory();
    RecentsManager.getInstance(myProject)
        .registerRecentEntry(RECENT_KEYS, myTargetDirectoryField.getChildComponent().getText());
    RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE =
        myCbSearchForReferences.isSelected();
    CommandProcessor.getInstance()
        .executeCommand(
            myProject,
            new Runnable() {
              public void run() {
                final Runnable action =
                    new Runnable() {
                      public void run() {
                        String directoryName =
                            myTargetDirectoryField
                                .getChildComponent()
                                .getText()
                                .replace(File.separatorChar, '/');
                        try {
                          myTargetDirectory =
                              DirectoryUtil.mkdirs(
                                  PsiManager.getInstance(myProject), directoryName);
                        } catch (IncorrectOperationException e) {
                          // ignore
                        }
                      }
                    };

                ApplicationManager.getApplication().runWriteAction(action);
                if (myTargetDirectory == null) {
                  CommonRefactoringUtil.showErrorMessage(
                      getTitle(),
                      RefactoringBundle.message("cannot.create.directory"),
                      myHelpID,
                      myProject);
                  return;
                }
                myCallback.run(MoveFilesOrDirectoriesDialog.this);
              }
            },
            RefactoringBundle.message("move.title"),
            null);
  }
  protected JComponent createNorthPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    final GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(0, 2, 0, 0);

    myNameLabel = new JLabel();
    panel.add(myNameLabel, c);
    c.insets.top = 10;
    c.gridy++;
    panel.add(new JLabel(RefactoringBundle.message("move.files.to.directory.label")), c);
    c.insets.top = 0;

    myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton();
    final List<String> recentEntries =
        RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS);
    if (recentEntries != null) {
      myTargetDirectoryField.getChildComponent().setHistory(recentEntries);
    }
    final FileChooserDescriptor descriptor =
        FileChooserDescriptorFactory.createSingleFolderDescriptor();
    myTargetDirectoryField.addBrowseFolderListener(
        RefactoringBundle.message("select.target.directory"),
        RefactoringBundle.message("the.file.will.be.moved.to.this.directory"),
        myProject,
        descriptor,
        TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);
    final JTextField textField = myTargetDirectoryField.getChildComponent().getTextEditor();
    FileChooserFactory.getInstance()
        .installFileCompletion(textField, descriptor, true, getDisposable());
    myTargetDirectoryField.setTextFieldPreferredWidth(60);
    c.insets.left = 0;
    c.gridy++;
    panel.add(myTargetDirectoryField, c);
    String shortcutText =
        KeymapUtil.getFirstKeyboardShortcutText(
            ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION));
    final JLabel label =
        new JLabel(RefactoringBundle.message("path.completion.shortcut", shortcutText));
    UIUtil.applyStyle(UIUtil.ComponentStyle.MINI, label);
    c.insets.left = 6;
    c.gridy++;
    panel.add(label, c);

    myCbSearchForReferences =
        new NonFocusableCheckBox(RefactoringBundle.message("search.for.references"));
    myCbSearchForReferences.setSelected(
        RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE);
    c.insets.top = 10;
    c.insets.left = 0;
    c.gridy++;
    panel.add(myCbSearchForReferences, c);

    textField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              protected void textChanged(DocumentEvent e) {
                validateOKButton();
              }
            });
    Disposer.register(getDisposable(), myTargetDirectoryField);

    return panel;
  }