Interface ProjectController
-
- All Known Implementing Classes:
ProjectControllerImpl
public interface ProjectControllerProject controller, manage projects and workspaces states.This controller is a service and can therefore be found in Lookup:
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
Only a single project can be opened at a time. It can be retrieved from
getCurrentProject().}At startup, no project is opened. To open a project, use
openProject(java.io.File)or create a new one withnewProject().A project contains one or more workspaces. A project can have only one workspace selected at a time. By default, a project starts with one workspace.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidaddWorkspaceListener(WorkspaceListener workspaceListener)voidcloseCurrentProject()Closes the current project.voidcloseCurrentWorkspace()Unselects the current workspace.voiddeleteWorkspace(Workspace workspace)Deletes the given workspace from its project.WorkspaceduplicateWorkspace(Workspace workspace)Duplicates the given workspace and adds it to the project.Collection<Project>getAllProjects()Gets all active projectsProjectgetCurrentProject()Returns the current opened project.WorkspacegetCurrentWorkspace()Returns the selected workspace of the current project.ProjectsgetProjects()Deprecated.Directly use this class instead as all the methods have been ported.booleanhasCurrentProject()Returns true if a project is selected.ProjectnewProject()Creates and open a new project.WorkspacenewWorkspace(Project project)Creates and adds a new workspace to the given project.WorkspaceopenNewWorkspace()Creates and open a new workspace in the current project.ProjectopenProject(File file)Opens a project from a.gephifile.voidopenProject(Project project)Opens a project from the list of active projects.voidopenWorkspace(Workspace workspace)Selects the given workspace as the current workspace of the project.voidremoveProject(Project project)Removes the project from the active project list.voidremoveWorkspaceListener(WorkspaceListener workspaceListener)voidrenameProject(Project project, String name)Renames the given project with the provided string.voidrenameWorkspace(Workspace workspace, String name)Renames the given workspace with the provided string.voidsaveProject(Project project)Saves the current project to its.gephifile.voidsaveProject(Project project, File file)Saves the current project to a new.gephifile.voidsetSource(Workspace workspace, String source)
-
-
-
Method Detail
-
newProject
Project newProject()
Creates and open a new project.If a project is currently opened, it will be closed first.
- Returns:
- newly created project
-
openProject
Project openProject(File file)
Opens a project from a.gephifile.If a project is currently opened, it will be closed first.
- Parameters:
file- project file- Returns:
- opened project
-
openProject
void openProject(Project project)
Opens a project from the list of active projects.If a project is currently opened, it will be closed first.
- Parameters:
project- project to open- Throws:
IllegalArgumentException- if the project doesn't belong to the list of active projects
-
saveProject
void saveProject(Project project)
Saves the current project to its.gephifile.- Parameters:
project- project to save- Throws:
IllegalStateException- is the project hasn't a file configured
-
saveProject
void saveProject(Project project, File file)
Saves the current project to a new.gephifile.The project file is updated with the new file.
- Parameters:
project- project to savefile- file to be written
-
closeCurrentProject
void closeCurrentProject()
Closes the current project.
-
removeProject
void removeProject(Project project)
Removes the project from the active project list.It won't delete any
.gephifiles.- Parameters:
project- project to remove
-
getProjects
Projects getProjects()
Deprecated.Directly use this class instead as all the methods have been ported.Gets the set of active projects.- Returns:
- projects
-
hasCurrentProject
boolean hasCurrentProject()
Returns true if a project is selected.- Returns:
- true if current project, false otherwise
-
getCurrentProject
Project getCurrentProject()
Returns the current opened project.- Returns:
- current open project or
nullif missing
-
getAllProjects
Collection<Project> getAllProjects()
Gets all active projects- Returns:
- project array
-
newWorkspace
Workspace newWorkspace(Project project)
Creates and adds a new workspace to the given project.The new workspace is not selected. Call
openWorkspace(Workspace)(org.gephi.project.api.Workspace)} to select it.- Parameters:
project- project to add the workspace to- Returns:
- workspace
-
deleteWorkspace
void deleteWorkspace(Workspace workspace)
Deletes the given workspace from its project.If the workspace is currently selected, it's preceding workspace will be selected.
If this workspace is the unique workspace in the project, the project will be closed.
- Parameters:
workspace- workspace to delete
-
renameWorkspace
void renameWorkspace(Workspace workspace, String name)
Renames the given workspace with the provided string.- Parameters:
workspace- workspace to renamename- new name
-
renameProject
void renameProject(Project project, String name)
Renames the given project with the provided string.- Parameters:
project- project to renamename- new name
-
getCurrentWorkspace
Workspace getCurrentWorkspace()
Returns the selected workspace of the current project.- Returns:
- selected workspace or
nullif no current project
-
openWorkspace
void openWorkspace(Workspace workspace)
Selects the given workspace as the current workspace of the project.This method calls
closeCurrentWorkspace()beforehand.- Parameters:
workspace- workspace to select
-
openNewWorkspace
Workspace openNewWorkspace()
Creates and open a new workspace in the current project. If not project is opened, a new one is created.
-
closeCurrentWorkspace
void closeCurrentWorkspace()
Unselects the current workspace.
-
duplicateWorkspace
Workspace duplicateWorkspace(Workspace workspace)
Duplicates the given workspace and adds it to the project.The new workspace is automatically selected.
- Parameters:
workspace- workspace to duplicate- Returns:
- duplicated workspace
-
addWorkspaceListener
void addWorkspaceListener(WorkspaceListener workspaceListener)
-
removeWorkspaceListener
void removeWorkspaceListener(WorkspaceListener workspaceListener)
-
-