net.quartzware
Class Project

java.lang.Object
  |
  +--net.quartzware.Project

public class Project
extends java.lang.Object
implements javax.swing.tree.TreeModel

Project class Contains all the information about the currently open Project. It holds all of the Resource Bundles and the current preferences for the project.


Inner Class Summary
 class Project.Config
          This class encapsulates the project options
 
Constructor Summary
Project()
          Default constructor PRE: none POST: class is created
Project(Project.Config cfg, java.util.Vector bundles)
          Creates a project using the given Config (preferences) and the given Vector of Resource Bundles.
Project(java.net.URL projectFile)
          Loads a Project using a project file.
 
Method Summary
 void addKey(java.lang.String key)
          Adds a new key to the root.
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
           
 void createBundle(java.lang.String suffix)
          Creates a new Resource Bundle and adds it to the Project
 void deleteKey(java.lang.String key)
          Deletes the Entries in all of the Resource Bundles that match the given key
 java.util.Vector getAllBundles()
          Gets all of the Resoruce Bundles
 ResBundle getBundle(java.lang.String suffix)
          Gets the bundle that matches the suffix
 java.lang.Object getChild(java.lang.Object parent, int index)
           
 int getChildCount(java.lang.Object parent)
           
 Project.Config getConfig()
          Returns a Config containing all of the options for the current Project.
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
           
 java.net.URL getProjectFile()
          Returns a URL which contains the path to the Project File.
 java.lang.Object getRoot()
           
 ResBundle getRootBundle()
          Gets the Root Resource Bundle
 void importBundle(java.net.URL file, java.lang.String suffix)
          Adds an existing bundle to the Project
 boolean isLeaf(java.lang.Object node)
           
 void removeBundle(ResBundle rb)
          Removes the given Resource Bundle from the current Project
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
           
 void save(boolean saveAs)
          Saves all of the currently dirty Resource Bundles.
 void setProjectFile(java.net.URL projectFile)
          Changes the URL used to write out.
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Project

public Project()
Default constructor PRE: none POST: class is created

Project

public Project(Project.Config cfg,
               java.util.Vector bundles)
Creates a project using the given Config (preferences) and the given Vector of Resource Bundles. Will be used mostly for creating a new project based on a Resource Bundle not made in RBEdit for a root.
Parameters:
cfg - Current preferences
bundles - a vector with Resource Bundles including a root PRE: cfg and bundles are not null POST: class is created

Project

public Project(java.net.URL projectFile)
Loads a Project using a project file. The project file lists the other files in the project, and this constructor tries to find them automatically
Parameters:
f - Project file selected from Open dialog box PRE: projectFile points to a file that can be used as a project file POST: the class is created
Method Detail

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Specified by:
getChild in interface javax.swing.tree.TreeModel

getChildCount

public int getChildCount(java.lang.Object parent)
Specified by:
getChildCount in interface javax.swing.tree.TreeModel

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel

getRoot

public java.lang.Object getRoot()
Specified by:
getRoot in interface javax.swing.tree.TreeModel

isLeaf

public boolean isLeaf(java.lang.Object node)
Specified by:
isLeaf in interface javax.swing.tree.TreeModel

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel

getRootBundle

public ResBundle getRootBundle()
Gets the Root Resource Bundle
Returns:
the Root PRE: none POST: returns the root bundle if it is present, else it returns null

deleteKey

public void deleteKey(java.lang.String key)
Deletes the Entries in all of the Resource Bundles that match the given key
Parameters:
key - The Key to be deleted PRE: key is not null POST: no Entry containing the given key will be in the project.

getProjectFile

public java.net.URL getProjectFile()
Returns a URL which contains the path to the Project File.
Returns:
the ProjectFile

setProjectFile

public void setProjectFile(java.net.URL projectFile)
Changes the URL used to write out. In other words, it changes where the project file is written to.
Parameters:
projectFile - The new ProjectFile

importBundle

public void importBundle(java.net.URL file,
                         java.lang.String suffix)
Adds an existing bundle to the Project
Parameters:
file - The file containing the Resource Bundle to be added
suffix - the suffix to be appended to the new Resource Bundle file name (the language_LOCALE_varient)
Returns:
the Resource Bundle just loaded PRE: file points to an actual file, and suffix is not null POST: the resource bundle pointed to by the file is read in, converted to a digestable form and added to the Project.

createBundle

public void createBundle(java.lang.String suffix)
Creates a new Resource Bundle and adds it to the Project
Parameters:
suffix - the suffix to be appended to the new Resource Bundle file name (the language_LOCALE_varient)
Returns:
the newly created Resource Bundle PRE: none POST: an empty resource bundle is created and added to the project

removeBundle

public void removeBundle(ResBundle rb)
Removes the given Resource Bundle from the current Project
Parameters:
rb - The resource bundle to be removed PRE: rb is not null POST: the resource bundle is removed if it exists

save

public void save(boolean saveAs)
Saves all of the currently dirty Resource Bundles. Does not write any files that have not been changed. If the saveAs flag is true, it will first bring up a Save As.. dialog box to prompt the user for a new name
Parameters:
saveAs - Save As Flag (described above) PRE: none POST: the project is saved.

getBundle

public ResBundle getBundle(java.lang.String suffix)
Gets the bundle that matches the suffix
Returns:
the bundle which matches the suffix PRE: suffix is not null POST: the bundle which matches the suffix is returned if found

getAllBundles

public java.util.Vector getAllBundles()
Gets all of the Resoruce Bundles
Returns:
all of the Resource Bundles in a Vectorj

addKey

public void addKey(java.lang.String key)
Adds a new key to the root. The Children will then be able to override this new key
Parameters:
key - the name of the key to be added PRE: key is not null POST: key is added to root bundle

getConfig

public Project.Config getConfig()
Returns a Config containing all of the options for the current Project.