public final class ProjectActionContext extends Object
ProjectConfiguration
or the IDE-supported project action and the associated properties, profiles, or Lookup may
affect behaviour of queries across the IDE.
Properties map to user-settable properties of the build system, such as system properties in Maven or project properties in Gradle.
Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
Instances of ProjectActionContext
may be passed to some queries as (part of the) parameters explicitly. In case
the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
query computation using ProjectActionContext.apply(java.lang.Runnable, org.netbeans.api.project.ProjectActionContext...)
; the implementation may then use ProjectActionContext.find(org.netbeans.api.project.Project)
to obtain a ProjectActionContext
effective for that project.
Important note: Not all project queries support ProjectActionContext
. Queries which do should mention that
fact in their documentation, or expose it in their APIs.
Modifier and Type | Class and Description |
---|---|
static class |
ProjectActionContext.Builder
Builder used to construct the
ProjectActionContext . |
static interface |
ProjectActionContext.ProjectCallback<V,E extends Exception>
Functional callback interface to be used with
#apply(org.netbeans.modules.project.dependency.ProjectActionContext.ProjectCallback, org.netbeans.modules.project.dependency.ProjectActionContext...) |
Modifier and Type | Method and Description |
---|---|
<V,E extends Exception> |
apply(ProjectActionContext.ProjectCallback<V,E> r,
ProjectActionContext... otherProjectContexts)
Executes a query using this project context.
|
void |
apply(Runnable r,
ProjectActionContext... otherProjectContexts)
Executes a query using this project context.
|
boolean |
equals(Object obj) |
static ProjectActionContext |
find(Project p)
Find the ProjectActionContext for the project.
|
ProjectConfiguration |
getConfiguration()
The project configuration to use for the project query.
|
Lookup |
getLookup()
Additional information for the underlying project implementation, similar to
context lookup in
ActionProvider.invokeAction(java.lang.String, org.openide.util.Lookup) . |
Set<String> |
getProfiles()
Profiles or some project system features/tags that should be applied for the evaluation.
|
Project |
getProject()
Returns the project this context applies to.
|
String |
getProjectAction()
The project action in whose context the project queries are performed.
|
Map<String,String> |
getProperties()
User-customized properties that should be effective during the computation.
|
int |
hashCode() |
static ProjectActionContext.Builder |
newBuilder(Project p)
Creates a new
ProjectActionContext builder for the given project. |
ProjectActionContext.Builder |
newDerivedBuilder()
Creates a Builder to create a similar ProjectActionContext to this one.
|
@NonNull public Project getProject()
Project
as a property allows multiple
contexts, individually for each project, to be active.public Lookup getLookup()
ActionProvider.invokeAction(java.lang.String, org.openide.util.Lookup)
.
Project service implementors may optimize, if the returned value is Lookup.EMPTY
reference.@CheckForNull public String getProjectAction()
null
for unspecified.@CheckForNull public ProjectConfiguration getConfiguration()
null
to
indicate the project's default Configuration should be used.null
.@NonNull public Map<String,String> getProperties()
@NonNull public Set<String> getProfiles()
@NonNull public ProjectActionContext.Builder newDerivedBuilder()
ProjectActionContext.Builder.context()
on
the result will produce a copy of this ProjectActionContext
.ProjectActionContext.Builder
instance.@NonNull public static ProjectActionContext.Builder newBuilder(Project p)
ProjectActionContext
builder for the given project.p
- the project@NonNull public static ProjectActionContext find(Project p)
p
- the project in questionpublic void apply(Runnable r, ProjectActionContext... otherProjectContexts)
Runnable
, or tasks initiated from the Runnable, the ProjectActionContext.find(org.netbeans.api.project.Project)
method
will find the appropriate ProjectActionContext
specified as parameter.r
- the code to execute.otherProjectContexts
- optional instances for other projectspublic <V,E extends Exception> V apply(ProjectActionContext.ProjectCallback<V,E> r, ProjectActionContext... otherProjectContexts) throws E extends Exception
Runnable
, or tasks initiated from the Runnable, the ProjectActionContext.find(org.netbeans.api.project.Project)
method
will find the appropriate ProjectActionContext
specified as parameter.V
- the return typeE
- exception thrown from the executed code.r
- the code to execute.otherProjectContexts
- optional instances for other projectsE extends Exception