If you're running a data catalog extension where most/all of the objects in the library depend on data catalogs, it can be dangerous to place these objects before the .db3 file has been downloaded. Instead of having a check in each snapper, it's easier to suppress the library from showing anything until at least the database has finished loading.
-
Make a hook that whenever a catalog is loaded, calls
updateLibAfterNewDB()
.
In extension.cm:/** * Extension. */ public class GenericCatalogExtension extends SimpleCatalogExtension { /** * Initialize. */ public void initialize(ExtensionEnv env) { super(env); registerDsEmbeddedCatalog(genericCatalogNumber, "GenericCatalogName", {"GenericCatalogName"}); } /** * Start. */ public void start(ExtensionEnv env) { //register the catalog, may be done somewhere else newDataCatalogHooks << function updateLibAfterNewDB; //this hook will be called whenever a catalog has finished downloading super(env); } }
-
Rebuild the toolbox when the specific catalog has finished downloading. Also, when you re-open CET it will notice the catalog has already been loaded.
In library.cm:/** * A new catalog db has been retrieved, update lib accordingly */ package void updateLibAfterNewDB(CtlgBrwsrCatalogs cats) { if (cats and cats._key == "GenericCatalogName") { library = null; genericRebuildToolboxes("#custom.generic.productLine"); } } /** * Generic toolbox rebuild function. */ public void genericRebuildToolboxes(str pkg, World world=null) { if (application.toolbox) { for (card in application.toolbox.childWindows) { if (card as LazyLibraryCard) { if (card.libraryFunctionPkg.toS.beginsWith(pkg)) { card.requestLazyRebuild(true); } } } } }
- Check to see if the catalog is loaded. If it's loaded, use the regular library. If not, load a library that tells the user the data isn't ready yet but will refresh when the data is loaded.
/** * Catalog is loaded? */ private bool catalogLoaded = false; public Library genericLibrary() { if (!catalogLoaded) { catalogLoaded = ctlgBrwsrCatalogs(genericCatalogNumber, "GenericCatalogName") != null; } if (catalogLoaded) return genericLoadedLibrary(); return genericUnloadedLibrary(); } public Library genericLoadedLibrary() { if (developMode) library = null; if (!library) { symbol pkg = (#:package); Library lib = library(pkg=pkg) { container LibraryLimb root("GenericFlapHeader") { //Put all the library icons here!! } }; library = lib; } return library; } public Library genericUnloadedLibrary() { if (developMode) library = null; if (!library) { symbol pkg = (#:package); Library lib = library(pkg=pkg) { container LibraryLimb root("GenericFlapHeader") { limb HeaderLimb txt("genericLoading", image=genericIcon("genericLoadingMessage")); } }; library = lib; } return library; }
Comments
0 comments
Please sign in to leave a comment.