8
有沒有辦法知道所選項目的類型?我想根據項目類型做一些特定的操作,如J2SE項目。如何在Netbeans平臺上獲得項目類型?
下面是我發現這樣做的唯一方法:
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;
}}