projectviewer.vpt
Class VPTProject

java.lang.Object
  extended byjavax.swing.tree.DefaultMutableTreeNode
      extended byprojectviewer.vpt.VPTNode
          extended byprojectviewer.vpt.VPTProject
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, javax.swing.tree.MutableTreeNode, java.io.Serializable, 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!

Version:
$Id: VPTProject.java 8932 2007-02-09 05:29:17Z vanza $
Author:
Marcelo Vanzin
See Also:
Serialized Form

Field Summary
protected  java.util.HashMap openableNodes
           
 
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 filterData)
           
 void addOpenFile(java.lang.String path)
          Adds a file to the list of the project's opened files.
 void addProjectListener(ProjectListener lstnr)
          Adds a new listener to the list.
 void clearOpenFiles()
          Clears the list of open files.
 int compareToNode(VPTNode node)
          Projects have precedence over everything but groups.
 void fireFileAdded(VPTFile file)
          Notifies the listeners that a single file has been added to the project.
 void fireFileRemoved(VPTFile file)
          Notifies the listeners that a single file has been added to the project.
 void fireFilesChanged(java.util.ArrayList added, java.util.ArrayList 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.
 VPTFile getFile(java.lang.String path)
          Deprecated. Use getChildNode(String) instead.
 java.util.Collection getFiles()
          Deprecated. Use getOpenableNodes() instead.
 java.util.List 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 getNodePath()
          Returns the path to the file represented by this node.
 java.lang.Object getObjectProperty(java.lang.String property)
          Returns the property stored for the given key.
 java.util.Collection getOpenableNodes()
          Returns a read-only collection of the nodes that can be opened contained in this project.
 java.util.Iterator getOpenFiles()
          Returns an iterator to the list of open files that this project remembers.
 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 hasListeners()
          Returns whether there are any listeners registered.
 boolean isInProject(java.lang.String path)
          Returns whether the project contains a node that can be opened that matches the given path.
 boolean isProjectFile(java.lang.String path)
          Deprecated. Use isInProject(String) instead.
 void registerFile(VPTFile file)
          Register a file in the project, adding it to the list of files that belong to the project
 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.
 void removeProjectListener(ProjectListener lstnr)
          Removes a listener from the list.
 java.lang.Object removeProperty(java.lang.String property)
          Removes the given property from the project.
 void setFilterList(java.util.List filterList)
          Sets the list of filters particular to this project.
 java.lang.Object setProperty(java.lang.String name, java.lang.Object value)
          Sets a property.
 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 unloadProperties()
          This method will take all properties that are not Strings and serialize them into "DeferredProperty" instances.
 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, canWrite, close, compareName, compareTo, delete, findIndexForChild, findProjectFor, getBackgroundColor, getChildWithName, getClipType, getForegroundColor, getName, isDirectory, isFile, isGroup, isOpened, isProject, isRoot, open, persistChildren, setName, setParent, sortChildren, sortChildren
 
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, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeFromParent, setAllowsChildren, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

openableNodes

protected java.util.HashMap openableNodes
Constructor Detail

VPTProject

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

getFile

public VPTFile getFile(java.lang.String path)
Deprecated. Use getChildNode(String) instead.

Returns a VPTFile included in this project that references the given path.


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.


getFiles

public java.util.Collection getFiles()
Deprecated. Use getOpenableNodes() instead.

Returns a read-only collection of the files contained in this project.


getOpenableNodes

public java.util.Collection getOpenableNodes()
Returns a read-only 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.


getObjectProperty

public java.lang.Object getObjectProperty(java.lang.String property)
Returns the property stored for the given key.


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).

setProperty

public java.lang.Object setProperty(java.lang.String name,
                                    java.lang.Object 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.Iterator getOpenFiles()
Returns an iterator to the list of open files that this project remembers.


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.


isProjectFile

public boolean isProjectFile(java.lang.String path)
Deprecated. Use isInProject(String) instead.

Returns whether the file denoted by the given path is part of this project.


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.

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.


registerFile

public void registerFile(VPTFile file)
Register a file in the project, adding it to the list of files that belong to 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.


removeAllChildren

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


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

compareToNode

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

Overrides:
compareToNode in class VPTNode

unloadProperties

public void unloadProperties()
This method will take all properties that are not Strings and serialize them into "DeferredProperty" instances. This is meant to be called internally by ProjectViewer and, while it wouldn't cause any problems, there's not much point in other plugins trying to call this method.

Since:
PV 2.1.2

addFilter

public void addFilter(VPTFilterData filterData)
Since:
PV 2.2.2.0

setFilterList

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

Since:
PV 2.2.2.0

getFilterList

public java.util.List 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

addProjectListener

public void addProjectListener(ProjectListener lstnr)
Adds a new listener to the list. The list if listeners is global to all the projects, so listeners don't need to be registered to each individual project.


removeProjectListener

public void removeProjectListener(ProjectListener lstnr)
Removes a listener from the list.


hasListeners

public boolean hasListeners()
Returns whether there are any listeners registered. Mainly for use to enhance performance by classes that would fire these events.


fireFilesChanged

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


fireFileAdded

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


fireFileRemoved

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


firePropertiesChanged

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