use of com.intellij.refactoring.ui.NameSuggestionsField in project intellij-community by JetBrains.
the class IntroducePropertyDialog method createCenterPanel.
protected JComponent createCenterPanel() {
myFieldNamePanel.setLayout(new BorderLayout());
myNameField = new NameSuggestionsField(myProject);
myNameChangedListener = new NameSuggestionsField.DataChanged() {
public void dataChanged() {
updateOkStatus();
}
};
myNameField.addDataChangedListener(myNameChangedListener);
myNameField.setSuggestions(getSuggestions());
myFieldNamePanel.add(myNameField, BorderLayout.CENTER);
List<MavenDomProjectModel> projects = getProjects();
ComboBoxUtil.setModel(myMavenProjectsComboBox, new DefaultComboBoxModel(), projects, model -> {
String projectName = model.getName().getStringValue();
MavenProject mavenProject = MavenDomUtil.findProject(model);
if (mavenProject != null) {
projectName = mavenProject.getDisplayName();
}
if (StringUtil.isEmptyOrSpaces(projectName)) {
projectName = "pom.xml";
}
return Pair.create(projectName, model);
});
myMavenProjectsComboBox.setSelectedItem(myMavenDomProjectModel);
return myMainPanel;
}
use of com.intellij.refactoring.ui.NameSuggestionsField in project intellij-community by JetBrains.
the class XmlTagRenameDialog method createNewNameComponent.
private void createNewNameComponent() {
myNameSuggestionsField = new NameSuggestionsField(new String[] { myTag.getName() }, myProject, FileTypes.PLAIN_TEXT, myEditor);
myNameChangedListener = new NameSuggestionsField.DataChanged() {
@Override
public void dataChanged() {
validateButtons();
}
};
myNameSuggestionsField.addDataChangedListener(myNameChangedListener);
myNameSuggestionsField.getComponent().registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
completeVariable(myNameSuggestionsField.getEditor());
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
}
use of com.intellij.refactoring.ui.NameSuggestionsField in project kotlin by JetBrains.
the class KotlinIntroduceTypeAliasDialog method init.
@Override
protected void init() {
super.init();
//noinspection unchecked
visibilityBox.setModel(new DefaultComboBoxModel(getApplicableVisibilities().toArray()));
//noinspection unchecked
visibilityBox.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
String tokenValue = value != null ? ((KtModifierKeywordToken) value).getValue() : null;
return super.getListCellRendererComponent(list, tokenValue, index, isSelected, cellHasFocus);
}
});
aliasNameField = new NameSuggestionsField(new String[] { originalDescriptor.getName() }, project, KotlinFileType.INSTANCE);
aliasNameField.addDataChangedListener(new NameSuggestionsField.DataChanged() {
@Override
public void dataChanged() {
update();
}
});
aliasNamePanel.add(aliasNameField, BorderLayout.CENTER);
aliasNameLabel.setLabelFor(aliasNameField);
boolean enableVisibility = isVisibilitySectionAvailable();
visibilityBox.setEnabled(enableVisibility);
if (enableVisibility) {
KtModifierKeywordToken defaultVisibility = originalDescriptor.getVisibility();
if (defaultVisibility == null) {
defaultVisibility = KtTokens.PUBLIC_KEYWORD;
}
visibilityBox.setSelectedItem(defaultVisibility);
}
visibilityBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(@NotNull ItemEvent e) {
update();
}
});
if (!originalDescriptor.getTypeParameters().isEmpty()) {
parameterTablePanel = new IntroduceTypeAliasParameterTablePanel() {
@Override
protected void updateSignature() {
KotlinIntroduceTypeAliasDialog.this.update();
}
@Override
protected void onEnterAction() {
doOKAction();
}
@Override
protected void onCancelAction() {
doCancelAction();
}
};
parameterTablePanel.init(originalDescriptor.getTypeParameters());
inputParametersPanel.setText("Type &Parameters");
inputParametersPanel.setLabelFor(parameterTablePanel.getTable());
inputParametersPanel.add(parameterTablePanel);
} else {
inputParametersPanel.setVisible(false);
}
}
use of com.intellij.refactoring.ui.NameSuggestionsField in project kotlin by JetBrains.
the class MoveKotlinNestedClassesToUpperLevelDialog method createUIComponents.
private void createUIComponents() {
parameterField = new NameSuggestionsField(project);
packageNameField = new PackageNameReferenceEditorCombo("", project, RECENTS_KEY, RefactoringBundle.message("choose.destination.package"));
}
use of com.intellij.refactoring.ui.NameSuggestionsField in project intellij-community by JetBrains.
the class RenameDialog method createNewNameComponent.
protected void createNewNameComponent() {
String[] suggestedNames = getSuggestedNames();
myOldName = UsageViewUtil.getShortName(myPsiElement);
myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, FileTypes.PLAIN_TEXT, myEditor) {
@Override
protected boolean shouldSelectAll() {
return myEditor == null || myEditor.getSettings().isPreselectRename();
}
};
if (myPsiElement instanceof PsiFile && myEditor == null) {
myNameSuggestionsField.selectNameWithoutExtension();
}
myNameChangedListener = () -> processNewNameChanged();
myNameSuggestionsField.addDataChangedListener(myNameChangedListener);
}
Aggregations