Package org.omegat.gui.glossary
Class GlossaryManager
- java.lang.Object
-
- org.omegat.gui.glossary.GlossaryManager
-
- All Implemented Interfaces:
DirectoryMonitor.Callback
public class GlossaryManager extends java.lang.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 Summary
Constructors Constructor Description GlossaryManager(GlossaryTextArea pane)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGlossaryProvider(IGlossary provider)
static boolean
createNewWritableGlossaryFile(java.io.File file)
Create new default writable glossary file.void
fileChanged(java.io.File file)
Called on any file changes - created, modified, deleted.void
forceReloadTBX()
void
forceUpdateGlossary()
java.util.List<GlossaryEntry>
getGlossaryEntries(java.lang.String src)
Get glossary entries.java.util.List<GlossaryEntry>
getLocalEntries()
Get glossary entries for search operation.java.util.List<GlossaryEntry>
searchSourceMatches(SourceTextEntry ste)
Get all glossary entries with source terms found in the provided string.java.util.List<Token[]>
searchSourceMatchTokens(SourceTextEntry ste, GlossaryEntry entry)
Get tokens of the source text that match the supplied glossary entry.java.util.List<java.lang.String>
searchTargetMatches(java.lang.String trg, ProtectedPart[] protectedParts, GlossaryEntry entry)
Get all target terms for the provided glossary entry that can be found in the provided string.void
start()
void
stop()
-
-
-
Constructor Detail
-
GlossaryManager
public GlossaryManager(GlossaryTextArea pane)
-
-
Method Detail
-
createNewWritableGlossaryFile
public static boolean createNewWritableGlossaryFile(java.io.File file) throws java.io.IOException
Create new default writable glossary file.- Parameters:
file
- a file to be created.- Returns:
- true if the file was successfully created
- Throws:
java.io.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(java.io.File file)
Description copied from interface:DirectoryMonitor.Callback
Called on any file changes - created, modified, deleted.- Specified by:
fileChanged
in interfaceDirectoryMonitor.Callback
-
forceReloadTBX
public void forceReloadTBX()
-
forceUpdateGlossary
public void forceUpdateGlossary()
-
getGlossaryEntries
public java.util.List<GlossaryEntry> getGlossaryEntries(java.lang.String src)
Get glossary entries.- Parameters:
src
-- Returns:
- all entries
-
getLocalEntries
public java.util.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 java.util.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 java.util.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 java.util.List<java.lang.String> searchTargetMatches(java.lang.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 searchprotectedParts
- 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
-
-