Baking a First Cookie for a NetBeans Module's Data Object
By Geertjan-Oracle on May 26, 2005
To enable them, you need to create a cookie. In the context of NetBeans Modules, a cookie has nothing to do with the message sent from a web server to a web browser. It's a completely different concept. (I don't know why it's the same word, but there are probably entirely logical historical reasons for it.) Reading and browsing through various documents, I've come across the following handy definition of what a cookie is: "Cookies are design patterns that you attach to a data object or a node to add functionality to the data object or the node. Cookies provide information to the the IDE or Platform about the types of operations that data objects or nodes are capable of supporting."
There are various ways to create cookies. The simplest (and hence the one that I'm most drawn to!) is to modify the data object by providing an ad-hoc implementation of a cookie interface (such as OpenCookie, ViewCookie, or EditCookie) and adding it to the CookieSet instance. So, it's best to show this in a screenshot:
As can be seen in the above screenshot, the OpenCookie interface has been implemented and added to the CookieSet instance. As a result (after rebuilding and reloading the module) the Open item is now enabled. Nothing can be done with it yet (it currently provides a JoptionPane with the text "Open Sesame!") but at least the item is now enabled. And... I've finally managed to bake my first cookie!