com.jstatcom.project
Class ProjectManager
- java.lang.Object
-
- com.jstatcom.project.ProjectManager
-
public final class ProjectManager extends java.lang.ObjectManages storing and retrieving project data and project states for all modules. This class is a Singleton. All modules taking part in the project management system must register with this object with the methodaddProjectStateHandlerat program start. On deserialization of projects, the data is restored and the modules states are set.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddClassTransformation(java.lang.String oldClassName, java.lang.String newClassName)Adds a classname transformation.voidaddPackagePrefix(java.lang.String name, java.lang.String packageName)Adds a package prefix.voidaddProjectStateHandler(ProjectStateHandler handler)Adds a project state handler, typically a modelling module, to the list of all handlers.ProjectTreeNodedeSerializeProject(java.io.File currentProjectFile)Restores project fromcurrentProjectFile.javax.swing.AbstractActiongetDeSerializationAction()Gets an abstract action instance that can be reused by components to invoke project deserialization.static ProjectManagergetInstance()Gets singleton instance of this class.ProjectgetProjectFromFile(java.io.File currentProjectFile)Gets project fromcurrentProjectFile.javax.swing.AbstractActiongetSerializationAction()Gets an abstract action instance that can be reused by components to invoke project serialization.TopFramegetTopFrame()Gets the reference to theTopFramecomponent that has been set earlier.voidserializeProject(java.io.File currentProjectFile, java.lang.String name, java.lang.String description)Stores the current state as a project tocurrentProjectFile.voidsetProjectToFile(java.io.File currentProjectFile, Project project)Serializes the fully specifiedprojectto the filecurrentProjectFile.voidsetTopFrame(TopFrame topFrame)Sets the reference to theTopFramecomponent that can be used for (de)serializing projects.
-
-
-
Method Detail
-
getInstance
public static ProjectManager getInstance()
Gets singleton instance of this class.- Returns:
- project manager
-
getSerializationAction
public javax.swing.AbstractAction getSerializationAction()
Gets an abstract action instance that can be reused by components to invoke project serialization. For example, it could be used by "Save Project" button.- Returns:
- abstract action
-
getDeSerializationAction
public javax.swing.AbstractAction getDeSerializationAction()
Gets an abstract action instance that can be reused by components to invoke project deserialization. For example, it could be used by "Open Project" button.- Returns:
- abstract action
-
setProjectToFile
public void setProjectToFile(java.io.File currentProjectFile, Project project)Serializes the fully specifiedprojectto the filecurrentProjectFile.- Parameters:
currentProjectFile- file to use for project serializationproject- fully specifiedProjectinstance- Throws:
java.lang.IllegalArgumentException- if (currentProjectFile == null || project == null)
-
addPackagePrefix
public void addPackagePrefix(java.lang.String name, java.lang.String packageName)Adds a package prefix. This can be used to reduce the size of the created XML file. For example, in the XML header it will appear asxmlns:jstatcom="java:com.jstatcom", where "jstatcom" is the name and "com.jstatcom" the package name. The package name will be replaced by the name in all classes of that package in the XML file.The package name "jstatcom" and "com.jstatcom" is reserved and must not be used.
- Parameters:
name-packageName-- Throws:
java.lang.IllegalArgumentException- ifnullor empty argument or ifnameofpackageNamehas already been used.
-
serializeProject
public void serializeProject(java.io.File currentProjectFile, java.lang.String name, java.lang.String description)Stores the current state as a project tocurrentProjectFile.- Parameters:
currentProjectFile- the file to store the project toname- the name of the projectdescription- the project description- Throws:
java.lang.IllegalArgumentException- if (currentProjectFile == null)
-
getProjectFromFile
public Project getProjectFromFile(java.io.File currentProjectFile)
Gets project fromcurrentProjectFile.- Parameters:
currentProjectFile- the file to read the project from- Returns:
- deserialized project
- Throws:
java.lang.IllegalArgumentException- if (currentProjectFile == null)
-
deSerializeProject
public ProjectTreeNode deSerializeProject(java.io.File currentProjectFile)
Restores project fromcurrentProjectFile.- Parameters:
currentProjectFile- the file to read the project from- Returns:
- reference to the newly created project tree node
- Throws:
java.lang.IllegalArgumentException- if (currentProjectFile == null)
-
addProjectStateHandler
public void addProjectStateHandler(ProjectStateHandler handler)
Adds a project state handler, typically a modelling module, to the list of all handlers. The state will be stored as part of the project and it is restored when the project is deserialized.This method should be called at program start when all handlers are being initialized.
- Parameters:
handler- element of a project that hanldles project states, usually aModelFrame- Throws:
java.lang.IllegalArgumentException-if (handler == null)
-
setTopFrame
public void setTopFrame(TopFrame topFrame)
Sets the reference to theTopFramecomponent that can be used for (de)serializing projects. It is not strictly required to use this setting.- Parameters:
topFrame- reference to theTopFrameinstance that is used as the main application frame
-
getTopFrame
public TopFrame getTopFrame()
Gets the reference to theTopFramecomponent that has been set earlier.- Returns:
- reference to the currently set
TopFrameinstance ornullif none has been set before
-
addClassTransformation
public void addClassTransformation(java.lang.String oldClassName, java.lang.String newClassName)Adds a classname transformation. This is useful to load serialized XML project files after a classname was changed.- Parameters:
oldClassName- full classname before renamingnewClassName- full classname after renaming
-
-
DMelt 3.0 © DataMelt by jWork.ORG