void (@NotNull AnActionEvent event) { DataContext dataContext = event.getDataContext(); MethodHierarchyBrowser methodHierarchyBrowser = getMethodHierarchyBrowser(event); if (methodHierarchyBrowser == null) return; Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) return; String commandName = event.getPresentation().getText(); ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(project, () -> { try{ HierarchyNodeDescriptor[] selectedDescriptors = methodHierarchyBrowser.getSelectedDescriptors(); if (selectedDescriptors.length > 0) { List<VirtualFile> files = new ArrayList<>(selectedDescriptors.length); for (HierarchyNodeDescriptor selectedDescriptor : selectedDescriptors) { PsiFile containingFile = ((MethodHierarchyNodeDescriptor)selectedDescriptor).getPsiClass().getContainingFile(); if (containingFile != null) { VirtualFile vFile = containingFile.getVirtualFile(); if (vFile != null) { files.add(vFile); } } } ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); if (!status.hasReadonlyFiles()) { for (HierarchyNodeDescriptor selectedDescriptor : selectedDescriptors) { PsiElement aClass = ((MethodHierarchyNodeDescriptor)selectedDescriptor).getPsiClass(); if (aClass instanceof PsiClass) { OverrideImplementUtil.overrideOrImplement((PsiClass)aClass, methodHierarchyBrowser.getBaseMethod()); } } ToolWindowManager.getInstance(project).activateEditorComponent(); } else { ApplicationManager.getApplication().invokeLater( () -> Messages.showErrorDialog(project, status.getReadonlyFilesMessage(), commandName)); } } } catch(IncorrectOperationException e){ LOG.error(e); } }, commandName, null)); }