dolphinsmalltalk / Dolphin

Dolphin Smalltalk Core Image
MIT License
301 stars 58 forks source link

Command queries can be zero-arg testing methods #1207

Closed blairmcg closed 9 months ago

blairmcg commented 9 months ago

Many command queries do nothing other than set the enablement of the command, in which case the code is simpler and smaller if a command query method can be a simple testing method that takes no arguments and returns true if the command is to be enabled, or false if disabled.

This seems to apply to the majority of cases visited so far, and in quite a few cases allows for the use of existing testing methods to be used, reducing the proliferation of individual query methods specific to individual commands or related groups of commands.

Also perform some validation of the query annotations, since it is easy to make a small mistake, such as mispelling a selector, and end up breaking the command handling in the development tools. As the command queries are often called repeatedly as a background/idle task to revalidate the UI state (e.g. for toolbar buttons), this can cause repetitive errors that are at best annoying, and at worst terminal.

Replace old #queryCommand: methods in MoenTreeView, Card containers, collection presenters and workspace classes.