Class ProjectActionContext
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 apply(java.lang.Runnable, org.netbeans.api.project.ProjectActionContext...)
; the implementation may then use 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.
- Since:
- 1.89
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Builder used to construct theProjectActionContext
.static interface
ProjectActionContext.ProjectCallback<V, E extends Exception>
Functional callback interface to be used withapply(org.netbeans.modules.project.dependency.ProjectActionContext.ProjectCallback, org.netbeans.modules.project.dependency.ProjectActionContext...)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(Runnable r, ProjectActionContext... otherProjectContexts) Executes a query using this project context.<V, E extends Exception>
Vapply
(ProjectActionContext.ProjectCallback<V, E> r, ProjectActionContext... otherProjectContexts) Executes a query using this project context.boolean
static ProjectActionContext
Find the ProjectActionContext for the project.The project configuration to use for the project query.org.openide.util.Lookup
Additional information for the underlying project implementation, similar to context lookup inActionProvider.invokeAction(java.lang.String, org.openide.util.Lookup)
.Profiles or some project system features/tags that should be applied for the evaluation.Returns the project this context applies to.The project action in whose context the project queries are performed.User-customized properties that should be effective during the computation.int
hashCode()
static ProjectActionContext.Builder
Creates a newProjectActionContext
builder for the given project.Creates a Builder to create a similar ProjectActionContext to this one.
-
Method Details
-
getProject
-
getLookup
public org.openide.util.Lookup getLookup()Additional information for the underlying project implementation, similar to context lookup inActionProvider.invokeAction(java.lang.String, org.openide.util.Lookup)
. Project service implementors may optimize, if the returned value isLookup.EMPTY
reference.- Returns:
- Lookup with additional information.
-
getProjectAction
The project action in whose context the project queries are performed. May be left unspecified, so the implementation can choose an appropriate default behaviour.- Returns:
- project aciton or
null
for unspecified.
-
getConfiguration
The project configuration to use for the project query. Can benull
to indicate the project's default Configuration should be used.- Returns:
- the project's configuration or
null
.
-
getProperties
User-customized properties that should be effective during the computation. The same customization should be made during project action execution to obtain the same results as evaluated by the query. If none specific properties are present, an empty map is returned.- Returns:
- user properties
-
getProfiles
-
newDerivedBuilder
Creates a Builder to create a similar ProjectActionContext to this one. All settings are copied to the Builder, so just callingProjectActionContext.Builder.context()
on the result will produce a copy of thisProjectActionContext
.- Returns:
- preconfigured
ProjectActionContext.Builder
instance.
-
newBuilder
Creates a newProjectActionContext
builder for the given project.- Parameters:
p
- the project- Returns:
- the builder instance
-
find
Find the ProjectActionContext for the project. If no context was specified explicitly,- Parameters:
p
- the project in question- Returns:
- the context
-
apply
Executes a query using this project context. Other contexts may be specified as well (optional). During the passedRunnable
, or tasks initiated from the Runnable, thefind(org.netbeans.api.project.Project)
method will find the appropriateProjectActionContext
specified as parameter.- Parameters:
r
- the code to execute.otherProjectContexts
- optional instances for other projects
-
apply
public <V, E extends Exception> V apply(ProjectActionContext.ProjectCallback<V, E> r, ProjectActionContext... otherProjectContexts) throws EExecutes a query using this project context. Other contexts may be specified as well (optional). During the passedRunnable
, or tasks initiated from the Runnable, thefind(org.netbeans.api.project.Project)
method will find the appropriateProjectActionContext
specified as parameter.- Type Parameters:
V
- the return typeE
- exception thrown from the executed code.- Parameters:
r
- the code to execute.otherProjectContexts
- optional instances for other projects- Throws:
E
-
hashCode
-
equals
-