Class ModuleModel

java.lang.Object
com.iizigo.project.ModuleModel

public class ModuleModel extends Object
The IIZI Module Model.
Author:
Christopher Mindus
  • Field Details

    • RESOURCE_NAME_MARKER_ID

      public static final String RESOURCE_NAME_MARKER_ID
      The marker ID for resource name problems.
      See Also:
    • LOAD_FILE_MARKER_ID

      public static final String LOAD_FILE_MARKER_ID
      The marker ID for load file problems.
      See Also:
    • MISSING_RESOURCE_MARKER_ID

      public static final String MISSING_RESOURCE_MARKER_ID
      The marker ID for missing project resource problems.
      See Also:
    • MODULE_DIRECTORY_NAME

      public static final String MODULE_DIRECTORY_NAME
      The "iiziModule" module directory name, where files are stored.
      See Also:
    • MODULE_SETTINGS_FILE_NAME

      public static final String MODULE_SETTINGS_FILE_NAME
      The ".iiziModuleProject" file name containing all settings.
      See Also:
    • moduleSettings

      public final IFile moduleSettings
      The IIZI Module settings file, null when creating new model project.
  • Method Details

    • from

      public static ModuleModel from(IProject project)
      Gets the module model from a project if possible.
      Parameters:
      project - The project.
      Returns:
      The module model if the project is an IIZI Module project, null otherwise.
    • getAppDistributionFile

      public IFile getAppDistributionFile()
      Gets the application distribution file.
      Returns:
      The file, but it may not exist!
    • getJavaPropCnr

      public JavaRootContainer getJavaPropCnr()
      Gets the property container for a project.
      Returns:
      The Java property container.
    • getSettings

      public ModuleProjectSettings getSettings()
      Gets the Module Project Settings.
    • isReservedResource

      public String isReservedResource(IResource resource)
      Checks if the resource is a reserved resource.
      Parameters:
      resource - File or Folder to check.
      Returns:
      The error string or null for no error. An error is returned if it's a project or the workspace root.
    • isDisposed

      public boolean isDisposed()
      Checks if the Module project is disposed of.
    • getJavaProject

      public org.eclipse.jdt.core.IJavaProject getJavaProject()
      Gets the Java Project instance for this project.
    • addPlugin

      public void addPlugin(PluginDescriptor pd, boolean doCreateDir) throws CoreException
      Adds a plug-in to this Module project instance, without creating anything. If a folder doesn't exist, CoreException is thrown.

      This model's monitor is held only around its lists of plug-ins and Module folders, never while the workspace is changed - the plug-in's directory created, the Module settings saved (validateProjectResourcePresence() says why).

      Parameters:
      pd - The plug-in description.
      doCreateDir - Flag to create the directory of the plug-in, if it is directory/file plug-in.
      Throws:
      CoreException - For errors.
    • getPlugins

      public PluginDescriptor[] getPlugins()
      Gets the associated plug-ins.
      Returns:
      The array of plug-in's.
    • removePlugin

      public int removePlugin(PluginDescriptor pd) throws CoreException
      Removes the specified plug-in from this project. This can only be done if no files are present in the folder.

      As addPlugin(PluginDescriptor, boolean): this model's monitor is held only around its lists, never while the plug-in's directory is deleted or the Module settings are saved.

      Parameters:
      pd - The plug-in description.
      Returns:
      0=OK, 1=not active, 2=Can't remove: directory is not empty, 3=directory error.
      Throws:
      CoreException - For errors.
    • isPluginActive

      public boolean isPluginActive(PluginDescriptor pd)
      Checks if a plug-in is active in the Module project.
      Returns:
      true if the plug-in is active, false otherwise.
    • getBaseModuleFolder

      public IFolder getBaseModuleFolder()
      Gets the base module folder "iiziModule".
      Returns:
      The base module folder.
    • getVirtualSpaceModuleFolder

      public ModuleFolder getVirtualSpaceModuleFolder()
      Gets the module folder for VirtualSpace.
      Returns:
      The ModuleFolder instance.
    • getPanelModuleFolder

      public ModuleFolder getPanelModuleFolder()
      Gets the module folder for panels.
      Returns:
      The ModuleFolder instance.
    • getStyleModuleFolder

      public ModuleFolder getStyleModuleFolder()
      Gets the module folder for styles.
      Returns:
      The ModuleFolder instance.
    • getSelectorModuleFolder

      public ModuleFolder getSelectorModuleFolder()
      Gets the module folder for selectors.
      Returns:
      The ModuleFolder instance.
    • getImageDefinitionModuleFolder

      public ModuleFolder getImageDefinitionModuleFolder()
      Gets the module folder for image definitions.
      Returns:
      The ModuleFolder instance.
    • getAssetsModuleFolder

      public ModuleFolder getAssetsModuleFolder()
      Gets the module folder for assets.
      Returns:
      The ModuleFolder instance.
    • getTextTableModuleFolder

      public ModuleFolder getTextTableModuleFolder()
      Gets the module folder for text tables.
      Returns:
      The ModuleFolder instance.
    • getModuleFolder

      public ModuleFolder getModuleFolder(String type)
      Gets the array of folders defined for the module project.
      Parameters:
      type - The type, e.g. "panel".
      Returns:
      The ModuleFolder for the type, null if not found.
    • getModuleFolder

      public ModuleFolder getModuleFolder(PluginDescriptor pd)
      Gets the module folder for a plug-in.
      Parameters:
      pd - The plug-in descriptor.
      Returns:
      The ModuleFolder for the type, null if defined for the project, or the plug-in is not directory based.
    • getModuleFolders

      public ModuleFolder[] getModuleFolders()
      Gets the array of folders defined for the module project.
      Returns:
      A new array of the ModuleFolder's.
    • getProject

      public IProject getProject()
      Gets the project.
      Returns:
      The Eclipse project.
    • getRootContainer

      public ModuleRootPropCnr getRootContainer()
      Gets the root container.
      Returns:
      The root property container for the Module.
    • getKStringInfoProvider

      public IKStringInfoProvider getKStringInfoProvider()
      Gets a KStringInfoProvider initialized for the module model.
      Returns:
      A KStringInfoProvider instance.
    • getCNChildren

      public Object[] getCNChildren()
      Gets the children (just one) for the root container for the Common Navigator.
      Returns:
      The children to display for the Common Navigator.
    • hasCompletedLoading

      public boolean hasCompletedLoading()
      Verifies if project has completed loading and it is not disposed of.
      Returns:
      true if loading has completed and the project is not closed or disposed of.
    • loadErrorText

      public static String loadErrorText(Throwable e)
      What a file that did not load is told with: the message of the innermost cause of the load error, which says what the file holds that cannot be loaded (the element of a component that is no part of IIZI any more, an XML error). It is the text of the file's error marker (which stands on the file, so the file is not named again) and the end of an editor's refusal to open the file (PropEditorPart.proceedInit), which the workbench shows on its error page.
      Parameters:
      e - The load error.
      Returns:
      The text, never null.
    • validateProjectResourcePresence

      public boolean validateProjectResourcePresence()
      Validates the presence of the required project resources and the problem markers for the project.

      What has to change - which of the project's markers go, which are new - is decided under this model's monitor; the Eclipse markers are deleted and created after it, never under it (CC-FIX-MODULEMODEL-LOCKS, ruling MD-D-1; the pattern of PropMarker.createMarker). To delete or create a marker the workspace is asked, which waits for the workspace lock, and the thread that holds that lock runs the resource change listeners before it gives the lock back: the notification that a project closes or is deleted calls dispose(), which takes this monitor, and so do getPlugins() and isPluginActive(PluginDescriptor) wherever a listener calls them. A thread that waited for the workspace lock while it held this monitor and such a listener would wait for each other forever.

      Returns:
      true for OK, false for error.
    • getQuickFixCreateFolders

      public IFolder[] getQuickFixCreateFolders()
      Gets the array of folders required to be created.
      Returns:
      The array of folders that needs to be created, null for none (i.e. OK).
    • saveSettings

      public void saveSettings()
      Saves the settings when possible. If the workspace is locked, the operation is postponed in a Job.
    • flushSettings

      public CoreException flushSettings()
      Writes the Module settings now when a postponed save is pending: the "Save Module project settings" job that a save from a locked workspace scheduled is cancelled, and its save is done here, by the caller, which must be allowed to write the settings file. A rename of the project calls it first, so that the job does not write the settings after the rename's operation, into the project of the old name (CC-FIX-IIZIGO-G4-PROJECT-LIFECYCLE).
      Returns:
      null for success or when no save is pending, otherwise the exception of the save.
    • saveSettings

      public CoreException saveSettings(Shell shell)
      Saves the module settings.
      Parameters:
      shell - Shell used for error message, null for logging only.
      Returns:
      null for success, otherwise the exception.
    • isModuleSettingsFile

      public boolean isModuleSettingsFile(IResource file)
      Checks if the file is the module settings file.
      Parameters:
      file - The file to test with.
      Returns:
      true if it's the module settings file, false otherwise.
    • isOnClassPath

      public boolean isOnClassPath(IResource resource)
      Checks if a resource is inside the classpath of this Module project.
      Parameters:
      resource - The resource to check.
      Returns:
      true if it's on the classpath, false otherwise.
    • markModuleReference

      public void markModuleReference(ModuleModel module)
      Marks a Module as being used by or referenced in this project.
      Parameters:
      module - The module to mark as referenced.
    • markModuleReference

      public void markModuleReference(String moduleName)
      Marks a Module as being used by or referenced in this project.
      Parameters:
      moduleName - The module name to mark as referenced.
    • getModuleNameReferences

      public String[] getModuleNameReferences()
      Gets the Modules that are referenced by this Module project.
      Returns:
      An new (cloned) array of all the referenced Module names.
    • getProjectReferences

      public IProject[] getProjectReferences(boolean onlyModuleProjects)
      Gets the Projects that are referenced by this Module project.
      Parameters:
      onlyModuleProjects - Flag for only module projects, or if Java projects should be added too.
      Returns:
      An new (cloned) array of all the referenced Module Projects. The projects can be both Java projects as well as Module projects.
    • getModuleProjectReferences

      public ModuleModel[] getModuleProjectReferences()
      Gets the Projects that are referenced by this Module project. This module is included first.
      Returns:
      An new (cloned) array of all the referenced Module Projects.
    • getReferencedDesignerPropModules

      public ResourceDesignerProp[] getReferencedDesignerPropModules()
      Gets the designer properties of the module models that are referenced by this Module project. This project's designer property always comes first.
      Returns:
      An new (cloned) array of all the Module Project's designer properties.
    • getBuildPathProjects

      public List<IProject> getBuildPathProjects()
      Gets the Java projects that are included on the classpath of this project.
      Returns:
      A new list of projects on the build path.
    • addCommitRefactoringListener

      public boolean addCommitRefactoringListener(ICommitRefactoring listener, RefactoringOperation... operations)
      Adds a listener for Commit Refactoring in this project.
      Parameters:
      listener - The listener.
      operations - The operations of interest.
      Returns:
      true if successful, false if listener was already present.
    • removeCommitRefactoringListener

      public boolean removeCommitRefactoringListener(ICommitRefactoring listener)
      Removes a listener for Commit Refactoring in this project.
      Parameters:
      listener - The listener.
      Returns:
      true if successful, false if listener was not present.
    • scheduleCleanAndRebuild

      public void scheduleCleanAndRebuild()
      Schedules a full build of a project.
    • cleanRebuildPropertyMarkers

      public void cleanRebuildPropertyMarkers()
      Cleans the property error markers from this project, its settings file beside the Module folder too, and rebuilds them.
    • saveClasspath

      public void saveClasspath()
      Saves the Java classpath of a project in order to be able to use it in the Server.
    • getInstalledFonts

      public ArrayList<EditorFontFiles> getInstalledFonts()
      Gets all the installed fonts in this project and all projects referenced.
      Returns:
      A new list with the font files instances.
    • getStylesFontFiles

      public EditorFontFiles[] getStylesFontFiles()
      Gets the fonts installed in this module project.
      Returns:
      A new array of font files, only from the styles font faces.
    • getInstalledFontsMap

      public Map<String, List<FontFiles>> getInstalledFontsMap()
      Gets the map of installed fonts. This map is cached and a read-only copy is returned. The key in the map is the font family name. If a font family has several styles/weights defined, the normal weight and style is used the EditorFontFiles instance.
      Returns:
      An unmodifiable map of the installed fonts. Do not modify this map or the List value(s), it is a shared instance.
    • clearInstalledFontsMapAndCustomCSSCache

      public void clearInstalledFontsMapAndCustomCSSCache()
      Clears the installed font map cache and custom CSS files.
    • addResourceListener

      public boolean addResourceListener(IModuleProjectResourceListener listener)
      Adds a new resource listener when a resource is added or removed. Calling this method multiple times with the same listener will have no effect (but to return false).
      Parameters:
      listener - The listener to add.
      Returns:
      true if the listener was added, false otherwise.
      Throws:
      NullPointerException - If the listener is null.
    • removeResourceListener

      public boolean removeResourceListener(IModuleProjectResourceListener listener)
      Removes a new resource listener when a resource is added or removed.
      Parameters:
      listener - The listener to remove.
      Returns:
      true if listener is successfully removed, false otherwise.