| java.lang.Object org.netbeans.spi.project.support.ant.SourcesHelper
SourcesHelper | final public class SourcesHelper (Code) | | Helper class to work with source roots and typed folders of a project.
author: Jesse Glick |
Method Summary | |
public void | addNonSourceRoot(String location) Similar to
SourcesHelper.addPrincipalSourceRoot but affects only
SourcesHelper.registerExternalRoots and not
SourcesHelper.createSources .
Useful for project type providers which have external paths holding build
products. | public void | addOwnedFile(String location) Add any file that is supposed to be owned by a given project
via FileOwnerQuery, affects only
SourcesHelper.registerExternalRoots
and not
SourcesHelper.createSources .
Useful for project type providers which have external paths holding build
products. | public void | addPrincipalSourceRoot(String location, String displayName, Icon icon, Icon openedIcon) Add a possible principal source root, or top-level folder which may
contain sources that should be considered part of the project. | public void | addPrincipalSourceRoot(String location, String includes, String excludes, String displayName, Icon icon, Icon openedIcon) Add a possible principal source root, or top-level folder which may
contain sources that should be considered part of the project, with
optional include and exclude lists.
If an include or exclude string is given as null, then it is skipped. | public void | addTypedSourceRoot(String location, String type, String displayName, Icon icon, Icon openedIcon) Add a typed source root which will be considered only in certain contexts. | public void | addTypedSourceRoot(String location, String includes, String excludes, String type, String displayName, Icon icon, Icon openedIcon) Add a typed source root with optional include and exclude lists. | public Sources | createSources() Create a source list object.
All principal source roots are listed as
Sources.TYPE_GENERIC unless they
are inside the project directory. | public void | registerExternalRoots(int algorithm) Register all external source or non-source roots using
FileOwnerQuery.markExternalOwner .
Only roots added by
SourcesHelper.addPrincipalSourceRoot and
SourcesHelper.addNonSourceRoot are considered. |
SourcesHelper | public SourcesHelper(AntProjectHelper project, PropertyEvaluator evaluator)(Code) | | Create the helper object, initially configured to recognize only sources
contained inside the project directory.
Parameters: project - an Ant project helper Parameters: evaluator - a way to evaluate Ant properties used to define source locations |
addPrincipalSourceRoot | public void addPrincipalSourceRoot(String location, String displayName, Icon icon, Icon openedIcon) throws IllegalStateException(Code) | | Add a possible principal source root, or top-level folder which may
contain sources that should be considered part of the project.
If the actual value of the location is inside the project directory,
this is simply ignored; so it safe to configure principal source roots
for any source directory which might be set to use an external path, even
if the common location is internal.
Parameters: location - a project-relative or absolute path giving the locationof a source tree; may contain Ant property substitutions Parameters: displayName - a display name (for SourceGroup.getDisplayName) Parameters: icon - a regular icon for the source root, or null Parameters: openedIcon - an opened variant icon for the source root, or null throws: IllegalStateException - if this method is called after eitherSourcesHelper.createSources or SourcesHelper.registerExternalRootswas called See Also: SourcesHelper.registerExternalRoots See Also: Sources.TYPE_GENERIC |
addPrincipalSourceRoot | public void addPrincipalSourceRoot(String location, String includes, String excludes, String displayName, Icon icon, Icon openedIcon) throws IllegalStateException(Code) | | Add a possible principal source root, or top-level folder which may
contain sources that should be considered part of the project, with
optional include and exclude lists.
If an include or exclude string is given as null, then it is skipped. A non-null value is
evaluated and then treated as a comma- or space-separated pattern list,
as detailed in the Javadoc for
PathMatcher .
(As a special convenience, a value consisting solely of an Ant property reference
which cannot be evaluated, e.g. ${undefined}, is treated like null.)
SourceGroup.contains will then reflect the includes and excludes for files, but note that the
semantics of that method requires that a folder be "contained" in case any folder or file
beneath it is contained, and in particular the root folder is always contained.
Parameters: location - a project-relative or absolute path giving the locationof a source tree; may contain Ant property substitutions Parameters: includes - Ant-style includes; may contain Ant property substitutions;if not null, only files and foldersmatching the pattern (or patterns), and not specified in the excludes list,will be SourceGroup.contains included Parameters: excludes - Ant-style excludes; may contain Ant property substitutions;if not null, files and foldersmatching the pattern (or patterns) will not be SourceGroup.contains included,even if specified in the includes list Parameters: displayName - a display name (for SourceGroup.getDisplayName) Parameters: icon - a regular icon for the source root, or null Parameters: openedIcon - an opened variant icon for the source root, or null throws: IllegalStateException - if this method is called after eitherSourcesHelper.createSources or SourcesHelper.registerExternalRootswas called See Also: SourcesHelper.registerExternalRoots See Also: Sources.TYPE_GENERIC since: org.netbeans.modules.project.ant/1 1.15 |
addTypedSourceRoot | public void addTypedSourceRoot(String location, String includes, String excludes, String type, String displayName, Icon icon, Icon openedIcon) throws IllegalStateException(Code) | | Add a typed source root with optional include and exclude lists.
See
SourcesHelper.addPrincipalSourceRoot(String,String,String,String,Icon,Icon) for details on semantics of includes and excludes.
Parameters: location - a project-relative or absolute path giving the locationof a source tree; may contain Ant property substitutions Parameters: includes - an optional list of Ant-style includes Parameters: excludes - an optional list of Ant-style excludes Parameters: type - a source root type such as JavaProjectConstants.SOURCES_TYPE_JAVA Parameters: displayName - a display name (for SourceGroup.getDisplayName) Parameters: icon - a regular icon for the source root, or null Parameters: openedIcon - an opened variant icon for the source root, or null throws: IllegalStateException - if this method is called after eitherSourcesHelper.createSources or SourcesHelper.registerExternalRootswas called since: org.netbeans.modules.project.ant/1 1.15 |
createSources | public Sources createSources()(Code) | | Create a source list object.
All principal source roots are listed as
Sources.TYPE_GENERIC unless they
are inside the project directory. The project directory itself is also listed
(with a display name according to
ProjectUtils.getInformation ), unless
it is contained by an explicit principal source root (i.e. ancestor directory).
Principal source roots should never overlap; if two configured
principal source roots are determined to have the same root folder, the first
configured root takes precedence (which only matters in regard to the display
name); if one root folder is contained within another, the broader
root folder subsumes the narrower one so only the broader root is listed.
Other source groups are listed according to the named typed source roots.
There is no check performed that these do not overlap (though a project type
provider should for UI reasons avoid this situation).
Any source roots which do not exist on disk are ignored, as if they had
not been configured at all. Currently it is not defined when this existence
check is performed (e.g. when this method is called, when the source root
is first accessed, periodically, etc.), so project type providers are
generally encouraged to make sure all desired source folders exist
before calling this method, if creating a new project.
Source groups are created according to the semantics described in
org.netbeans.spi.project.support.GenericSources.group . They are listed in the order they
were configured (for those roots that are actually used as groups).
You may call this method inside the project's constructor, but
Sources.getSourceGroups may not be called within the
constructor, as it requires the actual project object to exist and be
registered in
ProjectManager .
a source list object suitable for Project.getLookup |
registerExternalRoots | public void registerExternalRoots(int algorithm) throws IllegalArgumentException, IllegalStateException(Code) | | Register all external source or non-source roots using
FileOwnerQuery.markExternalOwner .
Only roots added by
SourcesHelper.addPrincipalSourceRoot and
SourcesHelper.addNonSourceRoot are considered. They are registered if (and only if) they in fact fall
outside of the project directory, and of course only if the folders really
exist on disk. Currently it is not defined when this file existence check
is done (e.g. when this method is first called, or periodically) or whether
folders which are created subsequently will be registered, so project type
providers are encouraged to create all desired external roots before calling
this method.
If the actual value of the location changes (due to changes being
fired from the property evaluator), roots which were previously internal
and are now external will be registered, and roots which were previously
external and are now internal will be unregistered. The (un-)registration
will be done using the same algorithm as was used initially.
If an explicit include list is configured for a principal source root, only those
subfolders which are included (or folders directly containing included files)
will be registered. Note that the source root, or an included subfolder, will
be registered even if it contains excluded files or folders beneath it.
Calling this method causes the helper object to hold strong references to the
current external roots, which helps a project satisfy the requirements of
FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT .
You may not call this method inside the project's constructor, as
it requires the actual project to exist and be registered in
ProjectManager .
Typically you would use
org.openide.util.Mutex.postWriteRequest to run it
later, if you were creating the helper in your constructor, since the project construction
normally occurs in read access.
Parameters: algorithm - an external root registration algorithm as perFileOwnerQuery.markExternalOwner throws: IllegalArgumentException - if the algorithm is unrecognized throws: IllegalStateException - if this method is called more than once on agiven SourcesHelper object |
|
|