8
Seçilen bir projenin türünü bilmenin bir yolu var mı? Bir J2SE projesi gibi proje türüne bağlı olarak bazı özel eylemler yapmak istiyorum.Netbeans Platform'da proje türünü nasıl alabilirim?
Aşağıda bunu yapmak bulunan tek yoludur: -> aksiyon -
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;
}}