use of com.intellij.ui.ReferenceEditorComboWithBrowseButton in project intellij-community by JetBrains.
the class IntroduceParameterObjectDialog method createUIComponents.
private void createUIComponents() {
final PsiFile file = mySourceMethod.getContainingFile();
packageTextField = new PackageNameReferenceEditorCombo(file instanceof PsiJavaFile ? ((PsiJavaFile) file).getPackageName() : "", myProject, RECENTS_KEY, RefactoringBundle.message("choose.destination.package"));
final Document document = packageTextField.getChildComponent().getDocument();
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();
}
};
document.addDocumentListener(adapter);
existingClassField = new ReferenceEditorComboWithBrowseButton(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final Project project = mySourceMethod.getProject();
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
final TreeJavaClassChooserDialog chooser = new TreeJavaClassChooserDialog(RefactorJBundle.message("select.wrapper.class"), project, scope, null, null);
final String classText = existingClassField.getText();
final PsiClass currentClass = JavaPsiFacade.getInstance(project).findClass(classText, GlobalSearchScope.allScope(project));
if (currentClass != null) {
chooser.select(currentClass);
}
chooser.show();
final PsiClass selectedClass = chooser.getSelected();
if (selectedClass != null) {
final String className = selectedClass.getQualifiedName();
existingClassField.setText(className);
RecentsManager.getInstance(myProject).registerRecentEntry(EXISTING_KEY, className);
}
}
}, "", myProject, true, EXISTING_KEY);
existingClassField.getChildComponent().getDocument().addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() {
@Override
public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
validateButtons();
enableGenerateAccessors();
}
});
myDestinationCb = new DestinationFolderComboBox() {
@Override
public String getTargetPackage() {
return getPackageName();
}
};
((DestinationFolderComboBox) myDestinationCb).setData(myProject, mySourceMethod.getContainingFile().getContainingDirectory(), packageTextField.getChildComponent());
}
use of com.intellij.ui.ReferenceEditorComboWithBrowseButton in project kotlin by JetBrains.
the class MoveKotlinNestedClassesDialog method initClassChooser.
private void initClassChooser(@NotNull KtClassOrObject initialTargetClass) {
//noinspection ConstantConditions
originalClassField.setText(originalClass.getFqName().asString());
//noinspection ConstantConditions
targetClassChooser = new ReferenceEditorComboWithBrowseButton(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TreeClassChooser chooser = new TreeJavaClassChooserDialog(RefactoringBundle.message("choose.destination.class"), myProject, GlobalSearchScope.projectScope(myProject), new ClassFilter() {
@Override
public boolean isAccepted(PsiClass aClass) {
if (!(aClass instanceof KtLightClassForSourceDeclaration))
return false;
KtClassOrObject classOrObject = ((KtLightClassForSourceDeclaration) aClass).getKotlinOrigin();
if (classOrObject instanceof KtObjectDeclaration) {
return !((KtObjectDeclaration) classOrObject).isObjectLiteral();
}
if (classOrObject instanceof KtClass) {
KtClass ktClass = (KtClass) classOrObject;
return !(ktClass.isInner() || ktClass.isAnnotation());
}
return false;
}
}, null, null, true) {
@Nullable
@Override
protected PsiClass getSelectedFromTreeUserObject(DefaultMutableTreeNode node) {
PsiClass psiClass = super.getSelectedFromTreeUserObject(node);
if (psiClass != null)
return psiClass;
Object userObject = node.getUserObject();
if (!(userObject instanceof KtClassOrObjectTreeNode))
return null;
return LightClassUtilsKt.toLightClass(((KtClassOrObjectTreeNode) userObject).getValue());
}
};
chooser.selectDirectory((targetClass != null ? targetClass : originalClass).getContainingFile().getContainingDirectory());
chooser.showDialog();
PsiClass aClass = chooser.getSelected();
if (aClass instanceof KtLightClassForSourceDeclaration) {
targetClass = ((KtLightClassForSourceDeclaration) aClass).getKotlinOrigin();
targetClassChooser.setText(aClass.getQualifiedName());
}
}
}, initialTargetClass.getFqName().asString(), myProject, true, JavaCodeFragment.VisibilityChecker.PROJECT_SCOPE_VISIBLE, RECENTS_KEY);
targetClassChooser.getChildComponent().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
PsiClass aClass = JavaPsiFacade.getInstance(myProject).findClass(targetClassChooser.getText(), GlobalSearchScope.projectScope(myProject));
targetClass = aClass instanceof KtLightClassForSourceDeclaration ? ((KtLightClassForSourceDeclaration) aClass).getKotlinOrigin() : null;
validateButtons();
}
});
targetClassChooserPanel.add(targetClassChooser);
}
use of com.intellij.ui.ReferenceEditorComboWithBrowseButton in project android by JetBrains.
the class ActivityComboProvider method createComponent.
@NotNull
@Override
protected ReferenceEditorComboWithBrowseButton createComponent(@NotNull Parameter parameter) {
ChooseClassActionListener browseAction = new ChooseClassActionListener(myModule);
RecentsManager recentsManager = RecentsManager.getInstance(myModule.getProject());
// Always have a blank entry and make sure it shows up first - because by default, most users
// won't want to add any parent.
recentsManager.registerRecentEntry(myRecentsKey, "");
ReferenceEditorComboWithBrowseButton control = new ReferenceEditorComboWithBrowseButton(browseAction, "", myModule.getProject(), true, new OnlyShowActivities(myModule), myRecentsKey);
// Need to tell our browse action which component to modify when user hits OK. Ideally we'd
// pass this into browseAction's constructor but the control isn't created until after.
browseAction.setOwner(control);
return control;
}
Aggregations