projectviewer
Class ProjectManager

java.lang.Object
  extended byprojectviewer.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.

Version:
$Id: ProjectManager.java 9220 2007-03-27 03:44:56Z vanza $
Author:
Marcelo Vanzin (with some code from older versions)

Method Summary
 void addProject(VPTProject p, VPTGroup parent)
          Adds a project to the list.
 void addProjectListeners(org.gjt.sp.jedit.PluginJAR jar)
          Adds the plugin's declared project listeners to the list of project listeners to be added to a project when it's activated.
 void fireDynamicMenuChange()
           
 java.util.List 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.Iterator getProjects()
          Returns an iterator that points to the (ordered) 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 removeProjectListeners(org.gjt.sp.jedit.PluginJAR jar)
          Removes the project listeners of the given plugin from the list, and from any active project in ProjectViewer.
 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 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.
protected  void unloadProjectProperties()
          Called when a plugin is unloaded so that object properties are serialized, avoiding ClassCastExceptions later.
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.Iterator getProjects()
Returns an iterator that points to the (ordered) list of project names managed by this manager. The Iterator 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.


getGlobalFilterList

public java.util.List 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 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

addProjectListeners

public void addProjectListeners(org.gjt.sp.jedit.PluginJAR jar)
Adds the plugin's declared project listeners to the list of project listeners to be added to a project when it's activated.


removeProjectListeners

public void removeProjectListeners(org.gjt.sp.jedit.PluginJAR jar)
Removes the project listeners of the given plugin from the list, and from any active project in ProjectViewer.


unloadProjectProperties

protected void unloadProjectProperties()
Called when a plugin is unloaded so that object properties are serialized, avoiding ClassCastExceptions later.


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()