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 classProjectControllerImpl.EventType
-
Field Summary
Fields Modifier and Type Field Description private org.gephi.utils.longtask.api.LongTaskExecutorlongTaskExecutorprivate List<ProjectListener>projectListenersprivate ProjectsImplprojectsprivate List<WorkspaceListener>workspaceListeners
-
Constructor Summary
Constructors Constructor Description ProjectControllerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddProjectListener(ProjectListener projectListener)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.private voidfireProjectEvent(Consumer<? super ProjectListener> consumer)private voidfireWorkspaceEvent(ProjectControllerImpl.EventType event, Workspace workspace)Collection<Project>getAllProjects()Gets all active projectsProjectImplgetCurrentProject()Returns the current opened project.WorkspaceImplgetCurrentWorkspace()Returns the selected workspace of the current project.ProjectsImplgetProjects()Gets the set of active projects.private ProjectImplhandleException(Project project, Throwable t)booleanhasCurrentProject()Returns true if a project is selected.ProjectImplnewProject()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.private voidopenProjectInternal(Project project)voidopenWorkspace(Workspace workspace)Selects the given workspace as the current workspace of the project.private voidregisterNetbeansPropertyEditors()If not already registered, includes NetBeans property editors in the search path.voidremoveProject(Project project)Removes the project from the active project list.protected voidremoveProjectListener(ProjectListener projectListener)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)
-
-
-
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:ProjectControllerCreates and open a new project.If a project is currently opened, it will be closed first.
- Specified by:
newProjectin interfaceProjectController- Returns:
- newly created project
-
handleException
private ProjectImpl handleException(Project project, Throwable t)
-
openProject
public Project openProject(File file)
Description copied from interface:ProjectControllerOpens a project from a.gephifile.If a project is currently opened, it will be closed first.
- Specified by:
openProjectin interfaceProjectController- Parameters:
file- project file- Returns:
- opened project
-
openProject
public void openProject(Project project)
Description copied from interface:ProjectControllerOpens a project from the list of active projects.If a project is currently opened, it will be closed first.
- Specified by:
openProjectin interfaceProjectController- Parameters:
project- project to open
-
saveProject
public void saveProject(Project project)
Description copied from interface:ProjectControllerSaves the current project to its.gephifile.- Specified by:
saveProjectin interfaceProjectController- Parameters:
project- project to save
-
saveProject
public void saveProject(Project project, File file)
Description copied from interface:ProjectControllerSaves the current project to a new.gephifile.The project file is updated with the new file.
- Specified by:
saveProjectin interfaceProjectController- Parameters:
project- project to savefile- file to be written
-
closeCurrentProject
public void closeCurrentProject()
Description copied from interface:ProjectControllerCloses the current project.- Specified by:
closeCurrentProjectin interfaceProjectController
-
removeProject
public void removeProject(Project project)
Description copied from interface:ProjectControllerRemoves the project from the active project list.It won't delete any
.gephifiles.- Specified by:
removeProjectin interfaceProjectController- Parameters:
project- project to remove
-
getProjects
public ProjectsImpl getProjects()
Description copied from interface:ProjectControllerGets the set of active projects.- Specified by:
getProjectsin interfaceProjectController- Returns:
- projects
-
getAllProjects
public Collection<Project> getAllProjects()
Description copied from interface:ProjectControllerGets all active projects- Specified by:
getAllProjectsin interfaceProjectController- Returns:
- project array
-
hasCurrentProject
public boolean hasCurrentProject()
Description copied from interface:ProjectControllerReturns true if a project is selected.- Specified by:
hasCurrentProjectin interfaceProjectController- Returns:
- true if current project, false otherwise
-
newWorkspace
public Workspace newWorkspace(Project project)
Description copied from interface:ProjectControllerCreates 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:
newWorkspacein interfaceProjectController- Parameters:
project- project to add the workspace to- Returns:
- workspace
-
deleteWorkspace
public void deleteWorkspace(Workspace workspace)
Description copied from interface:ProjectControllerDeletes 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:
deleteWorkspacein interfaceProjectController- Parameters:
workspace- workspace to delete
-
openProjectInternal
private void openProjectInternal(Project project)
-
getCurrentProject
public ProjectImpl getCurrentProject()
Description copied from interface:ProjectControllerReturns the current opened project.- Specified by:
getCurrentProjectin interfaceProjectController- Returns:
- current open project or
nullif missing
-
getCurrentWorkspace
public WorkspaceImpl getCurrentWorkspace()
Description copied from interface:ProjectControllerReturns the selected workspace of the current project.- Specified by:
getCurrentWorkspacein interfaceProjectController- Returns:
- selected workspace or
nullif no current project
-
closeCurrentWorkspace
public void closeCurrentWorkspace()
Description copied from interface:ProjectControllerUnselects the current workspace.- Specified by:
closeCurrentWorkspacein interfaceProjectController
-
openWorkspace
public void openWorkspace(Workspace workspace)
Description copied from interface:ProjectControllerSelects the given workspace as the current workspace of the project.This method calls
ProjectController.closeCurrentWorkspace()beforehand.- Specified by:
openWorkspacein interfaceProjectController- Parameters:
workspace- workspace to select
-
openNewWorkspace
public Workspace openNewWorkspace()
Description copied from interface:ProjectControllerCreates and open a new workspace in the current project. If not project is opened, a new one is created.- Specified by:
openNewWorkspacein interfaceProjectController
-
duplicateWorkspace
public Workspace duplicateWorkspace(Workspace workspace)
Description copied from interface:ProjectControllerDuplicates the given workspace and adds it to the project.The new workspace is automatically selected.
- Specified by:
duplicateWorkspacein interfaceProjectController- Parameters:
workspace- workspace to duplicate- Returns:
- duplicated workspace
-
renameProject
public void renameProject(Project project, String name)
Description copied from interface:ProjectControllerRenames the given project with the provided string.- Specified by:
renameProjectin interfaceProjectController- Parameters:
project- project to renamename- new name
-
renameWorkspace
public void renameWorkspace(Workspace workspace, String name)
Description copied from interface:ProjectControllerRenames the given workspace with the provided string.- Specified by:
renameWorkspacein interfaceProjectController- Parameters:
workspace- workspace to renamename- new name
-
setSource
public void setSource(Workspace workspace, String source)
- Specified by:
setSourcein interfaceProjectController
-
addWorkspaceListener
public void addWorkspaceListener(WorkspaceListener workspaceListener)
- Specified by:
addWorkspaceListenerin interfaceProjectController
-
removeWorkspaceListener
public void removeWorkspaceListener(WorkspaceListener workspaceListener)
- Specified by:
removeWorkspaceListenerin 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)
-
-