private ReferenceEditorComboWithBrowseButton createPackageChooser() {
    final ReferenceEditorComboWithBrowseButton packageChooser =
        new PackageNameReferenceEditorCombo(
            "", myProject, RECENTS_KEY, RefactoringBundle.message("choose.destination.package"));
    final Document document = packageChooser.getChildComponent().getDocument();
    document.addDocumentListener(
        new DocumentAdapter() {
          public void documentChanged(DocumentEvent e) {
            validateButtons();
          }
        });

    return packageChooser;
  }
 private void updateControlsEnabled() {
   myClassPackageChooser.setEnabled(myToPackageRadioButton.isSelected());
   myInnerClassChooser.setEnabled(myMakeInnerClassOfRadioButton.isSelected());
   UIUtil.setEnabled(
       myTargetPanel,
       isMoveToPackage() && getSourceRoots().length > 1 && !myTargetDirectoryFixed,
       true);
   validateButtons();
 }
  public MoveClassesOrPackagesDialog(
      Project project,
      boolean searchTextOccurences,
      PsiElement[] elementsToMove,
      final PsiElement initialTargetElement,
      MoveCallback moveCallback) {
    super(project, true);
    myElementsToMove = elementsToMove;
    myMoveCallback = moveCallback;
    myManager = PsiManager.getInstance(myProject);
    setTitle(MoveHandler.REFACTORING_NAME);
    mySearchTextOccurencesEnabled = searchTextOccurences;

    selectInitialCard();

    init();

    if (initialTargetElement instanceof PsiClass) {
      myMakeInnerClassOfRadioButton.setSelected(true);

      myInnerClassChooser.setText(((PsiClass) initialTargetElement).getQualifiedName());

      ApplicationManager.getApplication()
          .invokeLater(
              new Runnable() {
                public void run() {
                  myInnerClassChooser.requestFocus();
                }
              },
              ModalityState.stateForComponent(myMainPanel));
    } else if (initialTargetElement instanceof PsiPackage) {
      myClassPackageChooser.setText(((PsiPackage) initialTargetElement).getQualifiedName());
    }

    updateControlsEnabled();
    myToPackageRadioButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateControlsEnabled();
            myClassPackageChooser.requestFocus();
          }
        });
    myMakeInnerClassOfRadioButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateControlsEnabled();
            myInnerClassChooser.requestFocus();
          }
        });
  }
 protected String getTargetPackage() {
   return myHavePackages ? myWithBrowseButtonReference.getText() : myClassPackageChooser.getText();
 }
  public void setData(
      PsiElement[] psiElements,
      String targetPackageName,
      final PsiDirectory initialTargetDirectory,
      boolean isTargetDirectoryFixed,
      boolean searchInComments,
      boolean searchForTextOccurences,
      String helpID) {
    myInitialTargetDirectory = initialTargetDirectory;
    myTargetDirectoryFixed = isTargetDirectoryFixed;
    if (targetPackageName.length() != 0) {
      myWithBrowseButtonReference.prependItem(targetPackageName);
      myClassPackageChooser.prependItem(targetPackageName);
    }

    String nameFromCallback =
        myMoveCallback instanceof MoveClassesOrPackagesCallback
            ? ((MoveClassesOrPackagesCallback) myMoveCallback).getElementsToMoveName()
            : null;
    if (nameFromCallback != null) {
      myNameLabel.setText(nameFromCallback);
    } else if (psiElements.length == 1) {
      PsiElement firstElement = psiElements[0];
      if (firstElement instanceof PsiClass) {
        LOG.assertTrue(!MoveClassesOrPackagesImpl.isClassInnerOrLocal((PsiClass) firstElement));
      } else {
        PsiElement parent = firstElement.getParent();
        LOG.assertTrue(parent != null);
      }
      myNameLabel.setText(
          RefactoringBundle.message(
              "move.single.class.or.package.name.label",
              UsageViewUtil.getType(firstElement),
              UsageViewUtil.getLongName(firstElement)));
    } else if (psiElements.length > 1) {
      myNameLabel.setText(
          psiElements[0] instanceof PsiClass
              ? RefactoringBundle.message("move.specified.classes")
              : RefactoringBundle.message("move.specified.packages"));
    }
    selectInitialCard();

    myCbSearchInComments.setSelected(searchInComments);
    myCbSearchTextOccurences.setSelected(searchForTextOccurences);

    ((DestinationFolderComboBox) myDestinationFolderCB)
        .setData(
            myProject,
            myInitialTargetDirectory,
            new Pass<String>() {
              @Override
              public void pass(String s) {
                setErrorText(s);
              }
            },
            myClassPackageChooser.getChildComponent());
    UIUtil.setEnabled(
        myTargetPanel,
        getSourceRoots().length > 0 && isMoveToPackage() && !isTargetDirectoryFixed,
        true);
    validateButtons();
    myHelpID = helpID;
  }
 public JComponent getPreferredFocusedComponent() {
   return myHavePackages
       ? myWithBrowseButtonReference.getChildComponent()
       : myClassPackageChooser.getChildComponent();
 }