本文整理汇总了Java中com.intellij.refactoring.ui.NameSuggestionsField类的典型用法代码示例。如果您正苦于以下问题:Java NameSuggestionsField类的具体用法?Java NameSuggestionsField怎么用?Java NameSuggestionsField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NameSuggestionsField类属于com.intellij.refactoring.ui包,在下文中一共展示了NameSuggestionsField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRenameDialog
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
@Override
public RenameDialog createRenameDialog( Project project, PsiElement element, PsiElement nameSuggestionContext, Editor editor )
{
return new PsiFileRenameDialog( project, element, nameSuggestionContext, editor ) {
protected void createNewNameComponent() {
super.createNewNameComponent();
getNameSuggestionsField().selectNameWithoutExtension();
}
@Override
protected NameSuggestionsField getNameSuggestionsField()
{
return super.getNameSuggestionsField();
}
};
}
示例2: updateTargetClass
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
private void updateTargetClass() {
final PsiClass targetClass = getSelectedTargetClass();
PsiManager psiManager = myClass.getManager();
PsiType superType = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createType(targetClass);
SuggestedNameInfo suggestedNameInfo =
JavaCodeStyleManager.getInstance(psiManager.getProject()).suggestVariableName(VariableKind.FIELD, null, null, superType);
myFieldNameField.setSuggestions(suggestedNameInfo.names);
myInnerClassNameField.getComponent().setEnabled(InheritanceToDelegationUtil.isInnerClassNeeded(myClass, targetClass));
@NonNls final String suggestion = "My" + targetClass.getName();
myInnerClassNameField.setSuggestions(new String[]{suggestion});
myDataChangedListener = new NameSuggestionsField.DataChanged() {
public void dataChanged() {
validateButtons();
}
};
myInnerClassNameField.addDataChangedListener(myDataChangedListener);
myFieldNameField.addDataChangedListener(myDataChangedListener);
myMemberSelectionPanel.getTable().setMemberInfos(myBasesToMemberInfos.get(targetClass));
myMemberSelectionPanel.getTable().fireExternalDataChange();
}
示例3: createNewNameComponent
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
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 = new NameSuggestionsField.DataChanged() {
@Override
public void dataChanged() {
processNewNameChanged();
}
};
myNameSuggestionsField.addDataChangedListener(myNameChangedListener);
}
示例4: createNewNameComponent
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
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);
}
示例5: initializeName
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
private void initializeName() {
myNameLabel.setLabelFor(myNameField);
myPanel.registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
myNameField.requestFocus();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
myNameField.addDataChangedListener(new NameSuggestionsField.DataChanged() {
@Override
public void dataChanged() {
updateOkStatus();
}
});
}
示例6: createUIComponents
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
private void createUIComponents() {
final GrExpression expression = myContext.getExpression();
final GrVariable var = myContext.getVar();
final StringPartInfo stringPart = myContext.getStringPart();
List<String> list = new ArrayList<String>();
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);
}
示例7: createNewNameComponent
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
private void createNewNameComponent() {
String[] suggestedNames = getSuggestedNames();
myOldName = suggestedNames.length > 0 ? suggestedNames[0] : null;
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 = new NameSuggestionsField.DataChanged() {
@Override
public void dataChanged() {
processNewNameChanged();
}
};
myNameSuggestionsField.addDataChangedListener(myNameChangedListener);
}
示例8: initializeName
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
private void initializeName() {
myNameLabel.setLabelFor(myNameField);
myPanel.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myNameField.requestFocus();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
myNameField.addDataChangedListener(new NameSuggestionsField.DataChanged() {
@Override
public void dataChanged() {
updateOkStatus();
}
});
}
示例9: createNewNameComponent
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
protected void createNewNameComponent() {
String[] suggestedNames = getSuggestedNames();
myOldName = UsageViewUtil.getShortName(myPsiElement);
myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, PlainTextFileType.INSTANCE, myEditor) {
@Override
protected boolean shouldSelectAll() {
return myEditor == null || myEditor.getSettings().isPreselectRename();
}
};
if (myPsiElement instanceof PsiFile && myEditor == null) {
myNameSuggestionsField.selectNameWithoutExtension();
}
myNameChangedListener = new NameSuggestionsField.DataChanged() {
@Override
public void dataChanged() {
processNewNameChanged();
}
};
myNameSuggestionsField.addDataChangedListener(myNameChangedListener);
}
示例10: createNewNameComponent
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
private void createNewNameComponent()
{
myNameSuggestionsField = new NameSuggestionsField(new String[]{myTag.getName()}, myProject, PlainTextFileType.INSTANCE, 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);
}
示例11: createNewNameComponent
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
private void createNewNameComponent() {
String flowName = this.myTag.getAttribute("name").getValue();
this.myNameSuggestionsField = new NameSuggestionsField(new String[]{ flowName }, this.myProject, FileTypes.PLAIN_TEXT, this.myEditor);
this.myNameChangedListener = new NameSuggestionsField.DataChanged() {
public void dataChanged() {
FlowRenameDialog.this.validateButtons();
}
};
this.myNameSuggestionsField.addDataChangedListener(this.myNameChangedListener);
this.myNameSuggestionsField.getComponent().registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FlowRenameDialog.this.completeVariable(FlowRenameDialog.this.myNameSuggestionsField.getEditor());
}
}, KeyStroke.getKeyStroke(32, 2), 2);
}
示例12: createNorthPanel
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
protected JComponent createNorthPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new 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;
}
示例13: createNorthPanel
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
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();
}
示例14: createCenterPanel
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
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, new Function<MavenDomProjectModel, Pair<String, ?>>() {
public Pair<String, ?> fun(MavenDomProjectModel 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;
}
示例15: createNameField
import com.intellij.refactoring.ui.NameSuggestionsField; //导入依赖的package包/类
private NameSuggestionsField createNameField(GrVariable var) {
List<String> names = new ArrayList<String>();
if (var != null) {
names.add(var.getName());
}
ContainerUtil.addAll(names, suggestNames());
return new NameSuggestionsField(ArrayUtil.toStringArray(names), myProject, GroovyFileType.GROOVY_FILE_TYPE);
}