Show classes from a package in a dialog box

Iam writing a plugin. I want to show all the classes of a package in a dialog box so that user can select a class, how can i do this.
I tried TreeClassChooser , it is showing all the claases in project. Can anyone pls help.

Comment actions Permalink

psiPackage = JavaPsiFacade.getInstance(project).findPackage()

This would get you the list of classes; e.g. com.intellij.ide.util.PsiElementListCellRenderer could be used as renderer.


Comment actions Permalink

Thanks for your reply, i tried it and iam able to show the classes using following lines
ApplicationManager.getApplication().invokeLater(new Runnable() {
            public void run() {
                        setTitle("Select Class").
But having another issue now, the control goes back to the calling method even before i select the class, i want to select the class first and then then the control has to go back to calling method, how can i do this
Can you pls help

Comment actions Permalink

Sure, you don't have selected class before you show popup.

The call is not blocking so you need to perform everything which relys on selectedin inside your "runnable"

Comment actions Permalink

Sorry I didnot get you. I have written the code for what should happen once the class is selected inside setItemChoosenCallback(runnable), but the contol goes back to the main method before this is executed, and when i select the class, the statements get executed and nothing happens..

Comment actions Permalink

Everything depending on selection should be in the callback. Controlflow would return back immediately exactly as you described. You may find a lot of examples of such code in our code base, just search for popup creation and you'll get them!

Comment actions Permalink

I tried different ways, still dint get what i want, is it related to ModalityState. What ModalityStae should i specify


Please sign in to leave a comment.