-
Notifications
You must be signed in to change notification settings - Fork 1
DevFaqGetNameOfProjectGroup
org.netbeans.api.project.ui.OpenProjects.getDefault().getActiveProjectGroup().getName()
This approach uses a public API which is known to be stable for future versions. Since 7.3.
Note: this is rather a hack. It is not guaranteed that this will work for newer NetBeans versions. But this approach is known to work at least with NB 6.9.1 to 7.3.
/**
*
* @return name of the current project group or null
*/
public String getActiveProjectGroup() {
Preferences groupNode = getPreferences("org/netbeans/modules/projectui/groups");
if (null != groupNode) {
final String groupId = groupNode.get("active", null);
if (null != groupId) {
final Preferences groupPref = getPreferences("org/netbeans/modules/projectui/groups/" + groupId);
if (null != groupPref) {
final String activeProjectGroup = groupPref.get("name", null);
return activeProjectGroup;
}
}
}
return null;
}
/**
* Get the preference for the given node path.
*
* @param path configuration path like "org/netbeans/modules/projectui"
* @return {@link Preferences} or null
*/
private Preferences getPreferences(String path) {
try {
if (NbPreferences.root().nodeExists(path)) {
return NbPreferences.root().node(path);
}
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
return null;
}
The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.
This page was exported from http://wiki.netbeans.org/DevFaqGetNameOfProjectGroup , that was last modified by NetBeans user Markiewb on 2013-01-12T17:40:12Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-01-26, and needs to be reviewed.
Apache NetBeans is an effort undergoing incubation at The Apache Software Foundation (ASF).
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
This wiki is an experiment pending Apache NetBeans Community approval.