use of com.intellij.refactoring.ui.NameSuggestionsField in project intellij-community by JetBrains.
the class GrIntroduceConstantDialog method createUIComponents.
private void createUIComponents() {
myJavaVisibilityPanel = new JavaVisibilityPanel(false, true);
final GrVariable var = myContext.getVar();
final GrExpression expression = myContext.getExpression();
final StringPartInfo stringPart = myContext.getStringPart();
if (expression != null) {
myTypeCombo = GrTypeComboBox.createTypeComboBoxFromExpression(expression);
} else if (stringPart != null) {
myTypeCombo = GrTypeComboBox.createTypeComboBoxFromExpression(stringPart.getLiteral());
} else {
assert var != null;
myTypeCombo = GrTypeComboBox.createTypeComboBoxWithDefType(var.getDeclaredType(), var);
}
List<String> names = new ArrayList<>();
if (var != null) {
names.add(var.getName());
}
if (expression != null) {
ContainerUtil.addAll(names, suggestNames());
}
myNameField = new NameSuggestionsField(ArrayUtil.toStringArray(names), myContext.getProject(), GroovyFileType.GROOVY_FILE_TYPE);
GrTypeComboBox.registerUpDownHint(myNameField, myTypeCombo);
}
use of com.intellij.refactoring.ui.NameSuggestionsField in project intellij-community by JetBrains.
the class GrIntroduceFieldDialog method createUIComponents.
private void createUIComponents() {
final GrExpression expression = myContext.getExpression();
final GrVariable var = myContext.getVar();
final StringPartInfo stringPart = myContext.getStringPart();
List<String> list = new ArrayList<>();
if (var != null) {
list.add(var.getName());
}
ContainerUtil.addAll(list, suggestNames());
myNameField = new NameSuggestionsField(ArrayUtil.toStringArray(list), myContext.getProject(), GroovyFileType.GROOVY_FILE_TYPE);
if (expression != null) {
myTypeComboBox = GrTypeComboBox.createTypeComboBoxFromExpression(expression);
} else if (stringPart != null) {
myTypeComboBox = GrTypeComboBox.createTypeComboBoxFromExpression(stringPart.getLiteral());
} else {
myTypeComboBox = GrTypeComboBox.createTypeComboBoxWithDefType(var.getDeclaredType(), var);
}
GrTypeComboBox.registerUpDownHint(myNameField, myTypeComboBox);
}
use of com.intellij.refactoring.ui.NameSuggestionsField in project kotlin by JetBrains.
the class KotlinExtractFunctionDialog method init.
@Override
protected void init() {
super.init();
ExtractableCodeDescriptor extractableCodeDescriptor = originalDescriptor.getDescriptor();
functionNameField = new NameSuggestionsField(ArrayUtil.toStringArray(extractableCodeDescriptor.getSuggestedNames()), project, KotlinFileType.INSTANCE);
functionNameField.addDataChangedListener(new NameSuggestionsField.DataChanged() {
@Override
public void dataChanged() {
update();
}
});
functionNamePanel.add(functionNameField, BorderLayout.CENTER);
functionNameLabel.setLabelFor(functionNameField);
List<KotlinType> possibleReturnTypes = ExtractableCodeDescriptorKt.getPossibleReturnTypes(extractableCodeDescriptor.getControlFlow());
if (possibleReturnTypes.size() > 1) {
DefaultComboBoxModel returnTypeBoxModel = new DefaultComboBoxModel(possibleReturnTypes.toArray());
returnTypeBox.setModel(returnTypeBoxModel);
returnTypeBox.setRenderer(new DefaultListCellRenderer() {
@NotNull
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
setText(IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType((KotlinType) value));
return this;
}
});
returnTypeBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(@NotNull ItemEvent e) {
update();
}
});
} else {
returnTypePanel.getParent().remove(returnTypePanel);
}
boolean enableVisibility = isVisibilitySectionAvailable();
visibilityBox.setEnabled(enableVisibility);
if (enableVisibility) {
String defaultVisibility = extractableCodeDescriptor.getVisibility();
if (defaultVisibility.isEmpty()) {
defaultVisibility = KtTokens.PUBLIC_KEYWORD.getValue();
}
visibilityBox.setSelectedItem(defaultVisibility);
}
visibilityBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(@NotNull ItemEvent e) {
update();
}
});
parameterTablePanel = new ExtractFunctionParameterTablePanel() {
@Override
protected void updateSignature() {
KotlinExtractFunctionDialog.this.update();
}
@Override
protected void onEnterAction() {
doOKAction();
}
@Override
protected void onCancelAction() {
doCancelAction();
}
};
parameterTablePanel.init(extractableCodeDescriptor.getReceiverParameter(), extractableCodeDescriptor.getParameters());
inputParametersPanel.setText("&Parameters");
inputParametersPanel.setLabelFor(parameterTablePanel.getTable());
inputParametersPanel.add(parameterTablePanel);
}
use of com.intellij.refactoring.ui.NameSuggestionsField in project intellij-plugins by JetBrains.
the class DartRenameDialog method createNewNameComponent.
private void createNewNameComponent() {
String[] suggestedNames = getSuggestedNames();
myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, FileTypes.PLAIN_TEXT, myEditor) {
@Override
protected boolean shouldSelectAll() {
return myEditor == null || myEditor.getSettings().isPreselectRename();
}
};
myNameSuggestionsField.addDataChangedListener(this::processNewNameChanged);
}
Aggregations