How can I get a project type on Netbeans Platform?
        Posted  
        
            by Fabio
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Fabio
        
        
        
        Published on 2010-06-11T14:22:25Z
        Indexed on 
            2010/06/11
            14:43 UTC
        
        
        Read the original article
        Hit count: 253
        
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;
}}
        © Stack Overflow or respective owner