Search in sources :

Example 1 with DescriptorMemberChooserObject

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;
}
Also used : TreeClassChooser(com.intellij.ide.util.TreeClassChooser) ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) MemberChooser(com.intellij.ide.util.MemberChooser) KtProperty(org.jetbrains.kotlin.psi.KtProperty) DescriptorMemberChooserObject(org.jetbrains.kotlin.idea.core.util.DescriptorMemberChooserObject) ActionListener(java.awt.event.ActionListener) List(java.util.List)

Aggregations

MemberChooser (com.intellij.ide.util.MemberChooser)1 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)1 DocumentAdapter (com.intellij.ui.DocumentAdapter)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 List (java.util.List)1 DocumentEvent (javax.swing.event.DocumentEvent)1 DescriptorMemberChooserObject (org.jetbrains.kotlin.idea.core.util.DescriptorMemberChooserObject)1 KtProperty (org.jetbrains.kotlin.psi.KtProperty)1