You should extend a ProjectOpenedHook implementing the appropriate methods and ten add your extension to your Project's Lookup
NetBeans; How to Listen for Project Created/Opened/Closed Events
-
28-06-2022 - |
Question
I created a NetBeans module with, among other things, a custom project type. Then I decided to move some of the project-related stuff, including actions related to opening, creating and closing a project, to a separate library, to reduce dependency on the NetBeans platform.
Now I need to call code in the library when project is created, opened or closed in NetBeans, but I don't know how to get notified of those events. Can someone help?
Solution
OTHER TIPS
Antonio's suggestion works great, I just want to add some extra info.
To create a project, I created a Project Template, from an empty project. In the generated WizardIterator class, I replaced the call to unZipFile() with call my Project.create()
ProjectFactory's loadProject() method can also be used to trigger logic related to opening a project.
I handle project closing as Antonio suggested.