projectviewer
Class ProjectManager

java.lang.Object
  extended by projectviewer.ProjectManager

public final class ProjectManager
extends java.lang.Object

This class takes care of the global project configuration, that is, the list of configured projects. This provides functionality to load the project list in the project viewer and to map project names to configuration file names.

Author:
Marcelo Vanzin (with some code from older versions)

Method Summary
 void addProject(VPTProject p, VPTGroup parent)
          Adds a project to the list.
 void fireDynamicMenuChange()
           
 java.util.List<VPTFilterData> getGlobalFilterList()
          Returns the global filter list This list is valid if there is not a project specific list
static ProjectManager getInstance()
          Returns the project manager instance.
 VPTProject getProject(java.lang.String name)
          Returns the project with the given name.
 java.util.List<VPTProject> getProjects()
          Returns a list containing the list of project names managed by this manager.
 boolean hasProject(java.lang.String name)
          Returns whether a project with the given name exists.
 boolean isLoaded(java.lang.String pName)
          Returns whether a project is loaded or not.
 void removeProject(VPTProject p)
          Removes the project from the internal list of projects.
 void renameProject(java.lang.String oldName, java.lang.String newName)
          Updates information about a project to reflect its name change.
 void save()
          Saves all the project data to the disk (config + each project).
 void saveProject(VPTProject p)
          Save the project's data to the config file.
 void saveProject(VPTProject p, boolean wait)
          Same as above, with an extra argument.
 void saveProjectList()
          Saves the "global" data for the projects: the list of projects and the file names where each project data is stored.
 void setGlobalFilterList(java.util.List<VPTFilterData> globalFilterList)
          sets the global filter list as entered in option pane This list is valid if there is not a project specific list Clear cache in FilteredModel when globalFilterList changed
protected  void unload()
           
 void unloadProject(VPTProject p)
          Unloads a project: saves it to disk, removes all nodes and changes its state to "unloaded", freeing memory.
 void updateVCSStatus(VPTProject project)
           
static void writeXMLHeader(java.lang.String encoding, java.io.Writer out)
          Writes an XML header to the given writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ProjectManager getInstance()
Returns the project manager instance.


writeXMLHeader

public static void writeXMLHeader(java.lang.String encoding,
                                  java.io.Writer out)
                           throws java.io.IOException
Writes an XML header to the given writer. If encoding is not null, it is written in the encoding field; else, UTF-8 is used.

Throws:
java.io.IOException

save

public void save()
          throws java.io.IOException
Saves all the project data to the disk (config + each project).

Throws:
java.io.IOException

saveProject

public void saveProject(VPTProject p)
Save the project's data to the config file. Before calling this method, ensure that the project is in the internal list of projects (i.e., if it is a new project, call addProject(VPTProject, VPTGroup) before calling this method).


saveProject

public void saveProject(VPTProject p,
                        boolean wait)
Same as above, with an extra argument.

Parameters:
wait - Whether to wait for the I/O operation to finish.
Since:
PV 2.1.3.6
See Also:
saveProject(VPTProject)

removeProject

public void removeProject(VPTProject p)
Removes the project from the internal list of projects. Removes the project's config file (if it exists), and notifies the Viewer that the project does not exist anymore.


renameProject

public void renameProject(java.lang.String oldName,
                          java.lang.String newName)
Updates information about a project to reflect its name change.


addProject

public void addProject(VPTProject p,
                       VPTGroup parent)
Adds a project to the list.


getProject

public VPTProject getProject(java.lang.String name)
Returns the project with the given name. If the project is not yet loaded, load its configuration from the disk. It it does not exist, return null.


getProjects

public java.util.List<VPTProject> getProjects()
Returns a list containing the list of project names managed by this manager. The list is read-only.


isLoaded

public boolean isLoaded(java.lang.String pName)
Returns whether a project is loaded or not.

Parameters:
pName - The project's name.
Returns:
If the project was loaded from disk.
Throws:
java.lang.NullPointerException - If the project does not exist.

hasProject

public boolean hasProject(java.lang.String name)
Returns whether a project with the given name exists.


unloadProject

public void unloadProject(VPTProject p)
Unloads a project: saves it to disk, removes all nodes and changes its state to "unloaded", freeing memory.


updateVCSStatus

public void updateVCSStatus(VPTProject project)

getGlobalFilterList

public java.util.List<VPTFilterData> getGlobalFilterList()
Returns the global filter list This list is valid if there is not a project specific list

Since:
PV 2.2.2.0

setGlobalFilterList

public void setGlobalFilterList(java.util.List<VPTFilterData> globalFilterList)
sets the global filter list as entered in option pane This list is valid if there is not a project specific list Clear cache in FilteredModel when globalFilterList changed

Since:
PV 2.2.2.0

fireDynamicMenuChange

public void fireDynamicMenuChange()

saveProjectList

public void saveProjectList()
Saves the "global" data for the projects: the list of projects and the file names where each project data is stored.

Since:
PV 2.1.0 (was private before)

unload

protected void unload()