use of com.intellij.refactoring.ui.NameSuggestionsField in project intellij-community by JetBrains.
the class MoveInnerDialog method createUIComponents.
private void createUIComponents() {
if (!myInnerClass.hasModifierProperty(PsiModifier.STATIC)) {
final PsiManager manager = myInnerClass.getManager();
PsiType outerType = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createType(myInnerClass.getContainingClass());
mySuggestedNameInfo = JavaCodeStyleManager.getInstance(myProject).suggestVariableName(VariableKind.PARAMETER, null, null, outerType);
String[] variants = mySuggestedNameInfo.names;
myParameterField = new NameSuggestionsField(variants, myProject);
} else {
myParameterField = new NameSuggestionsField(new String[] { "" }, myProject);
myParameterField.getComponent().setEnabled(false);
}
myPackageNameField = new PackageNameReferenceEditorCombo("", myProject, RECENTS_KEY, RefactoringBundle.message("choose.destination.package"));
PsiPackage psiPackage = getTargetPackage();
if (psiPackage != null) {
myPackageNameField.prependItem(psiPackage.getQualifiedName());
}
}
use of com.intellij.refactoring.ui.NameSuggestionsField in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoIntroduceVariableDialog method createNamePanel.
private JComponent createNamePanel() {
JPanel panel = new JPanel(new BorderLayout());
String[] names = ArrayUtil.toStringArray(myOperation.getSuggestedNames());
myNameField = new NameSuggestionsField(names, myOperation.getProject(), GoFileType.INSTANCE);
myNameField.setBorder(IdeBorderFactory.createEmptyBorder(3, 5, 2, 3));
myNameField.addDataChangedListener(this::validateButtons);
JLabel label = new JLabel(UIUtil.replaceMnemonicAmpersand(RefactoringBundle.message("name.prompt")));
label.setLabelFor(myNameField);
panel.add(myNameField, BorderLayout.CENTER);
panel.add(label, BorderLayout.WEST);
return panel;
}
use of com.intellij.refactoring.ui.NameSuggestionsField in project intellij-community by JetBrains.
the class AnonymousToInnerDialog method createNorthPanel.
protected JComponent createNorthPanel() {
myNameField = new NameSuggestionsField(myProject);
FormBuilder formBuilder = FormBuilder.createFormBuilder().addLabeledComponent(RefactoringBundle.message("anonymousToInner.class.name.label.text"), myNameField);
if (!myShowCanBeStatic) {
myCbMakeStatic = new NonFocusableCheckBox(RefactoringBundle.message("anonymousToInner.make.class.static.checkbox.text"));
myCbMakeStatic.setSelected(true);
formBuilder.addComponent(myCbMakeStatic);
}
return formBuilder.getPanel();
}
use of com.intellij.refactoring.ui.NameSuggestionsField in project intellij-community by JetBrains.
the class ReplaceConstructorWithFactoryDialog method createNorthPanel.
protected JComponent createNorthPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = JBUI.insets(4, 0, 4, 8);
gbc.gridwidth = 1;
gbc.gridx = 0;
gbc.gridy = 0;
panel.add(new JLabel(RefactoringBundle.message("factory.method.name.label")), gbc);
gbc.gridx++;
gbc.weightx = 1.0;
@NonNls final String[] nameSuggestions = new String[] { "create" + myContainingClass.getName(), "new" + myContainingClass.getName(), "getInstance", "newInstance" };
myNameField = new NameSuggestionsField(nameSuggestions, getProject());
myNameChangedListener = new NameSuggestionsField.DataChanged() {
public void dataChanged() {
validateButtons();
}
};
myNameField.addDataChangedListener(myNameChangedListener);
panel.add(myNameField.getComponent(), gbc);
JPanel targetClassPanel = createTargetPanel();
gbc.gridx = 0;
gbc.gridy++;
gbc.gridwidth = 2;
panel.add(targetClassPanel, gbc);
return panel;
}
use of com.intellij.refactoring.ui.NameSuggestionsField in project intellij-community by JetBrains.
the class InheritanceToDelegationDialog method createNorthPanel.
protected JComponent createNorthPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.WEST;
gbc.gridy = 0;
gbc.gridx = 0;
gbc.insets = JBUI.insets(4, 0, 0, 8);
myClassCombo = new JComboBox(mySuperClasses);
myClassCombo.setRenderer(new ClassCellRenderer(myClassCombo.getRenderer()));
gbc.gridwidth = 2;
final JLabel classComboLabel = new JLabel();
panel.add(classComboLabel, gbc);
gbc.gridy++;
panel.add(myClassCombo, gbc);
classComboLabel.setText(RefactoringBundle.message("replace.inheritance.from"));
myClassComboItemListener = new MyClassComboItemListener();
myClassCombo.addItemListener(myClassComboItemListener);
gbc.gridy++;
gbc.gridwidth = 1;
gbc.insets = JBUI.insets(4, 0);
final JLabel fieldNameLabel = new JLabel();
panel.add(fieldNameLabel, gbc);
myFieldNameField = new NameSuggestionsField(myProject);
gbc.gridx++;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.insets = JBUI.insets(4, 0, 4, 8);
gbc.weightx = 1.0;
panel.add(myFieldNameField.getComponent(), gbc);
fieldNameLabel.setText(RefactoringBundle.message("field.name"));
// if(InheritanceToDelegationUtil.isInnerClassNeeded(myClass, mySuperClass)) {
gbc.gridx = 0;
gbc.gridy++;
gbc.gridwidth = 1;
gbc.insets = JBUI.insets(4, 0);
gbc.weightx = 0.0;
final JLabel innerClassNameLabel = new JLabel();
panel.add(innerClassNameLabel, gbc);
/*String[] suggestions = new String[mySuperClasses.length];
for (int i = 0; i < suggestions.length; i++) {
suggestions[i] = "My" + mySuperClasses[i].getName();
}*/
myInnerClassNameField = new NameSuggestionsField(myProject);
gbc.gridx++;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.insets = JBUI.insets(4, 4, 4, 8);
gbc.weightx = 1.0;
panel.add(myInnerClassNameField.getComponent(), gbc);
innerClassNameLabel.setText(RefactoringBundle.message("inner.class.name"));
boolean innerClassNeeded = false;
for (PsiClass superClass : mySuperClasses) {
innerClassNeeded |= InheritanceToDelegationUtil.isInnerClassNeeded(myClass, superClass);
}
myInnerClassNameField.setVisible(innerClassNeeded);
innerClassNameLabel.setVisible(innerClassNeeded);
return panel;
}
Aggregations