use of org.jetbrains.kotlin.idea.core.util.DescriptorMemberChooserObject in project kotlin by JetBrains.
the class AddFieldBreakpointDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
myClassChooser.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void textChanged(DocumentEvent event) {
updateUI();
}
});
myClassChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PsiClass currentClass = getSelectedClass();
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createAllProjectScopeChooser(DebuggerBundle.message("add.field.breakpoint.dialog.classchooser.title"));
if (currentClass != null) {
PsiFile containingFile = currentClass.getContainingFile();
if (containingFile != null) {
PsiDirectory containingDirectory = containingFile.getContainingDirectory();
if (containingDirectory != null) {
chooser.selectDirectory(containingDirectory);
}
}
}
chooser.showDialog();
PsiClass selectedClass = chooser.getSelected();
if (selectedClass != null) {
myClassChooser.setText(selectedClass.getQualifiedName());
}
}
});
myFieldChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
PsiClass selectedClass = getSelectedClass();
DescriptorMemberChooserObject[] properties = FieldBreakpointDialogUtilKt.collectProperties(selectedClass);
MemberChooser<DescriptorMemberChooserObject> chooser = new MemberChooser<DescriptorMemberChooserObject>(properties, false, false, myProject);
chooser.setTitle(DebuggerBundle.message("add.field.breakpoint.dialog.field.chooser.title", properties.length));
chooser.setCopyJavadocVisible(false);
chooser.show();
List<DescriptorMemberChooserObject> selectedElements = chooser.getSelectedElements();
if (selectedElements != null && selectedElements.size() == 1) {
KtProperty field = (KtProperty) selectedElements.get(0).getElement();
myFieldChooser.setText(field.getName());
}
}
});
myFieldChooser.setEnabled(false);
return myPanel;
}
Aggregations