Class ProjectManager

  • All Implemented Interfaces:
    java.util.EventListener, org.eclipse.core.resources.IResourceChangeListener

    public class ProjectManager
    extends java.lang.Object
    implements org.eclipse.core.resources.IResourceChangeListener
    The Project Manager manages all iizi-projects, handles job scheduling, notification, referencing, etc.
    Author:
    Christopher Mindus
    • Field Detail

      • PROJECT_JOBS

        public static final java.lang.String PROJECT_JOBS
        The Job family for iizi project jobs.
        See Also:
        Constant Field Values
    • Method Detail

      • getInstance

        public static ProjectManager getInstance()
        Gets the single instance of the Project Manager.
        Returns:
        The Project Manager.
      • dispose

        public void dispose()
        Disposes of the Project Manager.

        ONLY CALLED FROM com.iizigo.Activator, no one else.

      • isStartingUp

        public boolean isStartingUp()
        Checks if the Project Manager is in Starting up state.
      • startup

        public void startup​(java.lang.Runnable doneCallback)
        Start-up of the Project Manager.

        THIS METHOD SHOULD ONLY BE CALLED ONCE FROM THE PLUG-IN STARTUP CLASS.

      • onPluginRegistered

        public void onPluginRegistered​(java.lang.String pluginID)
        Called from the plug-in manager when a plug-in is registered. All projects that are in open-pending state are checked for the possibility of being opened.
        Parameters:
        pluginID - The plug-in ID.
      • getFirstModuleModelProject

        public ModuleModel getFirstModuleModelProject()
        Gets the first project.
        Returns:
        null For none.
      • getLoadedModuleProjects

        public java.lang.String[] getLoadedModuleProjects()
        Gets the names of all the loaded module projects.
      • getLoadedModuleModels

        public ModuleModel[] getLoadedModuleModels()
        Gets the loaded Module models projects.
        Returns:
        An array of all loaded Module model projects.
      • isOnClassPath

        public ModuleModel isOnClassPath​(org.eclipse.core.resources.IResource resource)
        Checks if a resource is inside the classpath of the Module projects.
        Parameters:
        resource - The resource to check.
        Returns:
        The first found Module project it belongs to, null if it doesn't belong to any.
      • getOnClassPathModules

        public ModuleModel[] getOnClassPathModules​(org.eclipse.core.resources.IResource resource)
        Gets the Module projects that a resource is inside the classpath of.
        Parameters:
        resource - The resource to check.
        Returns:
        The list of Module project it belongs to, null if it doesn't belong to any.
      • getProject

        public org.eclipse.core.resources.IProject getProject​(java.lang.String name)
        Gets a project from a name.
        Parameters:
        name - The project name.
        Returns:
        The project if name is valid and present and opened, null otherwise.
      • resourceChanged

        public void resourceChanged​(org.eclipse.core.resources.IResourceChangeEvent event)
        A resource event in the workspace occurred.

        Resource change events describe changes to resources.

        There are currently five different types of resource change events:

        • Before-the-fact batch reports of arbitrary creations, deletions and modifications to one or more resources expressed as a hierarchical resource delta. Event type is PRE_BUILD, and getDelta returns the hierarchical delta rooted at the workspace root. The getBuildKind method returns the kind of build that is about to occur, and the getSource method returns the scope of the build (either the workspace or a single project). These events are broadcast to interested parties immediately before each build operation. If auto-building is not enabled, these events still occur at times when auto-build would have occurred. The workspace is open for change during notification of these events. The delta reported in this event cycle is identical across all listeners registered for this type of event. Resource changes attempted during a PRE_BUILD callback must be done in the thread doing the notification.
        • After-the-fact batch reports of arbitrary creations, deletions and modifications to one or more resources expressed as a hierarchical resource delta. Event type is POST_BUILD, and getDelta returns the hierarchical delta rooted at the workspace root. The getBuildKind method returns the kind of build that occurred, and the getSource method returns the scope of the build (either the workspace or a single project). These events are broadcast to interested parties at the end of every build operation. If auto-building is not enabled, these events still occur at times when auto-build would have occurred. The workspace is open for change during notification of these events. The delta reported in this event cycle is identical across all listeners registered for this type of event. Resource changes attempted during a POST_BUILD callback must be done in the thread doing the notification.
        • After-the-fact batch reports of arbitrary creations, deletions and modifications to one or more resources expressed as a hierarchical resource delta. Event type is POST_CHANGE, and getDelta returns the hierarchical delta. The resource delta is rooted at the workspace root. These events are broadcast to interested parties after a set of resource changes and happen whether or not auto-building is enabled. The workspace is closed for change during notification of these events. The delta reported in this event cycle is identical across all listeners registered for this type of event.
        • Before-the-fact reports of the impending closure of a single project. Event type is PRE_CLOSE, and getResource returns the project being closed. The workspace is closed for change during notification of these events.
        • Before-the-fact reports of the impending deletion of a single project. Event type is PRE_DELETE, and getResource returns the project being deleted. The workspace is closed for change during notification of these events.
        • Before-the-fact reports of the impending refresh of a single project or the workspace. Event type is PRE_REFRESH and the getSource method returns the scope of the refresh (either the workspace or a single project). If the event is fired by a project refresh the getResource method returns the project being refreshed. The workspace is closed for changes during notification of these events.
        • In order to handle additional event types that may be introduced in future releases of the platform, clients should do not write code that presumes the set of event types is closed.
        Specified by:
        resourceChanged in interface org.eclipse.core.resources.IResourceChangeListener
      • isRegistered

        public boolean isRegistered​(org.eclipse.core.resources.IProject project)
        Checks if a project is registered with the Project Manager.
        Parameters:
        project - The project.
        Returns:
        true if this is a valid iizi Module Model project, false otherwise.
      • isRegistered

        public boolean isRegistered​(java.lang.String projectName)
        Checks if a project is registered with the Project Manager.
        Parameters:
        projectName - The project.
        Returns:
        true if this is a valid iizi Module Model project, false otherwise.
      • getModuleModel

        public ModuleModel getModuleModel​(java.lang.String projectName)
        Gets a registered iizi Module Model from a project name.
        Parameters:
        projectName - The project name.
        Returns:
        The Module Model instance, or null if not registered/valid.
      • onWorkspaceChange

        public void onWorkspaceChange​(RefactoringOperation operation)
        Called for workspace changes, new/rename/remove file/folder when processing delta-changes for the workspace. Do NOT call this method otherwise.
      • validateWorkspaceFiles

        public boolean validateWorkspaceFiles()
        Validates workspace files to see if there are references to "wild" properties. This is used for debugging and is VERY lengthy. Output to System.err and System.out is also performed.
        Returns:
        true for success, false for failure.
      • getModuleModel

        public ModuleModel getModuleModel​(org.eclipse.core.resources.IResource resource)
        Gets the iizi Module Model from a resource.
        Parameters:
        resource - Any resource (even null).
        Returns:
        The Module Model instance of the project; or, if the project is closed, doesn't have the iizi Module Nature or is not registered with the ProjectManager, this method returns null.
      • getModuleModel

        public ModuleModel getModuleModel​(GProp<?> gp)
        Gets the iizi Module Model from a property.
        Parameters:
        gp - The property (or null for none).
        Returns:
        The Module Model instance, or null if not found.
      • getModuleModel

        public ModuleModel getModuleModel​(org.eclipse.core.resources.IProject project)
        Gets the iizi Module Model from a project.
        Parameters:
        project - The project (or null).
        Returns:
        The Module Model instance of the project; or, if the project is closed, doesn't have the iizi Module Nature or is not registered with the ProjectManager, this method returns null.
      • onBuildStart

        public void onBuildStart​(org.eclipse.core.resources.IProject project)
        Informs the Project Manager that a build process is starting. This should be called for full or incremental builds.
        Parameters:
        project - The project build built, null for workspace.
      • onBuildEnd

        public void onBuildEnd​(org.eclipse.core.resources.IProject project)
        Informs the Project Manager that a build process has completed, with or without error. This should be called for full or incremental builds.
        Parameters:
        project - The project build built, null for workspace.
      • isProcessingWorkspaceModifications

        public boolean isProcessingWorkspaceModifications()
        Checks if the Project Manager is currently processing workspace modifications.
      • triggerReferenceValidationAllProjects

        public void triggerReferenceValidationAllProjects()
        Triggers all projects for reference validation, e.g. at project open/close/rename.
      • triggerReferenceValidationAllJavaProjects

        public void triggerReferenceValidationAllJavaProjects()
        Triggers all Java projects (i.e. not Module projects) for reference validation, e.g. at project open/close/rename.
      • triggerReferenceValidation

        public void triggerReferenceValidation​(org.eclipse.core.resources.IProject project,
                                               boolean onlyJava,
                                               boolean doReCheck)
        Triggers a project for reference validation.
        Parameters:
        project - The Module needing reference validation.
        onlyJava - Only if Java project(s).
        doReCheck - If a re-check of all references must be done.