use of com.intellij.ui.ReferenceEditorComboWithBrowseButton in project intellij-community by JetBrains.
the class GrIntroduceConstantDialog method initializeTargetClassEditor.
private void initializeTargetClassEditor() {
myTargetClassEditor = new ReferenceEditorComboWithBrowseButton(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myContext.getProject()).createWithInnerClassesScopeChooser(RefactoringBundle.message("choose.destination.class"), GlobalSearchScope.projectScope(myContext.getProject()), new ClassFilter() {
@Override
public boolean isAccepted(PsiClass aClass) {
return aClass.getParent() instanceof GroovyFile || aClass.hasModifierProperty(PsiModifier.STATIC);
}
}, null);
if (myTargetClass != null) {
chooser.selectDirectory(myTargetClass.getContainingFile().getContainingDirectory());
}
chooser.showDialog();
PsiClass aClass = chooser.getSelected();
if (aClass != null) {
myTargetClassEditor.setText(aClass.getQualifiedName());
}
}
}, "", myContext.getProject(), true, RECENTS_KEY);
myTargetClassPanel.setLayout(new BorderLayout());
myTargetClassPanel.add(myTargetClassLabel, BorderLayout.NORTH);
myTargetClassPanel.add(myTargetClassEditor, BorderLayout.CENTER);
Set<String> possibleClassNames = new LinkedHashSet<>();
for (final PsiElement occurrence : myContext.getOccurrences()) {
final PsiClass parentClass = getParentClass(occurrence);
if (parentClass != null && parentClass.getQualifiedName() != null) {
possibleClassNames.add(parentClass.getQualifiedName());
}
}
for (String possibleClassName : possibleClassNames) {
myTargetClassEditor.prependItem(possibleClassName);
}
if (myDefaultTargetClass != null) {
myTargetClassEditor.prependItem(myDefaultTargetClass.getQualifiedName());
}
myTargetClassEditor.getChildComponent().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
targetClassChanged();
updateOkStatus();
// enableEnumDependant(introduceEnumConstant());
}
});
}
use of com.intellij.ui.ReferenceEditorComboWithBrowseButton in project kotlin by JetBrains.
the class MoveKotlinTopLevelDeclarationsDialog method createPackageChooser.
private ReferenceEditorComboWithBrowseButton createPackageChooser() {
ReferenceEditorComboWithBrowseButton packageChooser = new PackageNameReferenceEditorCombo("", myProject, RECENTS_KEY, RefactoringBundle.message("choose.destination.package"));
Document document = packageChooser.getChildComponent().getDocument();
document.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
validateButtons();
}
});
return packageChooser;
}
use of com.intellij.ui.ReferenceEditorComboWithBrowseButton in project intellij-community by JetBrains.
the class WrapReturnValueDialog method createUIComponents.
private void createUIComponents() {
final com.intellij.openapi.editor.event.DocumentAdapter adapter = new com.intellij.openapi.editor.event.DocumentAdapter() {
public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
validateButtons();
}
};
packageTextField = new PackageNameReferenceEditorCombo("", myProject, RECENT_KEYS, RefactoringBundle.message("choose.destination.package"));
packageTextField.getChildComponent().getDocument().addDocumentListener(adapter);
existingClassField = new ReferenceEditorComboWithBrowseButton(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()).createWithInnerClassesScopeChooser(RefactorJBundle.message("select.wrapper.class"), GlobalSearchScope.allScope(myProject), null, null);
final String classText = existingClassField.getText();
final PsiClass currentClass = JavaPsiFacade.getInstance(myProject).findClass(classText, GlobalSearchScope.allScope(myProject));
if (currentClass != null) {
chooser.select(currentClass);
}
chooser.showDialog();
final PsiClass selectedClass = chooser.getSelected();
if (selectedClass != null) {
existingClassField.setText(selectedClass.getQualifiedName());
}
}
}, "", myProject, true, RECENT_KEYS);
existingClassField.getChildComponent().getDocument().addDocumentListener(adapter);
myDestinationCb = new DestinationFolderComboBox() {
@Override
public String getTargetPackage() {
return getPackageName();
}
};
((DestinationFolderComboBox) myDestinationCb).setData(myProject, sourceMethod.getContainingFile().getContainingDirectory(), packageTextField.getChildComponent());
}
use of com.intellij.ui.ReferenceEditorComboWithBrowseButton in project intellij-community by JetBrains.
the class MoveClassesOrPackagesDialog method createPackageChooser.
private ReferenceEditorComboWithBrowseButton createPackageChooser() {
final ReferenceEditorComboWithBrowseButton packageChooser = new PackageNameReferenceEditorCombo("", myProject, RECENTS_KEY, RefactoringBundle.message("choose.destination.package"));
final Document document = packageChooser.getChildComponent().getDocument();
document.addDocumentListener(new DocumentAdapter() {
public void documentChanged(DocumentEvent e) {
validateButtons();
}
});
return packageChooser;
}
use of com.intellij.ui.ReferenceEditorComboWithBrowseButton in project intellij-community by JetBrains.
the class IntroduceConstantDialog method createNorthPanel.
protected JComponent createNorthPanel() {
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(new NameSuggestionsField.DataChanged() {
public void dataChanged() {
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, 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 DocumentAdapter() {
public void documentChanged(DocumentEvent e) {
targetClassChanged();
enableEnumDependant(introduceEnumConstant());
}
});
myIntroduceEnumConstantCb.addActionListener(new ActionListener() {
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;
}
final NameSuggestionsManager nameSuggestionsManager = new NameSuggestionsManager(myTypeSelector, myNameField, createNameSuggestionGenerator(propertyName, myInitializerExpression, myCodeStyleManager, myEnteredName, myParentClass));
nameSuggestionsManager.setLabelsFor(myTypeLabel, myNameSuggestionLabel);
//////////
if (myOccurrencesCount > 1) {
myCbReplaceAll.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateTypeSelector();
myNameField.requestFocusInWindow();
}
});
myCbReplaceAll.setText(RefactoringBundle.message("replace.all.occurences", myOccurrencesCount));
} else {
myCbReplaceAll.setVisible(false);
}
if (myLocalVariable != null) {
if (myInvokedOnDeclaration) {
myCbDeleteVariable.setEnabled(false);
myCbDeleteVariable.setSelected(true);
} else if (myCbReplaceAll != null) {
updateCbDeleteVariable();
myCbReplaceAll.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateCbDeleteVariable();
}
});
}
} else {
myCbDeleteVariable.setVisible(false);
}
final PsiManager psiManager = PsiManager.getInstance(myProject);
if ((myTypeSelectorManager.isSuggestedType(CommonClassNames.JAVA_LANG_STRING) || (myLocalVariable != null && AnnotationUtil.isAnnotated(myLocalVariable, AnnotationUtil.NON_NLS, false, false))) && LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5) && JavaPsiFacade.getInstance(psiManager.getProject()).findClass(AnnotationUtil.NON_NLS, myParentClass.getResolveScope()) != null) {
final PropertiesComponent component = PropertiesComponent.getInstance(myProject);
myCbNonNls.setSelected(component.getBoolean(NONNLS_SELECTED_PROPERTY));
myCbNonNls.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
component.setValue(NONNLS_SELECTED_PROPERTY, myCbNonNls.isSelected());
}
});
} else {
myCbNonNls.setVisible(false);
}
updateTypeSelector();
enableEnumDependant(introduceEnumConstant());
return myPanel;
}
Aggregations