Closed xeruf closed 5 years ago
What is the status of this PR?
Still broken, but I'll work on it when I have time.
Current problem: MenuItems with subitems do not show up. Everything else seems fine.
Got that, was a dumb mistake. The "File" menu with its submenus still fails to show up though.
Do you want me to land a hand? I do have other things to work on, but if you need me to check the code I do not mind.
Yep, I have pushed the changes and added a TODO at the relevant position. How can I test the addMany
for files though? I am not able to select multiple files in the DirViewer.
It's been a while since I did anything relevant in the class so I'm out of loop and cant even reply to you without taking a look at your code. Sorry. I will, once I do that.
You do not have to go into the code for that. I just want to know in which widget I can select multiple files at once and invoke the contextmenu on them.
Okay found it, again a dumb mistake. Once I push the fix this should be ready for merge.
I'll take a look once I push my local changes.
I played around with the menus and discovered multiple problems with the design (not necessarily caused with this PR). Quite important.
1 Moving the ContextMenuBuilder.item()/menu() out as an extension function causes conflict with the Menu.menu()/item() extensions. In fact the menu is not populated with items as of now, because wrong extension is imported in CoreMenu. The correct solution is to unify these extensions. i.e., remove Menu.menu()/item() from utils and move ContextMenuBuilder.item()/menu() to utils instead. It did not occur to me, but this should have been done at the very beginning. I temporarily fixed it by making item() member function instead of extension.
2
There is a problem with addSingle/addMany. The menu generation works that either 'single' or 'many' items suppliers are used, never both at once. Unfortunately that creates duplication. Because one can not reuse items from List
3 There was a bug in unpacking singleton List
4 We ignored separators. Those are MenuItems too. API needs to be extended. After issue 1 is fixed. I only added a factory for now.
5 Menu creation and blocking. Blocking ui is no go. I'm thinking about moving the menu construction into bgr thread where we will be able to do even I/O. Fortunately javaFX does not forbid creation of its objects in bgr. Should be doable.
5 Testing. I did multiple fixes/improvements to be able to test/leverage the menus.
You are again putting some Inspector and util changes in here, which have nothing to do with this PR. Could you please just approve this so I can merge and prevent you from being tempted to add more unrelated changes?
No I can't. It did not even work without reverting the extension method. The namespace clash is serious problem that needs to be addressed. I wrote about these problems above. 1 and 4 must be addressed before accepting the merge. I can fix these, if you do want me to.
The changes I made were related, specifically for making it possible to test the menus better. You asked multiple times how to test addMany(). Well by drag & dropping files onto Inspector, that's how.
Fixed 1 by adjusting imports. Turns out the namespace does not clash because extension methods are resolved correctly due to receiver type priority, but only if both 'clashing' methods are imported. This is a little magical and difficult to spot but I'm leaving it as is as there is no easy way around it.
2 Isn't that big of a problem. Will stay as is.
3 Was still confusing. I ended up Removing ValueContextMenu altogether. Much better now.
Implemented 4.
You could have committed the changes to Inspector directly to master and then merged master back in.
1) I do not think the ContextMenuBuilder should have extension methods in util, unless you move the actual class to utils as well, which doesn't seem like a bad idea tbh.
2) "I have fixed this so both suppliers are used, i.e., if the value is File, it will also show menu items for type List,. This makes sense because the actions are applicable." I do not really agree with this. Firstly, you spell the actions differently depending on whether it is one or multiple items, and secondly, there are actions that only make sense on multiple items.
I fixed more problems related to ImprovedContextMenu
The merge is now ready, pls check if you are satisfied with all the solutions.
"I do not think the ContextMenuBuilder should have extension methods in util"
You are right. It was a bad idea. Final solution was to just import both item
extensions and let the compiler apply each in correct context.
"Firstly, you spell the actions differently depending on whether it is one or multiple items, and secondly, there are actions that only make sense on multiple items."
The former can be avoided with smart wording or solved using String.pluralize(count: Int)
extension
The latter may be true. Do you have any example?
We can revert this concept, but I think it makes more sense than it doesn't. Consider File.browse, which also has List
you gotta push them for me to have a look ^^
The changes to Inspector were done because of this branch. That means they belong to this branch right?
Although this branch seems to have stalled/bloated, I actually think it was simply result of iterative development and that there were great improvements compared to what master is doing. This PR taking its time is something I dont find disadvantageous at all.
Removed
I'm done, you can proceed. I suggest no squashing.
This branch has 21 commits, easily half of them being corrections and merges. Are you sure you want to have them all in master?
Also, you still need to approve for me to merge.
I'm not big on 'clean' history. Im 50:50, your call.
Id appreciate if you merged.
Right, I forgot. Will do today.
WIP - I want to avoid the verbosity and repetitions of the previous syntax and add some items