DataCleaner
DataCleaner copied to clipboard
Code improvement: Component icon loading convoluted and confusing
We have a set of icon loading utilities in IconUtils
and ImageManager
. There are several ways of getting these icon, but the overall names are getDescriptorIcon
, getIconFromData
and getImagePathForClass
.
Because of DataCloud, some data needs to be loaded using data in the descrptor itself, and others use the resource name of a file. However, the DataCloud icon implementation has mixed together several things. For example the HasIcon
is not only used to determine if the component provides its own data, but is used to decide the class is remote, meaning the icon will get a remote overlay slapped on it.
Local icons also has problems: The qualified class name is used to load the image... However, there's no attempt to just let the class load the icon resource (which would automatically load it from the correct package), instead a weird string replacement is done to load it using the the ImageManager
. A pretty terrible amount of indirection.
IconUtils also uses instanceof to choose datastore icons. It would probably be better if datastores could provide their preferred icon, so IconUtils doesn't need to know about every single datastore. This would also be a prerequisite for having Datastores in extensions and/or separate the UI properly from the engine.