com.borland.primetime.node
Class Project

java.lang.Object
  |
  +--com.borland.primetime.node.Node
        |
        +--com.borland.primetime.node.UrlNode
              |
              +--com.borland.primetime.node.Project
Direct Known Subclasses:
JBProject

public abstract class Project
extends UrlNode

There are several ways in which a project node is unusual and needs special care:


Field Summary
static java.lang.String CATEGORY_DEFAULT
           
static java.lang.String ENCODING
           
static java.lang.String PREFIX_UNTITLED
           
protected  java.util.ArrayList projectListeners
           
 
Fields inherited from class com.borland.primetime.node.Node
EMPTY_ARRAY, nodeListeners
 
Constructor Summary
protected Project(Url url)
          Creates a new project instance to represent a particular Url.
 
Method Summary
 void addProjectListener(ProjectListener listener)
           
 void check()
          Ensure that the project's properties are resynchronized with the current state of its paths.
 FileNode createFileNode(java.lang.String extension)
          Generates a unique Url with the specified extension for new files that the user has not yet been prompted to name.
static Project createProject(java.lang.String extension)
          Generates a unique Url with the specified extension for new projects that the user has not yet been prompted to name.
 void dumpAllNodes()
           
static void dumpProjects()
          Strictly a diagnostic method
 FileNode findNode(Url url)
           
 LightweightNode[] findNodes(java.lang.String name)
           
static Project findProject(Url url)
           
 void fireChildrenChanged(Node parent)
          Notifies all registered ProjectListeners that a node has been been added to or removed from a parent node the project.
 void fireNodeChanged(Node node)
          Notifies all registered ProjectListeners that a node's display name or icon has changed.
 void fireProjectPropertyChanged(java.lang.String category, java.lang.String property, java.lang.String oldValue, java.lang.String newValue)
          Notifies all registered ProjectListeners that a property on the project node has been changed.
 javax.swing.Icon getDisplayIcon()
          Provides an image to be used for graphical representation of the node.
 java.lang.String getDisplayName()
          Uses the the FileNode's underlying Url to derive a display name.
 int getDisplaySequence()
          Describes the logical group the node belongs to for ordering purposes.
 java.lang.String getEncoding()
          Describes the standard encoding used to read and write text files for this project.
 java.lang.String getLongDisplayName()
           
 FileNode getNode(Url url)
           
 Project getProject()
          Returns a reference to the project associated with this node.
static Project getProject(Url url)
           
 Url getProjectPath()
          Returns the Url representing the directory the project is stored in.
 Url getUrl()
          Returns the Url the project is currently associated with.
 boolean isModified()
          Describes whether or not unsaved changes exist in the project's state.
 boolean isNew()
          Describes whether or not the project needs to be renamed before it can be saved.
 boolean isPersistant()
          Determines whether or not the node definition and its properties will be saved with in a project file.
static boolean isProjectExtension(java.lang.String extension)
           
static boolean isProjectUrl(Url url)
           
protected  void postProjectLoad(Url rootUrl)
           
protected  void preProjectSave(Url rootUrl)
           
static void registerProjectClass(java.lang.String extension, java.lang.String description, java.lang.Class projectClass, javax.swing.Icon icon)
          Add a new project type to the registry of known types and their associated extensions.
 void removeProjectListener(ProjectListener listener)
           
 void rename(Url url)
          Rename cannot change the type of a Project.
 void revert()
          Revert a project to its on-disk state.
 void save()
          Updates the project's permanent storage to reflect the current state of the project.
 void saveAs(Url url)
          saveAs _can_ change the extension of a Project since all state is maintained by the Project instance itself and not the buffer representation, and all project buffers _must_ be associated with Project nodes.
 void setEncoding(java.lang.String encoding)
          Changes the standard encoding used to read and write text files for this project.
protected  void setUrl(Url url)
          Used internally by rename() and saveAs() to change the underlying Url associated with the project.
 
Methods inherited from class com.borland.primetime.node.UrlNode
getSuggestedUrl
 
Methods inherited from class com.borland.primetime.node.Node
addNodeListener, compareTo, dumpNodes, dumpNodes, dumpNodes, equals, fireNodeRenamed, getChildren, getDisplayChildren, getNodeID, getParent, getProperties, getProperty, getProperty, getProperty, hasChildren, hasDisplayChildren, hashCode, removeNodeListener, setParent, setProperty, setProperty, setProperty, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CATEGORY_DEFAULT

public static final java.lang.String CATEGORY_DEFAULT

ENCODING

public static final java.lang.String ENCODING

PREFIX_UNTITLED

public static final java.lang.String PREFIX_UNTITLED

projectListeners

protected java.util.ArrayList projectListeners
Constructor Detail

Project

protected Project(Url url)
           throws DuplicateNodeException,
                  InvalidUrlException
Creates a new project instance to represent a particular Url. This constructor should not be invoked directly, it is used internally by the factory method getProject(url).
Parameters:
url - The resource to read the project definition from.
Throws:
DuplicateNodeException - If a project is already registered for the specified Url.
Method Detail

getEncoding

public java.lang.String getEncoding()
Describes the standard encoding used to read and write text files for this project.
Returns:
A Java encoding name, or "default" if the default encoding should be used.

setEncoding

public void setEncoding(java.lang.String encoding)
Changes the standard encoding used to read and write text files for this project.
Parameters:
encoding - The Java encoding to use or null if the default encoding should be used.

setUrl

protected void setUrl(Url url)
               throws DuplicateNodeException
Used internally by rename() and saveAs() to change the underlying Url associated with the project.
Parameters:
url - The new Url to be associated with the project. This value must not be null.

getUrl

public Url getUrl()
Returns the Url the project is currently associated with.
Overrides:
getUrl in class UrlNode
Returns:
A valid non-null Url.

getProjectPath

public Url getProjectPath()
Returns the Url representing the directory the project is stored in.
Returns:
A valid non-null Url unless the project is in the new filesystem, in which case null may be returned.

isProjectUrl

public static boolean isProjectUrl(Url url)

isProjectExtension

public static boolean isProjectExtension(java.lang.String extension)
Parameters:
extension - The file extension without the leading period.

registerProjectClass

public static void registerProjectClass(java.lang.String extension,
                                        java.lang.String description,
                                        java.lang.Class projectClass,
                                        javax.swing.Icon icon)
Add a new project type to the registry of known types and their associated extensions.
Parameters:
type - The extension that this registration is associated with. Extensions are case-insensitive and do not include the leading period character.
projectClass - A subclass of Project that should be instantiated to represent projects with the matching extension.

findProject

public static Project findProject(Url url)

getProject

public static Project getProject(Url url)
                          throws InvalidUrlException

preProjectSave

protected void preProjectSave(Url rootUrl)

postProjectLoad

protected void postProjectLoad(Url rootUrl)

revert

public void revert()

Revert a project to its on-disk state. Note that this isn't the ideal implementation but is sufficient presuming that all references to project nodes are being discarded.

Ideally, we'd rather not lose FileNode instance identity and we would need to rework parentage on surviving nodes, etc.

Overrides:
revert in class UrlNode

saveAs

public void saveAs(Url url)
            throws java.io.IOException,
                   InvalidUrlException,
                   DuplicateNodeException
saveAs _can_ change the extension of a Project since all state is maintained by the Project instance itself and not the buffer representation, and all project buffers _must_ be associated with Project nodes. saveAs will overwrite existing files.
Overrides:
saveAs in class UrlNode

rename

public void rename(Url url)
            throws java.io.IOException,
                   InvalidUrlException,
                   DuplicateNodeException,
                   ReadOnlyException
Rename cannot change the type of a Project.
Overrides:
rename in class UrlNode

createProject

public static Project createProject(java.lang.String extension)
Generates a unique Url with the specified extension for new projects that the user has not yet been prompted to name.
Returns:
A valid Url uniquely identifying a new filesystem path.

createFileNode

public FileNode createFileNode(java.lang.String extension)
Generates a unique Url with the specified extension for new files that the user has not yet been prompted to name.
Returns:
A valid Url uniquely identifying a new filesystem path.

getNode

public FileNode getNode(Url url)

findNode

public FileNode findNode(Url url)

findNodes

public LightweightNode[] findNodes(java.lang.String name)

addProjectListener

public void addProjectListener(ProjectListener listener)

removeProjectListener

public void removeProjectListener(ProjectListener listener)

fireProjectPropertyChanged

public void fireProjectPropertyChanged(java.lang.String category,
                                       java.lang.String property,
                                       java.lang.String oldValue,
                                       java.lang.String newValue)
Notifies all registered ProjectListeners that a property on the project node has been changed.

fireChildrenChanged

public void fireChildrenChanged(Node parent)
Notifies all registered ProjectListeners that a node has been been added to or removed from a parent node the project.

fireNodeChanged

public void fireNodeChanged(Node node)
Notifies all registered ProjectListeners that a node's display name or icon has changed.

isPersistant

public boolean isPersistant()
Determines whether or not the node definition and its properties will be saved with in a project file. Project nodes are always persistant.
Overrides:
isPersistant in class Node
Returns:
True if the node should be saved, false otherwise.

check

public void check()
Ensure that the project's properties are resynchronized with the current state of its paths.
Overrides:
check in class Node

isModified

public boolean isModified()
Describes whether or not unsaved changes exist in the project's state.
Overrides:
isModified in class UrlNode
Returns:
True if changes have been made that have not yet been saved to the project file.

isNew

public boolean isNew()
Describes whether or not the project needs to be renamed before it can be saved.
Overrides:
isNew in class UrlNode
Returns:
True if the project's current Url should not be used for saving, false if the current Url is okay.

save

public void save()
          throws java.io.IOException,
                 InvalidUrlException
Updates the project's permanent storage to reflect the current state of the project.
Overrides:
save in class UrlNode

getProject

public Project getProject()
Description copied from class: Node
Returns a reference to the project associated with this node.
Overrides:
getProject in class Node
Tags copied from class: Node
Returns:
A project reference.

getDisplaySequence

public int getDisplaySequence()
Description copied from class: Node
Describes the logical group the node belongs to for ordering purposes. Nodes are divided into groups, then sorted by name within a group of nodes sharing the same grouping value. The groups themselves are ordered by grouping value, with lower numbers appearing earlier. Arbitrary numbers have been chosen to sort nodes in JBuilder as follows: Projects = 100, Folders = 200, Packages = 300, the default = 400, FileNodes = 500, ClassFileNodes = 600.
Overrides:
getDisplaySequence in class Node
Tags copied from class: Node
Returns:
An integer value specifying a grouping value.

getDisplayName

public java.lang.String getDisplayName()
Uses the the FileNode's underlying Url to derive a display name.
Overrides:
getDisplayName in class Node
Returns:
The filename of the node's Url with the path component removed.

getLongDisplayName

public java.lang.String getLongDisplayName()
Overrides:
getLongDisplayName in class Node

getDisplayIcon

public javax.swing.Icon getDisplayIcon()
Description copied from class: Node
Provides an image to be used for graphical representation of the node.
Overrides:
getDisplayIcon in class Node
Tags copied from class: Node
Returns:
An Icon instance.

dumpProjects

public static void dumpProjects()
Strictly a diagnostic method

dumpAllNodes

public void dumpAllNodes()