Interface ProjectController
-
- All Known Implementing Classes:
ProjectControllerImpl
public interface ProjectController
Project 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 void
addWorkspaceListener(WorkspaceListener workspaceListener)
void
closeCurrentProject()
Closes the current project.void
closeCurrentWorkspace()
Unselects the current workspace.void
deleteWorkspace(Workspace workspace)
Deletes the given workspace from its project.Workspace
duplicateWorkspace(Workspace workspace)
Duplicates the given workspace and adds it to the project.Collection<Project>
getAllProjects()
Gets all active projectsProject
getCurrentProject()
Returns the current opened project.Workspace
getCurrentWorkspace()
Returns the selected workspace of the current project.Projects
getProjects()
Deprecated.Directly use this class instead as all the methods have been ported.boolean
hasCurrentProject()
Returns true if a project is selected.Project
newProject()
Creates and open a new project.Workspace
newWorkspace(Project project)
Creates and adds a new workspace to the given project.Workspace
openNewWorkspace()
Creates and open a new workspace in the current project.Project
openProject(File file)
Opens a project from a.gephi
file.void
openProject(Project project)
Opens a project from the list of active projects.void
openWorkspace(Workspace workspace)
Selects the given workspace as the current workspace of the project.void
removeProject(Project project)
Removes the project from the active project list.void
removeWorkspaceListener(WorkspaceListener workspaceListener)
void
renameProject(Project project, String name)
Renames the given project with the provided string.void
renameWorkspace(Workspace workspace, String name)
Renames the given workspace with the provided string.void
saveProject(Project project)
Saves the current project to its.gephi
file.void
saveProject(Project project, File file)
Saves the current project to a new.gephi
file.void
setSource(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.gephi
file.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.gephi
file.- 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.gephi
file.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
.gephi
files.- 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
null
if 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
null
if 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)
-
-