com.intellij.refactoring.ui.NameSuggestionsField Java Examples

The following examples show how to use com.intellij.refactoring.ui.NameSuggestionsField. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenameDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void createNewNameComponent() {
  String[] suggestedNames = getSuggestedNames();
  myOldName = UsageViewUtil.getShortName(myPsiElement);
  myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, PlainTextFileType.INSTANCE, myEditor) {
    @Override
    protected boolean shouldSelectAll() {
      return myEditor == null || myEditor.getSettings().isPreselectRename();
    }
  };
  if (myPsiElement instanceof PsiFile && myEditor == null) {
    myNameSuggestionsField.selectNameWithoutExtension();
  }
  myNameChangedListener = new NameSuggestionsField.DataChanged() {
    @Override
    public void dataChanged() {
      processNewNameChanged();
    }
  };
  myNameSuggestionsField.addDataChangedListener(myNameChangedListener);

}
 
Example #2
Source File: FlowRenameDialog.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
private void createNewNameComponent() {
    String flowName = this.myTag.getAttribute("name").getValue();
    this.myNameSuggestionsField = new NameSuggestionsField(new String[]{ flowName }, this.myProject, FileTypes.PLAIN_TEXT, this.myEditor);
    this.myNameChangedListener = new NameSuggestionsField.DataChanged() {
        public void dataChanged() {
            FlowRenameDialog.this.validateButtons();
        }
    };
    this.myNameSuggestionsField.addDataChangedListener(this.myNameChangedListener);
    this.myNameSuggestionsField.getComponent().registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FlowRenameDialog.this.completeVariable(FlowRenameDialog.this.myNameSuggestionsField.getEditor());
        }
    }, KeyStroke.getKeyStroke(32, 2), 2);
}
 
Example #3
Source File: IntroduceVariableDialog.java    From CppTools with Apache License 2.0 5 votes vote down vote up
static void setupNameValidation(final Project project, final NameSuggestionsField myNewVarName, final Action okAction) {
  final NameSuggestionsField.DataChanged dataChangedListener = new NameSuggestionsField.DataChanged() {
    public void dataChanged() {
      final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(CppSupportLoader.CPP_FILETYPE.getLanguage());
      okAction.setEnabled(
        namesValidator.isIdentifier(myNewVarName.getEnteredName(), project)
      );
    }
  };
  myNewVarName.addDataChangedListener(dataChangedListener);
  dataChangedListener.dataChanged();
}
 
Example #4
Source File: IntroduceVariableDialog.java    From CppTools with Apache License 2.0 5 votes vote down vote up
private void createUIComponents() {
  myNewVarName = new NameSuggestionsField(
    calcVariants(),
    (Project) DataManager.getInstance().getDataContext().getData(DataConstants.PROJECT),
    CppSupportLoader.CPP_FILETYPE
  );
}
 
Example #5
Source File: ExtractFunctionDialog.java    From CppTools with Apache License 2.0 5 votes vote down vote up
private void createUIComponents() {
  functionMethodNameTextField = new NameSuggestionsField(
    new String[] {"fun"},
    (Project) DataManager.getInstance().getDataContext().getData(DataConstants.PROJECT),
    CppSupportLoader.CPP_FILETYPE
  );
}
 
Example #6
Source File: RenameDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected NameSuggestionsField getNameSuggestionsField() {
  return myNameSuggestionsField;
}