sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r948054474
##########
ide/projectapi/src/org/netbeans/api/project/ProjectUtils.java:
##########
@@ -57,6 +61,65 @@ private ProjectUtils() {}
private static final Logger LOG =
Logger.getLogger(ProjectUtils.class.getName());
+ /**
+ * Returns the active configuration for the given project. Returns {@code
null},
+ * if the project does not support configurations at all.
+ *
+ * @param p the project
+ * @return the active configuration, or {@code null} if configurations are
not supported.
+ * @since 1.89
+ */
+ public ProjectConfiguration getActiveConfiguration(@NonNull Project p) {
+ ProjectConfigurationProvider pcp =
p.getLookup().lookup(ProjectConfigurationProvider.class);
+ if (pcp == null) {
+ return null;
+ }
+ return ProjectManager.mutex().readAccess(() ->
pcp.getActiveConfiguration());
+ }
+
+ /**
+ * Sets the active configuration to a project. The configuration should
have been previously obtained by
+ * {@link #getActiveConfiguration(org.netbeans.api.project.Project)} from
the same project. The method
+ * returns {@code false}, if the configuration could not be set: if the
project does not support configurations
+ * at all, or the project failed to switch the configurations. Since the
active configuration setting is persisted,
+ * the method throws {@link IOException} if the setting save fails.
+ *
+ * @param <C> configuration type
+ * @param p the project
+ * @param cfg configuration or {@code null} for default configuration.
+ * @return true, if the configuration was successfully set.
+ * @throws IOException when the selected configuration cannot be persisted.
+ * @since 1.89
+ */
+ public <C extends ProjectConfiguration> boolean
setActiveConfiguration(@NonNull Project p, @NonNull C cfg) throws IOException {
Review Comment:
The project API itself is using generics ... (?)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists