views:

30

answers:

1

Hi folks,

Is there a way to know the type of a selected project? I would like to do some specific actions depending of the project type like a J2SE project.

Below is the only way that I found to do that:

public final class MyAction extends CookieAction { 

@Override 
public boolean isEnabled() { 
  if(this.getActivatedNodes() == null || this.getActivatedNodes().length != 1) { 
        return false; 
    } 

    Lookup lookup = this.getActivatedNodes()[0].getLookup(); 

    // gets the selected project 
    Project currentProject = lookup.lookup(Project.class); 

    // checks if the selected project is a J2SE Project or a Maven Project 
    if(currentProject != null && (currentProject.getClass().getSimpleName().equals("J2SEProject") 
            || currentProject.getClass().getSimpleName().equals("NbMavenProjectImpl"))) { 
        return true; 
    } 

    return false;

}}
A: 

There is an api to get you info about a NetBeans project. It may be useful.

There is a number of APIs that work with project objects. It is likely that you will find some useful APIs in there.

vkraemer
In these links there is no method or class to get a project type. These classes don't provide a method or a way to get the project type and the ProjectInformation class just provide the project display name but I would like to know the project type, for example, PHP Project, Java project, Maven Project, Ruby Project.
Fabio