ProgressManager#WithProgressAsync + CommandProcessor#executeCommand
I'm wrapping several commands into CommandProcessor#executeCommand for Undoability in one action. All inner commands runs in separeted AppllicationManager#InvokeLater.
- Commands executed in Async thread doesn't respect outer #executeCommand, i.e. undo works for each command separately.
- Also i can't put #executeCommand into async thread cuz i will get exception.
- #WithProgressSync respects outer command, but dialog freezes cuz ui thread.
Please sign in to leave a comment.
Commands can only be executed in UI thread.
Have you tried to use the same non-null command name and groupId so that the commands could be merged automatically?
Sorry, I don't understand "dialog freezes cuz ui thread", more details or a thread dump could be helpful.
runProcessWithProgressSynchronously (Freezes)
Undo in one action
https://i.gyazo.com/b65cb245ce958f3ff71501aecdc77008.mp4
Default:
"AWT-EventQueue-0 2016.3.4#IC-163.12024.16 IDEA, eap:false, os:Windows 10 10.0, java-version:Oracle Corporation 1.8.0_65-b17@2879"
prio=6 tid=0x18 nid=NA runnable
------------------------------------------------------------------------------------------
ProgressManager.getInstance().runProcessWithProgressSynchronously:
"AWT-EventQueue-0 2016.3.4#IC-163.12024.16 IDEA, eap:false, os:Windows 10 10.0, java-version:Oracle Corporation 1.8.0_65-b17@2879"
prio=6 tid=0x18 nid=NA waiting
"ApplicationImpl pooled thread 9@14747"
prio=4 tid=0x31 nid=NA runnable
------------------------------------------------------------------------------------------
InvokeLater:
"AWT-EventQueue-0 2016.3.4#IC-163.12024.16 IDEA, eap:false, os:Windows 10 10.0, java-version:Oracle Corporation 1.8.0_65-b17@2879"
prio=6 tid=0x18 nid=NA runnable
runProcessWithProgressAsynchronously (Not freezes, but broken undo)
Each action perform undo separately
https://i.gyazo.com/b2956eb1cf825178f03c36a2c82754bc.mp4
Default:
"AWT-EventQueue-0 2016.3.4#IC-163.12024.16 IDEA, eap:false, os:Windows 10 10.0, java-version:Oracle Corporation 1.8.0_65-b17@2876"
prio=6 tid=0x18 nid=NA runnable
------------------------------------------------------------------------------------------
ProgressManager.getInstance().runProcessWithProgressSynchronously:
"AWT-EventQueue-0 2016.3.4#IC-163.12024.16 IDEA, eap:false, os:Windows 10 10.0, java-version:Oracle Corporation 1.8.0_65-b17@2876"
prio=6 tid=0x18 nid=NA waiting
"ApplicationImpl pooled thread 6@14367"
prio=4 tid=0x2e nid=NA runnable
------------------------------------------------------------------------------------------
InvokeLater:
"AWT-EventQueue-0 2016.3.4#IC-163.12024.16 IDEA, eap:false, os:Windows 10 10.0, java-version:Oracle Corporation 1.8.0_65-b17@2876"
prio=6 tid=0x18 nid=NA runnable
with highlight:
Sorry, I understand just about nothing in this message. What do all these thread names mean? Have you tried my suggestion from the previous comment?
Same command name and groupId have no effect.
Two Commands performs async via #runProcessWithProgressAsynchronously. Both undoable separately.
1) ProgressManager:
https://github.com/CeH9/PackageTemplates/blob/4b7bc276cd78f056e4660668545251d53da3fe83/src/global/utils/ProgressHelper.java#L30
2) First command
https://github.com/CeH9/PackageTemplates/blob/4b7bc276cd78f056e4660668545251d53da3fe83/src/core/actions/custom/CreateDirectoryAction.java#L146-L153
3) Second one
https://github.com/CeH9/PackageTemplates/blob/4b7bc276cd78f056e4660668545251d53da3fe83/src/global/utils/file/FileWriter.java#L147-L165
Changes that modify files are not merged by the undo engine, I'm afraid. The only way to have 'atomic' undo is to make the changes inside one command.