projectviewer.vpt
Class VPTProject

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by projectviewer.vpt.VPTNode
          extended by projectviewer.vpt.VPTProject
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<VPTNode>, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public class VPTProject
extends VPTNode

Models a project. A project is a container for files and directories. It also provides interfaces for event notification and custom properties, so that other plugins can interact with projects.

Note: this class is not thread safe!

Author:
Marcelo Vanzin
See Also:
Serialized Form

Field Summary
protected  java.util.Map<java.lang.String,VPTNode> openableNodes
           
protected static javax.swing.Icon projectIcon
           
 
Fields inherited from class projectviewer.vpt.VPTNode
name, treeNoSelectionBackground, treeNoSelectionForeground, treeSelectionBackground, treeSelectionForeground
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
VPTProject(java.lang.String name)
           
 
Method Summary
 void addFilter(VPTFilterData filter)
          Adds a "filtered tree" filter to the project's filter list.
 void addOpenFile(java.lang.String path)
          Adds a file to the list of the project's opened files.
 void clearOpenFiles()
          Clears the list of open files.
 void closeFiles(org.gjt.sp.jedit.View view, boolean bRemember)
          Closes open files belonging to the project.
 int compareTo(VPTNode node)
          Projects have precedence over everything but groups.
 void fireFilesChanged(java.util.Collection<VPTFile> added, java.util.Collection<VPTFile> removed)
          Notifies the listeners that a group of files has been added to and/or removed from the project.
 void firePropertiesChanged()
          Notifies the listeners that a single file has been added to the project.
 VPTNode getChildNode(java.lang.String path)
          Returns the node that matches the given path.
 java.util.List<VPTFilterData> getFilterList()
          Returns the list of filters set for this project, or Collections.EMPTY_LIST if no filters are set.
 javax.swing.Icon getIcon(boolean expanded)
          Returns the icon to be shown on the tree next to the node name.
 java.lang.String getIconPath()
          Returns the custom icon path of this project.
protected  java.util.concurrent.locks.ReadWriteLock getLock()
          Returns the read-write lock used to project the project.
 java.lang.String getNodePath()
          Returns the path to the file represented by this node.
 java.util.Collection<VPTNode> getOpenableNodes()
          Returns a collection of the nodes that can be opened contained in this project.
 java.util.List<java.lang.String> getOpenFiles()
          Returns the list of open files the project knows about.
 java.util.Properties getProperties()
          Return the project's property set.
 java.lang.String getProperty(java.lang.String property)
          Returns the property stored for the given key, as a String.
 java.util.Set getPropertyNames()
          Returns a set containing all property names for this project.
 java.lang.String getRootPath()
          Returns the path to the root of the project.
 java.lang.String getURL()
          Returns the project's URL.
 boolean isInProject(java.lang.String path)
          Returns whether the project contains a node that can be opened that matches the given path.
 void registerNodePath(VPTNode node)
          Register a node in the project, adding it to the mapping of paths to nodes kept internally.
 void removeAllChildren()
          Removes all children from the project, and unregisters all files.
 void removeOpenFile(java.lang.String path)
          Remove an open file from the list.
 java.lang.Object removeProperty(java.lang.String property)
          Removes the given property from the project.
 void setFilterList(java.util.List<VPTFilterData> filterList)
          Sets the list of filters particular to this project.
 void setIconPath(java.lang.String path)
          Sets the icon to be shown on the tree next to the project name.
 java.lang.String setProperty(java.lang.String name, java.lang.String value)
          Sets a property.
 void setRootPath(java.lang.String path)
          Sets the path to the root of the project.
 void setURL(java.lang.String url)
          Sets the project's URL.
 java.lang.String toString()
          Returns a string representation of the current node.
 void unregisterNodePath(java.lang.String path)
          Unegister a node path from the project.
 void unregisterNodePath(VPTNode node)
          Unegister a node from the project.
 
Methods inherited from class projectviewer.vpt.VPTNode
canOpen, canRename, canWrite, changed, close, compareName, delete, findIndexForChild, findProjectFor, getBackgroundColor, getChildWithName, getClipType, getForegroundColor, getGroup, getName, getVersionControlState, insert, isDirectory, isFile, isGroup, isOpened, isProject, isRoot, lock, open, persistChildren, remove, remove, removeFromParent, setName, setParent, setVersionControlState, sortChildren, sortChildren, unlock
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, setAllowsChildren, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

projectIcon

protected static final javax.swing.Icon projectIcon

openableNodes

protected java.util.Map<java.lang.String,VPTNode> openableNodes
Constructor Detail

VPTProject

public VPTProject(java.lang.String name)
Method Detail

getChildNode

public VPTNode getChildNode(java.lang.String path)
Returns the node that matches the given path. Despite the name (too late to change, don't want to break other plugins), this only applies to "openable nodes", i.e., nodes whose canOpen() method return true and which are correcty registered with their respective projects.


getOpenableNodes

public java.util.Collection<VPTNode> getOpenableNodes()
Returns a collection of the nodes that can be opened contained in this project.


getURL

public java.lang.String getURL()
Returns the project's URL.


setURL

public void setURL(java.lang.String url)
Sets the project's URL.


getProperty

public java.lang.String getProperty(java.lang.String property)
Returns the property stored for the given key, as a String.


setProperty

public java.lang.String setProperty(java.lang.String name,
                                    java.lang.String value)
Sets a property.

Returns:
The old value for the property (can be null).

getPropertyNames

public java.util.Set getPropertyNames()
Returns a set containing all property names for this project.


removeProperty

public java.lang.Object removeProperty(java.lang.String property)
Removes the given property from the project.


getProperties

public java.util.Properties getProperties()
Return the project's property set.


getOpenFiles

public java.util.List<java.lang.String> getOpenFiles()
Returns the list of open files the project knows about.


addOpenFile

public void addOpenFile(java.lang.String path)
Adds a file to the list of the project's opened files.


removeOpenFile

public void removeOpenFile(java.lang.String path)
Remove an open file from the list.

Since:
PV 2.1.3.5

clearOpenFiles

public void clearOpenFiles()
Clears the list of open files.


closeFiles

public void closeFiles(org.gjt.sp.jedit.View view,
                       boolean bRemember)
Closes open files belonging to the project.

Parameters:
bRemember - Whether to remember the files to open them next time. Current buffer is remembered last. This behaviour is copied from ProjectViewer.closeProject which previously was closing files.
Since:
3.4.0

isInProject

public boolean isInProject(java.lang.String path)
Returns whether the project contains a node that can be opened that matches the given path.


getIcon

public javax.swing.Icon getIcon(boolean expanded)
Returns the icon to be shown on the tree next to the node name.

Specified by:
getIcon in class VPTNode
Parameters:
expanded - If the node is currently expanded or not.

setIconPath

public void setIconPath(java.lang.String path)
Sets the icon to be shown on the tree next to the project name.

Parameters:
path - The path to the new icon (null for default).
Since:
PV 3.0.1

getIconPath

public java.lang.String getIconPath()
Returns the custom icon path of this project.

Returns:
The custom icon path, or null if no custom icon is set.
Since:
PV 3.0.1

toString

public java.lang.String toString()
Returns a string representation of the current node.

Overrides:
toString in class VPTNode

getRootPath

public java.lang.String getRootPath()
Returns the path to the root of the project.


setRootPath

public void setRootPath(java.lang.String path)
Sets the path to the root of the project.


registerNodePath

public void registerNodePath(VPTNode node)
Register a node in the project, adding it to the mapping of paths to nodes kept internally. Only openable nodes are mapped.


removeAllChildren

public void removeAllChildren()
Removes all children from the project, and unregisters all files.

Overrides:
removeAllChildren in class VPTNode

unregisterNodePath

public void unregisterNodePath(VPTNode node)
Unegister a node from the project.


unregisterNodePath

public void unregisterNodePath(java.lang.String path)
Unegister a node path from the project.

Since:
PV 2.1.3.6

getNodePath

public java.lang.String getNodePath()
Returns the path to the file represented by this node.

Specified by:
getNodePath in class VPTNode

compareTo

public int compareTo(VPTNode node)
Projects have precedence over everything but groups.

Specified by:
compareTo in interface java.lang.Comparable<VPTNode>
Overrides:
compareTo in class VPTNode

addFilter

public void addFilter(VPTFilterData filter)
Adds a "filtered tree" filter to the project's filter list.

Since:
PV 2.2.2.0

setFilterList

public void setFilterList(java.util.List<VPTFilterData> filterList)
Sets the list of filters particular to this project.

Since:
PV 2.2.2.0

getFilterList

public java.util.List<VPTFilterData> getFilterList()
Returns the list of filters set for this project, or Collections.EMPTY_LIST if no filters are set.

Since:
PV 2.2.2.0

getLock

protected java.util.concurrent.locks.ReadWriteLock getLock()
Returns the read-write lock used to project the project.

Overrides:
getLock in class VPTNode
Since:
PV 3.0.0

fireFilesChanged

public void fireFilesChanged(java.util.Collection<VPTFile> added,
                             java.util.Collection<VPTFile> removed)
Notifies the listeners that a group of files has been added to and/or removed from the project.


firePropertiesChanged

public void firePropertiesChanged()
Notifies the listeners that a single file has been added to the project.