Clicking on a row in the project tree doesn't open the file anymore
Answered
https://youtrack.jetbrains.com/issue/WEB-43113
In short, I have this issue when clicking on a file in the project tree do not open the file anymore in my plugin.
What caused this: I replaced the DefaultTreeUI component by my version of TreeUI. To make sure I won't be missing any features of the DefaultTreeUI I copied-pasted the DefaultTreeUI methods, replacing only what I need to replace.
However I still have this issue, even after reverting all my changes, and just using DefaultTreeUI methods. I suspect there is some part in the code that assumes that there can only by a DefaultTreeUI component. Can someone help me figure out this?
Please sign in to leave a comment.
Yes, this class name is hardcoded.
See https://youtrack.jetbrains.com/issue/IDEA-178054
https://github.com/JetBrains/intellij-community/blob/master/platform/util/ui/src/com/intellij/util/ui/tree/WideSelectionTreeUI.java#L271
https://github.com/JetBrains/intellij-community/blob/master/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java#L107
I'm afraid, you will need to wait for an answer from Sergey (which might be delayed due to holidays https://publicholidays.ru/2020-dates ).
It is not recommended to create custom TreeUI. Which functionality do you want to add here?
I don’t know if you know the material theme plugin, but the concept of the plugin is to change the UI components. Therefore I have my own instance of TreeUI replacing your version.
In my version the user can control the look of the arrows as well as adding an indicator of the current selected file.
I think I can get around this issue now thanks to Aleksei but just so you know this is a bit problematic to have hardcoded class names checks.
You can configure icons and other properties via UIDefaults.
It’s not just about icons, it’s about the ability to customize the UI components however I want to. Why would you have the property “TreeUI” in UIDefaults if you can’t replace it with your own version?
Because many developers ignore the main Swing rule - call all methods from EDT. This leads to different multi-threading issues, which I'm trying to solve in the DefaultTreeUI.
No problem then - just make the DefaultTreeUI extendable then. This way I can simply extend the class to change only the parts that interest me.
It's API is not finished yet. Maybe later.
Which parts you want to extend? Something related to offsets can be configured via com.intellij.ui.tree.ui.Control.Painter:
Hmm interesting... I'll check if that meets my requirements. Thanks
Actually, we already have UI settings in the Appearance configurable, which allows to switch on compact mode and to show indent guides.
Yes I know about this, this is not what I want, rather I have implemented a new Control.Painter which I use to render the selected file indicator (http://www.material-theme.com/blog/whats-new-in-2-5/#selected-tree-indicator-styles)
It works with my version of the TreeUI but if I can use DefaultTreeUI and change the Control.Painter to my own that would do the trick.
Oh, I see. So the custom Control.Painer should help.