Project view - list of files/packages

Answered

Hi !

It's my first contact with plugin development.

I want to auto-resize/match Project View to packages/files. 

And to do that I need to somehow access all packages and files in project view (the tree structure). Or even better know height/width/position of particular class/package.

Code that I have:

 

Or simply with pictures what I want to do, I have 500px width:

I want 250px width:

0
5 comments
Official comment

When/how to you determine there's a new "width" to be applied? This will be tricky and might result in some jumping/unexpected layout changes in toolwindow/editor layout?!

com.intellij.ide.projectView.ProjectView#getCurrentProjectViewPane will give you currently shown pane, com.intellij.ide.projectView.impl.AbstractProjectViewPane#getTree the JTree from which you should be able to calculated required dimensions. Then use com.intellij.openapi.wm.ex.ToolWindowEx#stretchWidth/Height to change it.

Thanks for the reply, I have lost my faith :D

You know I will start with sth simple, so for begging, I will create an action that will trigger this auto-match event. Later it can be triggered by "(go to) project" (alt+1) shortcut.

Actually, this auto-match is not for me, but all these people that have Project View for half of the screen (it's really annoying to watch).

0

OK, after a ton of debugging, fighting with returned Object classes, exceptions for bad casting etc.

I still haven't figured it out.

My biggest accomplishment is finding this Tree Model map with a tree of packages/classes.

But I don't even know how to access it. 

Any advice ?

0

Please try javax.swing.JTree#getPathBounds

0

It works !!! Thanks, Yann.

For grandchilds:

This code will match Project View width to 9th row (aaaa...):


Before:

After invoking action:

The code will be on Github: 

https://github.com/RafalJDev/intellij-auto-resize

0

Please sign in to leave a comment.