Open the modal window by double clicking on the custom Project View tree item

I have a custom project view and want to open a modal window with settings instead code editor when the user double clicked on some elements.

Is my usecase already supported by intellij?

Comment actions Permalink

Does "custom project view" means that you have own AbstractProjectViewPSIPane with own nodes?

Then IDEA executes the following method to process every selected node that implement Navigatable

OpenSourceUtil#navigate(boolean, boolean, Iterable<? extends Navigatable>) 


Comment actions Permalink

At this moment I use a class which extends ProjectViewPane and create my own nodes in getChildren() method.

I do not understand how OpenSourceUtil#navigate can help me.

I found EditSourceOnDoubleClickHandler and use its method

install(JTree, Runnable)

for implements custom behavior on double click. Is this a normal way?

Comment actions Permalink

No, it is applicable for your custom tree. The Project View tree has already installed a double click handler. And your handler may affect it.

Note, that your Runnable is called right after processing selected nodes, but it does not know about selection: 

OpenSourceUtil.openSourcesFrom(dataContext, true);
if (myWhenPerformed != null);

I recommend to implement the following methods in your ProjectViewNode:

boolean expandOnDoubleClick(); return false (needed for non-leaf nodes)
boolean canNavigate(); // return true (will be processed by openSourcesFrom)
boolean canNavigateToSource(); // return false
void navigate(boolean requestFocus); // open dialog
Comment actions Permalink

 Thanks, this method works fine.


Please sign in to leave a comment.