JComponent () { sourceMethodTextField.setEditable(false); final DocumentListener docListener = new DocumentAdapter() { @Override protected void textChanged(@NotNull final DocumentEvent e) { validateButtons(); } }; classNameField.getDocument().addDocumentListener(docListener); myFieldsCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { validateButtons(); } }); myInnerClassNameTextField.getDocument().addDocumentListener(docListener); final PsiFile file = sourceMethod.getContainingFile(); if (file instanceof PsiJavaFile) { final String packageName = ((PsiJavaFile)file).getPackageName(); packageTextField.setText(packageName); } final PsiClass containingClass = sourceMethod.getContainingClass(); assert containingClass != null : sourceMethod; final String containingClassName = containingClass instanceof PsiAnonymousClass ? JavaBundle.message("wrap.return.value.anonymous.class.presentation", ((PsiAnonymousClass)containingClass).getBaseClassType().getClassName()) : containingClass.getName(); final String sourceMethodName = sourceMethod.getName(); sourceMethodTextField.setText(containingClassName + '.' + sourceMethodName); final ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(useExistingClassButton); buttonGroup.add(createNewClassButton); buttonGroup.add(myCreateInnerClassButton); createNewClassButton.setSelected(true); final ActionListener enableListener = new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { toggleRadioEnablement(); } }; useExistingClassButton.addActionListener(enableListener); createNewClassButton.addActionListener(enableListener); myCreateInnerClassButton.addActionListener(enableListener); toggleRadioEnablement(); final DefaultComboBoxModel<PsiField> model = new DefaultComboBoxModel<>(); myFieldsCombo.setModel(model); myFieldsCombo.setRenderer(SimpleListCellRenderer.create((label, field, index) -> { if (field != null) { label.setText(field.getName()); label.setIcon(field.getIcon(Iconable.ICON_FLAG_VISIBILITY)); } })); existingClassField.getChildComponent().getDocument().addDocumentListener(new com.intellij.openapi.editor.event.DocumentListener() { @Override public void documentChanged(@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { final JavaPsiFacade facade = JavaPsiFacade.getInstance(myProject); final PsiClass currentClass = facade.findClass(existingClassField.getText(), GlobalSearchScope.allScope(myProject)); if (currentClass != null) { model.removeAllElements(); final PsiType returnType = sourceMethod.getReturnType(); assert returnType != null; for (PsiField field : currentClass.getFields()) { final PsiType fieldType = field.getType(); if (TypeConversionUtil.isAssignable(fieldType, returnType)) { model.addElement(field); } else { if (WrapReturnValueProcessor.getInferredType(fieldType, returnType, currentClass, sourceMethod) != null) { model.addElement(field); } } } } } }); return myWholePanel; }