@Override
  public void invoke(
      @NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
    ResourceBundleEditor bundleEditor = ResourceBundleUtil.getEditor(dataContext);
    if (bundleEditor == null) {
      return;
    }

    String propertyName = bundleEditor.getState(FileEditorStateLevel.NAVIGATION).getPropertyName();
    if (propertyName == null) {
      return;
    }

    ResourceBundle bundle = ResourceBundleUtil.getResourceBundleFromDataContext(dataContext);
    if (bundle == null) {
      return;
    }
    Messages.showInputDialog(
        project,
        PropertiesBundle.message("rename.bundle.enter.new.resource.bundle.key.name.prompt.text"),
        PropertiesBundle.message("rename.resource.bundle.key.dialog.title"),
        Messages.getQuestionIcon(),
        propertyName,
        new ResourceBundleKeyRenameValidator(project, bundleEditor, bundle, propertyName));
  }
 @Override
 public void invoke(
     final @NotNull Project project, Editor editor, final PsiFile file, DataContext dataContext) {
   final ResourceBundleEditor resourceBundleEditor =
       (ResourceBundleEditor) PlatformDataKeys.FILE_EDITOR.getData(dataContext);
   assert resourceBundleEditor != null;
   final ResourceBundleEditorViewElement selectedElement =
       resourceBundleEditor.getSelectedElementIfOnlyOne();
   if (selectedElement != null) {
     CommandProcessor.getInstance()
         .runUndoTransparentAction(
             () -> {
               if (selectedElement instanceof PropertiesPrefixGroup) {
                 final PropertiesPrefixGroup group = (PropertiesPrefixGroup) selectedElement;
                 ResourceBundleRenameUtil.renameResourceBundleKeySection(
                     getPsiElementsFromGroup(group),
                     group.getPresentableName(),
                     group.getPrefix().length() - group.getPresentableName().length());
               } else if (selectedElement instanceof ResourceBundlePropertyStructureViewElement) {
                 final PsiElement psiElement =
                     ((ResourceBundlePropertyStructureViewElement) selectedElement)
                         .getProperty()
                         .getPsiElement();
                 ResourceBundleRenameUtil.renameResourceBundleKey(psiElement, project);
               } else if (selectedElement instanceof ResourceBundleFileStructureViewElement) {
                 ResourceBundleRenameUtil.renameResourceBundleBaseName(
                     ((ResourceBundleFileStructureViewElement) selectedElement).getValue(),
                     project);
               } else {
                 throw new IllegalStateException(
                     "unsupported type: " + selectedElement.getClass());
               }
             });
   }
 }
 @Override
 public boolean isAvailableOnDataContext(DataContext dataContext) {
   ResourceBundleEditor editor = ResourceBundleUtil.getEditor(dataContext);
   if (editor == null) {
     return false;
   }
   return editor.getState(FileEditorStateLevel.NAVIGATION).getPropertyName() != null;
 }