JComponent () { myTypeSelector = myTypeSelectorManager.getTypeSelector(); myTypePanel.setLayout(new BorderLayout()); myTypePanel.add(myTypeSelector.getComponent(), BorderLayout.CENTER); if (myTypeSelector.getFocusableComponent() != null) { myTypeLabel.setLabelFor(myTypeSelector.getFocusableComponent()); } myNameField = new NameSuggestionsField(myProject); myNameSuggestionPanel.setLayout(new BorderLayout()); myNameField.addDataChangedListener(() -> updateButtons()); myNameSuggestionPanel.add(myNameField.getComponent(), BorderLayout.CENTER); myNameSuggestionLabel.setLabelFor(myNameField.getFocusableComponent()); Set<String> possibleClassNames = new LinkedHashSet<>(); for (final PsiExpression occurrence : myOccurrences) { final PsiClass parentClass = new IntroduceConstantHandler().getParentClass(occurrence); if (parentClass != null && parentClass.getQualifiedName() != null) { possibleClassNames.add(parentClass.getQualifiedName()); } } myTfTargetClassName = new ReferenceEditorComboWithBrowseButton(new ChooseClassAction(), "", myProject, true, JavaCodeFragment.VisibilityChecker.PROJECT_SCOPE_VISIBLE, RECENTS_KEY); myTargetClassNamePanel.setLayout(new BorderLayout()); myTargetClassNamePanel.add(myTfTargetClassName, BorderLayout.CENTER); myTargetClassNameLabel.setLabelFor(myTfTargetClassName); for (String possibleClassName : possibleClassNames) { myTfTargetClassName.prependItem(possibleClassName); } myTfTargetClassName.getChildComponent().setSelectedItem(myParentClass.getQualifiedName()); myTfTargetClassName.getChildComponent().addDocumentListener(new DocumentListener() { @Override public void documentChanged(@NotNull DocumentEvent e) { targetClassChanged(); enableEnumDependant(introduceEnumConstant()); } }); myIntroduceEnumConstantCb.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { enableEnumDependant(introduceEnumConstant()); } }); final JPanel enumPanel = new JPanel(new BorderLayout()); enumPanel.add(myIntroduceEnumConstantCb, BorderLayout.EAST); myTargetClassNamePanel.add(enumPanel, BorderLayout.SOUTH); final String propertyName; if (myLocalVariable != null) { propertyName = myCodeStyleManager.variableNameToPropertyName(myLocalVariable.getName(), VariableKind.LOCAL_VARIABLE); } else { propertyName = null; } myNameSuggestionsManager = new NameSuggestionsManager(myTypeSelector, myNameField, createNameSuggestionGenerator(propertyName, myInitializerExpression, myCodeStyleManager, myEnteredName, myParentClass)); myNameSuggestionsManager.setLabelsFor(myTypeLabel, myNameSuggestionLabel); ////////// if (myOccurrencesCount > 1) { myCbReplaceAll.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateTypeSelector(); myNameField.requestFocusInWindow(); } }); myCbReplaceAll.setText(RefactoringBundle.message("replace.all.occurences", myOccurrencesCount)); myCbReplaceAll.setSelected(JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_REPLACE_ALL); } else { myCbReplaceAll.setVisible(false); } if (myLocalVariable != null) { if (myInvokedOnDeclaration) { myCbDeleteVariable.setEnabled(false); myCbDeleteVariable.setSelected(true); } else if (myCbReplaceAll != null) { updateCbDeleteVariable(); myCbReplaceAll.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateCbDeleteVariable(); } }); } } else { myCbDeleteVariable.setVisible(false); } if ((myTypeSelectorManager.isSuggestedType(CommonClassNames.JAVA_LANG_STRING) || (myLocalVariable != null && AnnotationUtil.isAnnotated(myLocalVariable, AnnotationUtil.NON_NLS, CHECK_EXTERNAL))) && LanguageLevelProjectExtension.getInstance(myProject).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5) && JavaPsiFacade.getInstance(myProject).findClass(AnnotationUtil.NON_NLS, myParentClass.getResolveScope()) != null) { final PropertiesComponent component = PropertiesComponent.getInstance(myProject); myCbNonNls.setSelected(component.getBoolean(NONNLS_SELECTED_PROPERTY)); myCbNonNls.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { component.setValue(NONNLS_SELECTED_PROPERTY, myCbNonNls.isSelected()); } }); } else { myCbNonNls.setVisible(false); } updateTypeSelector(); enableEnumDependant(introduceEnumConstant()); return myPanel; }