uk.org.toot.project
Class SingleProject

java.lang.Object
  extended by uk.org.toot.project.SingleProject
Direct Known Subclasses:
SingleTransportProject

public class SingleProject
extends java.lang.Object

Simple-minded single project manager. Typically certain parts of an overall system will need to know when the current project changes so that they may save and load relevant settings. Projects each have a directory path based on their name. i.e. ~//projects/ Directories are automatically created. Note that there is no single project file, just a project directory into which application components should write their relevant files. There is a concurrency weakness if listeners are added or removed during an open or close, so don't do that. Suggested usage is to have a single instance in your application and to pass it into the constructor of application components. Those components should then typically create a private ProjectListener instance and add and remove it as appropriate. When the current project is changed, if there is an existing current project, it is closed, the new current project is opened. When a project is opened the open() method of all ProjectListeners is called. Similarly their close() methods are called when a project is closed. No arguments are passed to the ProjectListeners, they should call getCurrentProjectName() and/or getCurrentProjectPath() as appropriate.


Constructor Summary
SingleProject()
           
SingleProject(java.io.File appPath)
           
SingleProject(java.lang.String appDir)
           
 
Method Summary
 void addProjectListener(ProjectListener listener)
           
 boolean canOpenProject()
           
 boolean canSaveProject()
           
 void exportProject(java.lang.String name)
          Export the named project to the specified file.
 java.io.File getApplicationPath()
           
 java.lang.String getCurrentProjectArtist()
           
 java.io.File getCurrentProjectPath()
           
 java.lang.String getCurrentProjectTitle()
           
 java.io.File getProjectsRoot()
           
 void importProject(java.lang.String name, java.io.File file)
          Import the named project from the specified file.
 void openProject(java.lang.String name)
           
 void removeProjectListener(ProjectListener listener)
           
 void saveAsProject(java.lang.String name)
           
 void saveProject()
           
 void setProjectsRoot(java.lang.String path)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleProject

public SingleProject()

SingleProject

public SingleProject(java.lang.String appDir)

SingleProject

public SingleProject(java.io.File appPath)
Method Detail

openProject

public void openProject(java.lang.String name)

saveProject

public void saveProject()

saveAsProject

public void saveAsProject(java.lang.String name)

importProject

public void importProject(java.lang.String name,
                          java.io.File file)
Import the named project from the specified file. i.e. project is uncompressed from file.


exportProject

public void exportProject(java.lang.String name)
Export the named project to the specified file. i.e. project is compressed to file.


canOpenProject

public boolean canOpenProject()

canSaveProject

public boolean canSaveProject()

getApplicationPath

public java.io.File getApplicationPath()

getCurrentProjectTitle

public java.lang.String getCurrentProjectTitle()

getCurrentProjectArtist

public java.lang.String getCurrentProjectArtist()

getCurrentProjectPath

public java.io.File getCurrentProjectPath()

setProjectsRoot

public void setProjectsRoot(java.lang.String path)

getProjectsRoot

public java.io.File getProjectsRoot()

addProjectListener

public void addProjectListener(ProjectListener listener)

removeProjectListener

public void removeProjectListener(ProjectListener listener)


Copyright © 2004, 2005, 2006, 2007 Steve Taylor. All Rights Reserved.