net.quartzware
Class Project

java.lang.Object
  |
  +--net.quartzware.Project
All Implemented Interfaces:
javax.swing.tree.TreeModel

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(java.io.File projectFile)
          Loads a Project using a project file.
Project(Project.Config cfg, java.util.Vector bundles)
          Creates a project using the given Config (preferences) and the given Vector of Resource Bundles.
 
Method Summary
 void addBundle(ResBundle rb)
          Adds the given Resource Bundle to the current Project
 void addKey(java.lang.String key)
          Adds a new key to the root.
 void addTreeModelListener(javax.swing.event.TreeModelListener lis)
           
 void deleteKey(java.lang.String key)
          Deletes the Entries in all of the Resource Bundles that match the given key
 void fireUpdate()
           
 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.io.File getProjectFile()
          Returns a File which contains the path to the Project File.
 java.lang.Object getRoot()
           
 ResBundle getRootBundle()
          Gets the Root Resource Bundle
 boolean isChild(java.lang.String parSfx, java.lang.String chldSfx)
           
 boolean isLeaf(java.lang.Object node)
           
static Project load(java.io.File file)
          Loads all bundles listed in the project file at the given path.
static ResBundle loadBundle(java.io.File loc)
          Loads the specified ResBundle.
 void loadProjectFile(java.io.File projFile)
          Load in a project file PRE: none POST: a new project is created
 void removeBundle(ResBundle rb)
          Removes the given Resource Bundle from the current Project
 void removeBundleAndChildren(java.lang.String sfx)
          Removes the Resource Bundle that matches the given suffix and all of its children from the current Project.
 void removeTreeModelListener(javax.swing.event.TreeModelListener lis)
           
 void save(boolean saveAs)
          Saves all of the currently dirty Resource Bundles.
static void saveBundle(ResBundle bund)
          Saves the specified ResBundle.
 void saveProjectFile()
          Save out the project file PRE: none POST: the project file is saved.
 void setProjectFile(java.io.File projFile)
          Changes the File used to write out.
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
           
 
Methods inherited from class java.lang.Object
equals, 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.io.File 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 lis)
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

isChild

public boolean isChild(java.lang.String parSfx,
                       java.lang.String chldSfx)

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener lis)
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.io.File getProjectFile()
Returns a File which contains the path to the Project File.
Returns:
the ProjectFile

setProjectFile

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

addBundle

public void addBundle(ResBundle rb)
Adds the given Resource Bundle to the current Project
Parameters:
rb - The resource bundle to be added PRE: rb is not null POST: the resource bundle is 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

removeBundleAndChildren

public void removeBundleAndChildren(java.lang.String sfx)
Removes the Resource Bundle that matches the given suffix and all of its children from the current Project.
Parameters:
rb - The resource bundle to be removed PRE: none POST: the resource bundles are removed

save

public void save(boolean saveAs)
Saves all of the currently dirty Resource Bundles. Does not write any files that have not been changed, unless the saveAs flag is true. If the saveAs flag is true, everything is written out.
Parameters:
saveAs - Save As Flag (described above) PRE: none POST: the project is saved.

saveBundle

public static void saveBundle(ResBundle bund)
Saves the specified ResBundle. Will not pop up a dialog of any kind.
Parameters:
bundle - bundle to write out. PRE: none POST: the project is saved.

saveProjectFile

public void saveProjectFile()
Save out the project file PRE: none POST: the project file is saved.

loadProjectFile

public void loadProjectFile(java.io.File projFile)
Load in a project file PRE: none POST: a new project is created

load

public static Project load(java.io.File file)
Loads all bundles listed in the project file at the given path.
Parameters:
file - Where the project file is. PRE: none POST: the project is loaded.

loadBundle

public static ResBundle loadBundle(java.io.File loc)
Loads the specified ResBundle.
Parameters:
File - the file to read in from. PRE: none POST: none

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 Bundleren 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

fireUpdate

public void fireUpdate()

getConfig

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