コード例 #1
0
 private void updateControlsEnabled() {
   myClassPackageChooser.setEnabled(myToPackageRadioButton.isSelected());
   myInnerClassChooser.setEnabled(myMakeInnerClassOfRadioButton.isSelected());
   UIUtil.setEnabled(
       myTargetPanel,
       isMoveToPackage() && getSourceRoots().length > 1 && !myTargetDirectoryFixed,
       true);
   validateButtons();
 }
コード例 #2
0
  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();
          }
        });
  }
コード例 #3
0
  private void createUIComponents() {
    myMainPanel = new JPanel();

    myWithBrowseButtonReference = createPackageChooser();
    myClassPackageChooser = createPackageChooser();

    myInnerClassChooser =
        new ClassNameReferenceEditor(
            PsiManager.getInstance(myProject), null, ProjectScope.getProjectScope(myProject));
    myInnerClassChooser.addDocumentListener(
        new DocumentAdapter() {
          public void documentChanged(DocumentEvent e) {
            validateButtons();
          }
        });

    // override CardLayout sizing behavior
    myCardPanel =
        new JPanel() {
          public Dimension getMinimumSize() {
            return myHavePackages
                ? myMovePackagePanel.getMinimumSize()
                : myMoveClassPanel.getMinimumSize();
          }

          public Dimension getPreferredSize() {
            return myHavePackages
                ? myMovePackagePanel.getPreferredSize()
                : myMoveClassPanel.getPreferredSize();
          }
        };

    myDestinationFolderCB =
        new DestinationFolderComboBox() {
          @Override
          public String getTargetPackage() {
            return MoveClassesOrPackagesDialog.this.getTargetPackage();
          }
        };
  }
コード例 #4
0
 @Nullable
 private PsiClass findTargetClass() {
   String name = myInnerClassChooser.getText().trim();
   return JavaPsiFacade.getInstance(myManager.getProject())
       .findClass(name, ProjectScope.getProjectScope(myProject));
 }