Class Project
- java.lang.Object
-
- ca.cgjennings.apps.arkham.project.Member
-
- ca.cgjennings.apps.arkham.project.Task
-
- ca.cgjennings.apps.arkham.project.TaskGroup
-
- ca.cgjennings.apps.arkham.project.Project
-
- All Implemented Interfaces:
IconProvider,java.lang.Comparable<Member>,java.lang.Iterable<Member>
public class Project extends TaskGroup
Projects simplify the management of multi-file projects.- Author:
- Chris Jennings
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringKEY_RESOURCE_IDstatic java.lang.StringPROJECT_TASK_TYPE-
Fields inherited from class ca.cgjennings.apps.arkham.project.Task
KEY_ICON, KEY_SUBTYPE, KEY_TYPE, TASK_SETTINGS
-
-
Constructor Summary
Constructors Constructor Description Project(java.io.File baseFolder)Opens an existing project.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the project.static java.io.FilecreateProject(java.io.File projectFolder, java.lang.String projectName)Creates a new project folder with the specified project name.MemberfindMember(java.io.File file)Returns theMemberinstance that represents a file in a project.MemberfindMember(java.lang.String path)Returns theMemberinstance pointed to by file or URL path in a string.MemberfindMember(java.net.URL url)Returns theMemberinstance pointed to by a URL.ThemedIcongetIcon()Returns an icon that is appropriate for this member, in this case the standard icon for projects.java.io.FilegetPackageFile()If this project is stored in a package, returns the package file.java.net.URLgetURL()Returns a project: URL that can be used to access this member whenever this project is the main open project.ProjectViewgetView()Returns the canonicalProjectViewassociated with this project, ornullif no view is associated with it.static booleanisProjectFolder(java.io.File file)Returnstrueif the specified file exists and is a project folder.static booleanisProjectPackage(java.io.File file)Returnstrueif the specified file exists and is a packaged project container.static Projectopen(java.io.File f)Opens an existing project, either from a project folder or from a project package file.voidsynchronizeAll()java.util.Iterator<Task>taskIterator()Returns an iterator over all task folders in the project, including the project itself.voidtoPackage(java.io.File pkg)Writes the contents of this project to a package project ("crate") file.static java.io.Fileunpackage(java.io.File pkg, java.io.File targetParent)Unpack a project package file into a project folder.-
Methods inherited from class ca.cgjennings.apps.arkham.project.TaskGroup
addNewTask
-
Methods inherited from class ca.cgjennings.apps.arkham.project.Task
createTask, getCustomIcons, getSettings, isTaskFolder, readTaskSettings, registerCustomIcon, unregisterCustomIcon, writeTaskSettings
-
Methods inherited from class ca.cgjennings.apps.arkham.project.Member
compareTo, deleteFile, equals, findChild, findChild, getBaseName, getChildAt, getChildCount, getChildren, getExcludedFilePatterns, getExtension, getFile, getIndex, getMetadataSource, getName, getParent, getProject, getTask, hasChildren, hashCode, isAncestorOf, isFileExcluded, isFolder, iterator, registerMetadataSource, renameFile, setExcludedFilePatterns, synchronize, toString, unregisterMetadataSource
-
-
-
-
Field Detail
-
PROJECT_TASK_TYPE
public static final java.lang.String PROJECT_TASK_TYPE
- See Also:
- Constant Field Values
-
KEY_RESOURCE_ID
public static final java.lang.String KEY_RESOURCE_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
open
public static Project open(java.io.File f) throws java.io.IOException
Opens an existing project, either from a project folder or from a project package file.- Parameters:
f- the project folder or package file to open- Returns:
- the opened project
- Throws:
java.io.IOException- if an error occurs while opening the project
-
getView
public ProjectView getView()
Returns the canonicalProjectViewassociated with this project, ornullif no view is associated with it.- Returns:
- the canonical project view displaying this project, or
null
-
getURL
public java.net.URL getURL()
Description copied from class:MemberReturns a project: URL that can be used to access this member whenever this project is the main open project. Returnsnullif the file has been deleted.
-
findMember
public Member findMember(java.lang.String path)
Returns theMemberinstance pointed to by file or URL path in a string. This method is a scripting convenience that invokes either thefindMember(java.io.File)orfindMember(java.net.URL)method as appropriate.- Parameters:
path- a file path or project URL- Returns:
- the project member described by the path, or
null - Since:
- 3.4
-
findMember
public Member findMember(java.net.URL url)
Returns theMemberinstance pointed to by a URL. The URL protocol must either befile:orproject:. If the file specified by the URL is not part of the project,nullis returned.- Parameters:
url- the URL to locate a project member for- Returns:
- the project member described by the URL, or
null - Since:
- 3.0
-
findMember
public Member findMember(java.io.File file)
Returns theMemberinstance that represents a file in a project. If the file is not part of the project, thennullis returned.- Parameters:
file- the file to locate in the project's member tree- Returns:
- the project member for
file, ornull
-
isProjectFolder
public static final boolean isProjectFolder(java.io.File file) throws java.io.IOExceptionReturnstrueif the specified file exists and is a project folder.- Parameters:
file- the file to test- Returns:
trueif the file is a regular project folder- Throws:
java.lang.NullPointerException- if the file isnulljava.io.IOException
-
isProjectPackage
public static final boolean isProjectPackage(java.io.File file)
Returnstrueif the specified file exists and is a packaged project container.- Parameters:
file- the file to test- Returns:
trueif the file is a packaged project- Throws:
java.lang.NullPointerException- if the file isnull
-
createProject
public static java.io.File createProject(java.io.File projectFolder, java.lang.String projectName) throws java.io.IOExceptionCreates a new project folder with the specified project name. The project will be created as a subfolder ofprojectFolder. The returned file can be used to create aProjectinstance for the new project using theProject(java.io.File)constructor.- Parameters:
projectFolder- the folder to create the project inprojectName- the name of the new project- Returns:
- the new project folder's file
- Throws:
java.io.IOException- if the project folder does not exist, or if it exists but has a child with the same name as the project name, or if the project folder cannot be created for some reason
-
getIcon
public ThemedIcon getIcon()
Returns an icon that is appropriate for this member, in this case the standard icon for projects.- Specified by:
getIconin interfaceIconProvider- Overrides:
getIconin classMember- Returns:
- an icon for this member
-
synchronizeAll
public void synchronizeAll()
-
toPackage
public void toPackage(java.io.File pkg) throws java.io.IOExceptionWrites the contents of this project to a package project ("crate") file. A packaged project is essentially a ZIP archive that uses the file extension.seproject. When a packaged project is opened in the application, it will unpack the file to a temporary folder and open that folder as a project. When the project is closed, it will then copy the modified package back to the original package file. If a project was opened from a package file, thengetPackageFile()will return a non-nullvalue.- Parameters:
pkg- the file to write the package archive to- Throws:
java.io.IOException- if an I/O error occurs while writing the package file
-
unpackage
public static java.io.File unpackage(java.io.File pkg, java.io.File targetParent) throws java.io.IOExceptionUnpack a project package file into a project folder. The project folder will be a subfolder oftargetParent, which must be a folder.- Parameters:
pkg- the package filetargetParent- the intended parent of the project folder- Returns:
- the unpacked project folder
- Throws:
java.io.IOException- if an error occurs while unpacking the package
-
getPackageFile
public java.io.File getPackageFile()
If this project is stored in a package, returns the package file. Otherwise, returnsnull.- Returns:
- returns the package file for this project
-
close
public void close()
Closes the project. A project must be closed when no longer needed to make sure that any pending changes get written to the file system. If the project is a packaged type, then closing the project will also update the original package archive to reflect the current state of the project.
-
taskIterator
public java.util.Iterator<Task> taskIterator()
Returns an iterator over all task folders in the project, including the project itself.- Returns:
- an iterator that iterates over all of the tasks in the project
-
-