Class GlossaryManager

java.lang.Object
org.omegat.gui.glossary.GlossaryManager
All Implemented Interfaces:
DirectoryMonitor.Callback

@NullMarked public class GlossaryManager extends Object implements DirectoryMonitor.Callback
Class that loads glossary files and adds glossary entries to strings of the source files.

This class don't need any threads synchronization code, since it only set and clear 'glossaryEntries' var.

  • Constructor Details

    • GlossaryManager

      public GlossaryManager(IGlossaries pane)
  • Method Details

    • createNewWritableGlossaryFile

      public static boolean createNewWritableGlossaryFile(File file) throws IOException
      Create new default writable glossary file.
      Parameters:
      file - a file to be created.
      Returns:
      true if the file was successfully created
      Throws:
      IOException - when there is a problem to create file.
    • addGlossaryProvider

      public void addGlossaryProvider(IGlossary provider)
    • start

      public void start()
    • stop

      public void stop()
    • fileChanged

      public void fileChanged(File file)
      Description copied from interface: DirectoryMonitor.Callback
      Called on any file changes - created, modified, deleted.
      Specified by:
      fileChanged in interface DirectoryMonitor.Callback
    • forceReloadTBX

      public void forceReloadTBX()
    • forceUpdateGlossary

      public void forceUpdateGlossary()
    • getGlossaryEntries

      public List<GlossaryEntry> getGlossaryEntries(String src)
      Get glossary entries.
      Parameters:
      src - keyword of the glossary to seek.
      Returns:
      all entries
    • getLocalEntries

      public List<GlossaryEntry> getLocalEntries()
      Get glossary entries for search operation. Almost the same as getGlossaryEntries(), except search usually executed for every segment in project, i.e. should work enough fast. Then, search should be produced by local files only.
      Returns:
      all entries
    • searchSourceMatches

      public List<GlossaryEntry> searchSourceMatches(SourceTextEntry ste)
      Get all glossary entries with source terms found in the provided string.
      Returns:
      A list of matching glossary entries
    • searchSourceMatchTokens

      public List<Token[]> searchSourceMatchTokens(SourceTextEntry ste, GlossaryEntry entry)
      Get tokens of the source text that match the supplied glossary entry.
      Parameters:
      ste - The entry to search
      Returns:
      A list of tokens matching the supplied glossary entry
    • searchTargetMatches

      public List<String> searchTargetMatches(String trg, ProtectedPart[] protectedParts, GlossaryEntry entry)
      Get all target terms for the provided glossary entry that can be found in the provided string.
      Parameters:
      trg - The text to search
      protectedParts - A list of protected parts from which matches should be disregarded (can be null)
      entry - The glossary entry whose target terms should be searched
      Returns:
      A list of matching target terms