Skip to main content

NetBeans Plugin Dev : Listing all packages from default main project

Posted by edgars on January 17, 2007 at 5:25 AM PST

Hi everybody, after some free time this week, I am almost finishing the new JSF Palette for NetBeans. In the following image you can see its actual state:


As we are always doing comercial applications for serveral niches of business, it´s really cool to imagine you could work as an IDE Developer, while you aren't hired to do that, you can do it to help you save time in projects or simply for fun. I will show you now the secrets behind the following dialog:


I used this dialog when a user is inserting the tag f:loadBundle, in JSP source, we might set the package name, property file name and the var reference name to this tag. Than we are listing all packages from our default main project in a simple JComboBox. To do this, I am using the following code:

    protected void initializeComboPackages() {
        Project p = OpenProjects.getDefault().getMainProject();
        Sources src = (Sources) p.getLookup().lookup(Sources.class);
        if (src!=null)  {
            SourceGroup[] groups = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
            if (groups.length>0) {
               SourceGroup group = groups[0];

In the code "packages" is a JComboBox.
If you want create some plugin using similar feature, now you have this described here.


Edgar Silva - edgar (em)

Related Topics >>