Package org.gephi.project.impl
Class ProjectControllerImpl
- java.lang.Object
-
- org.gephi.project.impl.ProjectControllerImpl
-
- All Implemented Interfaces:
ProjectController
public class ProjectControllerImpl extends Object implements ProjectController
- Author:
- Mathieu Bastian
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ProjectControllerImpl.EventType
-
Field Summary
Fields Modifier and Type Field Description private org.gephi.utils.longtask.api.LongTaskExecutor
longTaskExecutor
private List<ProjectListener>
projectListeners
private ProjectsImpl
projects
private List<WorkspaceListener>
workspaceListeners
-
Constructor Summary
Constructors Constructor Description ProjectControllerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addProjectListener(ProjectListener projectListener)
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.private void
fireProjectEvent(Consumer<? super ProjectListener> consumer)
private void
fireWorkspaceEvent(ProjectControllerImpl.EventType event, Workspace workspace)
Collection<Project>
getAllProjects()
Gets all active projectsProjectImpl
getCurrentProject()
Returns the current opened project.WorkspaceImpl
getCurrentWorkspace()
Returns the selected workspace of the current project.ProjectsImpl
getProjects()
Gets the set of active projects.private ProjectImpl
handleException(Project project, Throwable t)
boolean
hasCurrentProject()
Returns true if a project is selected.ProjectImpl
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.private void
openProjectInternal(Project project)
void
openWorkspace(Workspace workspace)
Selects the given workspace as the current workspace of the project.private void
registerNetbeansPropertyEditors()
If not already registered, includes NetBeans property editors in the search path.void
removeProject(Project project)
Removes the project from the active project list.protected void
removeProjectListener(ProjectListener projectListener)
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)
-
-
-
Field Detail
-
projects
private final ProjectsImpl projects
-
workspaceListeners
private final List<WorkspaceListener> workspaceListeners
-
projectListeners
private final List<ProjectListener> projectListeners
-
longTaskExecutor
private final org.gephi.utils.longtask.api.LongTaskExecutor longTaskExecutor
-
-
Method Detail
-
registerNetbeansPropertyEditors
private void registerNetbeansPropertyEditors()
If not already registered, includes NetBeans property editors in the search path. This is necessary when in the toolkit to properly save and read project files.
-
newProject
public ProjectImpl newProject()
Description copied from interface:ProjectController
Creates and open a new project.If a project is currently opened, it will be closed first.
- Specified by:
newProject
in interfaceProjectController
- Returns:
- newly created project
-
handleException
private ProjectImpl handleException(Project project, Throwable t)
-
openProject
public Project openProject(File file)
Description copied from interface:ProjectController
Opens a project from a.gephi
file.If a project is currently opened, it will be closed first.
- Specified by:
openProject
in interfaceProjectController
- Parameters:
file
- project file- Returns:
- opened project
-
openProject
public void openProject(Project project)
Description copied from interface:ProjectController
Opens a project from the list of active projects.If a project is currently opened, it will be closed first.
- Specified by:
openProject
in interfaceProjectController
- Parameters:
project
- project to open
-
saveProject
public void saveProject(Project project)
Description copied from interface:ProjectController
Saves the current project to its.gephi
file.- Specified by:
saveProject
in interfaceProjectController
- Parameters:
project
- project to save
-
saveProject
public void saveProject(Project project, File file)
Description copied from interface:ProjectController
Saves the current project to a new.gephi
file.The project file is updated with the new file.
- Specified by:
saveProject
in interfaceProjectController
- Parameters:
project
- project to savefile
- file to be written
-
closeCurrentProject
public void closeCurrentProject()
Description copied from interface:ProjectController
Closes the current project.- Specified by:
closeCurrentProject
in interfaceProjectController
-
removeProject
public void removeProject(Project project)
Description copied from interface:ProjectController
Removes the project from the active project list.It won't delete any
.gephi
files.- Specified by:
removeProject
in interfaceProjectController
- Parameters:
project
- project to remove
-
getProjects
public ProjectsImpl getProjects()
Description copied from interface:ProjectController
Gets the set of active projects.- Specified by:
getProjects
in interfaceProjectController
- Returns:
- projects
-
getAllProjects
public Collection<Project> getAllProjects()
Description copied from interface:ProjectController
Gets all active projects- Specified by:
getAllProjects
in interfaceProjectController
- Returns:
- project array
-
hasCurrentProject
public boolean hasCurrentProject()
Description copied from interface:ProjectController
Returns true if a project is selected.- Specified by:
hasCurrentProject
in interfaceProjectController
- Returns:
- true if current project, false otherwise
-
newWorkspace
public Workspace newWorkspace(Project project)
Description copied from interface:ProjectController
Creates and adds a new workspace to the given project.The new workspace is not selected. Call
ProjectController.openWorkspace(Workspace)
(org.gephi.project.api.Workspace)} to select it.- Specified by:
newWorkspace
in interfaceProjectController
- Parameters:
project
- project to add the workspace to- Returns:
- workspace
-
deleteWorkspace
public void deleteWorkspace(Workspace workspace)
Description copied from interface:ProjectController
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.
- Specified by:
deleteWorkspace
in interfaceProjectController
- Parameters:
workspace
- workspace to delete
-
openProjectInternal
private void openProjectInternal(Project project)
-
getCurrentProject
public ProjectImpl getCurrentProject()
Description copied from interface:ProjectController
Returns the current opened project.- Specified by:
getCurrentProject
in interfaceProjectController
- Returns:
- current open project or
null
if missing
-
getCurrentWorkspace
public WorkspaceImpl getCurrentWorkspace()
Description copied from interface:ProjectController
Returns the selected workspace of the current project.- Specified by:
getCurrentWorkspace
in interfaceProjectController
- Returns:
- selected workspace or
null
if no current project
-
closeCurrentWorkspace
public void closeCurrentWorkspace()
Description copied from interface:ProjectController
Unselects the current workspace.- Specified by:
closeCurrentWorkspace
in interfaceProjectController
-
openWorkspace
public void openWorkspace(Workspace workspace)
Description copied from interface:ProjectController
Selects the given workspace as the current workspace of the project.This method calls
ProjectController.closeCurrentWorkspace()
beforehand.- Specified by:
openWorkspace
in interfaceProjectController
- Parameters:
workspace
- workspace to select
-
openNewWorkspace
public Workspace openNewWorkspace()
Description copied from interface:ProjectController
Creates and open a new workspace in the current project. If not project is opened, a new one is created.- Specified by:
openNewWorkspace
in interfaceProjectController
-
duplicateWorkspace
public Workspace duplicateWorkspace(Workspace workspace)
Description copied from interface:ProjectController
Duplicates the given workspace and adds it to the project.The new workspace is automatically selected.
- Specified by:
duplicateWorkspace
in interfaceProjectController
- Parameters:
workspace
- workspace to duplicate- Returns:
- duplicated workspace
-
renameProject
public void renameProject(Project project, String name)
Description copied from interface:ProjectController
Renames the given project with the provided string.- Specified by:
renameProject
in interfaceProjectController
- Parameters:
project
- project to renamename
- new name
-
renameWorkspace
public void renameWorkspace(Workspace workspace, String name)
Description copied from interface:ProjectController
Renames the given workspace with the provided string.- Specified by:
renameWorkspace
in interfaceProjectController
- Parameters:
workspace
- workspace to renamename
- new name
-
setSource
public void setSource(Workspace workspace, String source)
- Specified by:
setSource
in interfaceProjectController
-
addWorkspaceListener
public void addWorkspaceListener(WorkspaceListener workspaceListener)
- Specified by:
addWorkspaceListener
in interfaceProjectController
-
removeWorkspaceListener
public void removeWorkspaceListener(WorkspaceListener workspaceListener)
- Specified by:
removeWorkspaceListener
in interfaceProjectController
-
addProjectListener
protected void addProjectListener(ProjectListener projectListener)
-
removeProjectListener
protected void removeProjectListener(ProjectListener projectListener)
-
fireProjectEvent
private void fireProjectEvent(Consumer<? super ProjectListener> consumer)
-
fireWorkspaceEvent
private void fireWorkspaceEvent(ProjectControllerImpl.EventType event, Workspace workspace)
-
-