Class AbstractFileStorageProvider

java.lang.Object
com.e1c.langtool.storage.AbstractFileStorageProvider
All Implemented Interfaces:
ITranslationStorageProvider
Direct Known Subclasses:
ContextFileStorageProvider, DictionaryFileStorageProvider

public abstract class AbstractFileStorageProvider extends Object implements ITranslationStorageProvider
The abstract class of resource file storage provider with common logic of creating AbstractFileStorage with the project settings, track changes of the settings and re-create storages with dispose evicted instance of storage.
  • Field Details

  • Constructor Details

  • Method Details

    • isActive

      public boolean isActive()
      Description copied from interface: ITranslationStorageProvider
      Checks whether it active and can be used or not.
      Specified by:
      isActive in interface ITranslationStorageProvider
      Returns:
      true, if is active
    • initialize

      public void initialize(org.eclipse.core.resources.IProject project, List<String> segments)
      Description copied from interface: ITranslationStorageProvider
      Initialize.
      Specified by:
      initialize in interface ITranslationStorageProvider
      Parameters:
      project - the project
      segments - the segments
    • getStorageSegments

      public List<String> getStorageSegments(org.eclipse.core.resources.IProject project)
      Description copied from interface: ITranslationStorageProvider
      At least one segment ID should be returned to use the provider. String cannot contains `:`, which used for separation provider_id and segment for global "Storage ID" in the project: com.e1c.langtool.storage:common com.e1c.langtool.storage:context
      Specified by:
      getStorageSegments in interface ITranslationStorageProvider
      Parameters:
      project - the project
      Returns:
      the storage segments
    • getStorageDescription

      public String getStorageDescription(org.eclipse.core.resources.IProject project, String segment)
      Description copied from interface: ITranslationStorageProvider
      Gets the storage description.
      Specified by:
      getStorageDescription in interface ITranslationStorageProvider
      Parameters:
      project - the project
      segment - the segment
      Returns:
      the storage description
    • getStorage

      public ITranslationStorageProvider.Storage getStorage(org.eclipse.core.resources.IProject project, String segment)
      Description copied from interface: ITranslationStorageProvider
      Gets the storage.
      Specified by:
      getStorage in interface ITranslationStorageProvider
      Parameters:
      project - the project
      segment - the segment
      Returns:
      the storage
    • settingsChanged

      protected void settingsChanged(org.eclipse.core.resources.IProject project, boolean projectClosed)
      Process the change of the project settings. This method remove evicted storages of the project and dispose them.
      Parameters:
      project - the project of changed settings, cannot be null.
      projectClosed - the project closed
    • createStorage

      protected abstract ITranslationStorageProvider.Storage createStorage(org.eclipse.core.resources.IProject project, String segment)
      Creates the storage by the given project and segment.
      Parameters:
      project - the project, cannot be null.
      segment - the segment, cannot be null.
      Returns:
      the storage, cannot be null.
    • disposeStorage

      protected void disposeStorage(org.eclipse.core.resources.IProject project, String segment, ITranslationStorageProvider.Storage storage)
      Dispose storage if the project settings changed.
      Parameters:
      project - the project, cannot be null.
      segment - the segment, cannot be null.
      storage - the storage, cannot be null.
    • getProjectSettings

      protected abstract Collection<? extends ResourceStorageSettings> getProjectSettings(org.eclipse.core.resources.IProject project)
      Gets the project resource storage settings.
      Parameters:
      project - the project, cannot be null.
      Returns:
      the project settings, can return null.