AnAction (final Project project, final Factory<? extends BaseInjection> producer) { return new AnAction() { @Override public void actionPerformed(@NotNull final AnActionEvent e) { final BaseInjection originalInjection = producer.create(); final BaseInjection injection = createFrom(originalInjection); if (injection != null) { final BaseInjection newInjection = showInjectionUI(project, injection); if (newInjection != null) { originalInjection.copyFrom(newInjection); } } else { perform(project, producer); } } }; }