jadx icon indicating copy to clipboard operation
jadx copied to clipboard

feat(gui):improve search and usage dialog

Open MrIkso opened this issue 1 year ago • 6 comments

This PR improves Search and Usage dialogs. Releated to #2009 , #2373, #1130

Main features:

  1. Added Whole Word find option
  2. Highlights text for found Classes/Methods/Filelds
  3. Tree structure for code/comment/resource results

Removed

  1. Open button - unuseless feature for curently view
  2. Sort button - results sorted by name defaults

Limitations

  1. Curently search available only one selected option
  2. When Method/Field name used highligt type not formatted html
Preview
Old New
Class Search Old_Search_Class_2024-12-27_02-14 Search_Class_2024-12-27_02-14
Methods Search Old_Search_Method_2024-12-27_02-14 Search_Method_2024-12-27_02-14
Field Search Old_Search_Field_2024-12-27_02-14 Search_Fileld_2024-12-27_02-14
Code Search Old_Search_Code_2024-12-27_02-14 Search_Code_2024-12-27_02-14
Resource Search Old_Sesrch_Res_2024-12-27_02-57 Search_Ressource1_2024-12-27_02-14 Search_Ressource2_2024-12-27_02-14
Usage Old_Usage_2024-12-27_02-50 Usage_2024-12-27_02-50

P.S maybe there will be more ideas how to make the appearance of the search results the best, maybe combine the table and the tree (TreeTable).

MrIkso avatar Dec 27 '24 01:12 MrIkso

Well, it is sad that this PR don't get any suggestions or comments.

Anyway, I have some thoughts: At first, we will need a tree representation in usage dialog to implement references window (#1368). That is an improvement of current usage dialog with addition of all type of references like class hierarchy, method overrides, etc. and not only usage. For this, collapsible sections are the good approach, so the tree looks like the best component. Although in search, code preview looks better in a table component in a separate column, because obfuscated code have short names so classes/methods names became useless and tree pointless. So, as suggested by @MrIkso, TreeTable component will be a nice approach to combine above requirements and allow using various representation as needed. Some implementation details:

  • create a customizable tree table component which allows inserting simple text nodes (needed for references window)
  • in code search add a switch to change representation: tree or table (should change a 'model' for new component)
  • use new component in usage dialog with a single Usage top level label (others will be added later)

Such approach will allow using single component in all places to represent jadx nodes in various ways.

@MrIkso this looks like a big task, so you may change this PR, or I can merge it into a new branch and implement these myself or with your help if you want to.

skylot avatar Jan 15 '25 19:01 skylot

@skylot yeah ThreeTable it's best variant. I did something like this once, it's a bit complicated but doable. My current implementation has one problem, if the string found is long, it window freezes. Otherwise everything seems to be working. Upd.. info about TreeTable https://www.hameister.org/JavaSwingTreeTable.html https://www.comp.nus.edu.sg/~cs3283/ftp/Java/swingConnect/tech_topics/tables-trees/tables-trees.html https://github.com/nishihatapalmer/TreeTable

MrIkso avatar Jan 15 '25 19:01 MrIkso

It looks very nice! I think this was a very much needed task to be performed, I'm glad it's already being worked on.

I have one suggestion. It would be nice if the nesting in packages/classes could be disabled, and have everything shown in a single node like it's implemented right now. In most cases this will never be desired, but sometimes when looking at strings or some common code, it's appreciated to see it next to each others to spot differences quickly.

Thanks!

iscle avatar Feb 21 '25 03:02 iscle

@skylot I decided to see how search is implemented, find usages in netbeans ide. I think something similar can be done here? We can even seen code how everything)

Preview

image

image

image

image

image

There everything is not in a separate dialog but at the bottom of the screen, which in principle can be tried to be implemented here, also with tabs(?). I also thought to take the editor from there, it is more productive, but it implemet very hard.

MrIkso avatar Jun 03 '25 19:06 MrIkso

@MrIkso I see, so results are in tree with preview panel, and this looks very similar to implementation in this PR :slightly_smiling_face: But, as I mention early, in my opinion, tree representation is not working for obfuscated classes, that is why current implementation heavily focused on code lines, so it is easier to scan results without mixing in classes names. Also, I think for current implementation preview is better to put at the bottom, because results table is wide.

There everything is not in a separate dialog but at the bottom of the screen, which in principle can be tried to be implemented here

Sure, there is already an issue for start using dockable framework (#2237), but all docking frameworks are very old and abandoned, only active is a ModernDocking, we might use it once it became stable enough. As another approach, I implement dock/undock manually for logs, it works fine, but docked position is fixed through.

skylot avatar Jun 03 '25 22:06 skylot

@MrIkso Thanks for working on this. I was wondering why there was no 'Whole word' search feature so I went ahead and implemented it myself but your version seems better. Really looking forward to it.

MewtR avatar Jun 04 '25 23:06 MewtR