org.netbeans.modules.versioning/1 1.32.0 1

org.netbeans.modules.versioning.spi
Class VCSContext

java.lang.Object
  extended by org.netbeans.modules.versioning.spi.VCSContext

public final class VCSContext
extends Object

This encapsulates a context, typically set of selected files or nodes. Context is passed to VCSAnnotators when asked for actions available on a given context or to annotate a name (label) representing a context.


Field Summary
static VCSContext EMPTY
          VCSContext that contains no files.
 
Method Summary
 Set<File> computeFiles(FileFilter filter)
          Returns the smallest possible set of all files that lie under Root files and are NOT under some Excluded file.
 boolean contains(File file)
          Determines whether the supplied File is contained in this context.
static VCSContext forNodes(Node[] nodes)
          Initializes the context from array of nodes (typically currently activated nodes).
 Lookup getElements()
          Retrieves elements that make up this VCS context.
 Set<File> getExclusions()
          Retrieves set of files/folders that are excluded from this context.
 Set<File> getFiles()
          Retrieves set of files/folders that represent this context.
 Set<File> getRootFiles()
          Retrieves set of root files/folders that represent this context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

public static final VCSContext EMPTY
VCSContext that contains no files.

Method Detail

forNodes

public static VCSContext forNodes(Node[] nodes)
Initializes the context from array of nodes (typically currently activated nodes). Nodes are converted to Files based on their nature. For example Project Nodes are queried for their SourceRoots and those roots become root files of this context and exclusions list is constructed using sourceRoot.contains() queries. Nodes' lookups are examined in the following way (the first applied rule wins): - if there's a File, the File is added to set of root files - if there's a Project, project's source roots of type Sources.TYPE_GENERIC are added to set of root files and all direct children that do not belong to the project (sg.contains() == false) are added to set of exclusions - if there's a FileObject, it is added to set of root files - if there's a DataObject, all dao.files() are added to set of root files

Parameters:
nodes - array of Nodes
Returns:
VCSContext containing nodes and corresponding files they represent

computeFiles

public Set<File> computeFiles(FileFilter filter)
Returns the smallest possible set of all files that lie under Root files and are NOT under some Excluded file. Technically, for every file in the returned set all of the following is true: - the file itself or at least one of its ancestors is a root file/folder - neither the file itself nor any of its ancestors is an exluded file/folder - the file passed through the supplied FileFilter

Parameters:
filter - custom file filter
Returns:
filtered set of files that must pass through the filter

getElements

public Lookup getElements()
Retrieves elements that make up this VCS context. The returned lookup may be empty or may contain any number of the following elements: - instances of Node that were originally used to construct this context object

Returns:
Lookup lookup of this VCSContext

getFiles

public Set<File> getFiles()
Retrieves set of files/folders that represent this context. This set contains all files the user selected, unfiltered. For example, if the user selects two elements: folder /var and file /var/Foo.java then getFiles() returns both of them and getRootFiles returns only the folder /var. This method is suitable for versioning systems that DO manage folders, such as Clearcase.

Returns:
Set set of Files this context represents
Since:
1.6
See Also:
getRootFiles()

getRootFiles

public Set<File> getRootFiles()
Retrieves set of root files/folders that represent this context. This set only contains context roots, not files/folders that are contained within these roots. For example, if the user selects two elements: folder /var and file /var/Foo.java then getFiles() returns both of them and getRootFiles returns only the folder /var. This method is suitable for versioning systems that do not manage folders, such as CVS.

Returns:
Set set of Files this context represents
See Also:
getFiles()

getExclusions

public Set<File> getExclusions()
Retrieves set of files/folders that are excluded from this context. Exclusions are files or folders that are descendants of a root folder and should NOT be a part of a versioning operation. For example, an CVS/Update command run on a project that contains a subproject should not touch any files in the subproject. Therefore the VCSContext for the action would contain one root file (the project's root) and one exclusion (subproject root).

Returns:
Set set of files and folders that are not part of (are excluded from) this context. All their descendands are excluded too.

contains

public boolean contains(File file)
Determines whether the supplied File is contained in this context. In other words, the file must be either a root file/folder or be a descendant of a root folder and also must NOT be an excluded file/folder or be a descendant of an excluded folder.

Parameters:
file - a File to test
Returns:
true if this context contains the supplied file, false otherwise

org.netbeans.modules.versioning/1 1.32.0 1

Built on May 25 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.