コード例 #1
0
  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);
  }
コード例 #2
0
  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;
  }
コード例 #3
0
 public void setToSearchForTextOccurrences(final PsiElement element, boolean enabled) {
   if (element instanceof PsiFileSystemItem) {
     RefactoringSettings.getInstance().RENAME_SEARCH_FOR_TEXT_FOR_FILE = enabled;
   }
 }
コード例 #4
0
 public boolean isToSearchForTextOccurrences(final PsiElement element) {
   return element instanceof PsiFileSystemItem
       && RefactoringSettings.getInstance().RENAME_SEARCH_FOR_TEXT_FOR_FILE;
 }
コード例 #5
0
 public void setToSearchInComments(final PsiElement element, boolean enabled) {
   if (element instanceof PsiFileSystemItem) {
     RefactoringSettings.getInstance().RENAME_SEARCH_IN_COMMENTS_FOR_FILE = enabled;
   }
 }
コード例 #6
0
 public boolean isToSearchInComments(final PsiElement element) {
   return element instanceof PsiFileSystemItem
       && RefactoringSettings.getInstance().RENAME_SEARCH_IN_COMMENTS_FOR_FILE;
 }