Package org.omegat.core.data
Class RealProject
java.lang.Object
org.omegat.core.data.RealProject
- All Implemented Interfaces:
IProject
Loaded project implementation. Only translation could be changed after
project will be loaded and set by Core.setProject.
All components can read all data directly without synchronization. All
synchronization implemented inside RealProject.
Since team sync is long operation, auto-saving was split into 3 phrases: get
remote data in background, then rebase during segment deactivation, then
commit in background.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.omegat.core.data.IProject
IProject.AllTranslations, IProject.DefaultTranslationsIterator, IProject.FileInfo, IProject.MultipleTranslationsIterator, IProject.OptimisticLockingFail -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionalign(ProjectProperties props, File translatedDir) Align project.voidSignals to the core thread that a project is being closed now, and if it's still being loaded, core thread shouldn't throw any error.voidCommit source files in a team project.voidcompileProject(String sourcePattern) Builds translated files corresponding to sourcePattern and creates fresh TM files.voidcompileProject(String sourcePattern, boolean doPostProcessing) Builds translated files corresponding to sourcePattern and creates fresh TM files.voidcompileProjectAndCommit(String sourcePattern, boolean doPostProcessing, boolean commitTargetFiles) Builds translated files corresponding to sourcePattern and creates fresh TM files.voidCreate new project.Get all source segments.Get default and alternative translations for optimistic locking.Get all translation memories from /other_lang/ folder.Get info about each source file in project.Returns the active Project's Properties.Get ordered list of source file names.Returns tokenizer for source language.Get statistics info.getTargetPathForSourceFile(String currentSource) For a given source file, calculate the path of the target file that would be created by running Create Translated Documents (the file may not exist yet).Returns tokenizer for target language.Get translation info for specified entry.Get all translation memories from /tm/ folder.booleanisOrphaned(String source) Check if orphaned.booleanisOrphaned(EntryKey entry) Check if orphaned.booleanGet project loaded status.booleanReturns whether the project was modified.booleanTells whether a project is a team projectbooleanCheck if team synchronization prepared.voidIterate by all default translations in project.voidIterate by all multiple translations in project.voidloadProject(boolean onlineMode) Load exist project in a "big" sense -- loads project's properties, glossaries, tms, source files etc.voidsaveProject(boolean doTeamSync) Saves the translation memory and preferences.voidSave project properties only.voidsetNote(SourceTextEntry entry, TMXEntry oldTE, String note) Change note only for translation.voidsetSourceFilesOrder(List<String> filesList) Set ordered list of source file names.voidsetTranslation(SourceTextEntry entry, PrepareTMXEntry trans, boolean defaultTranslation, TMXEntry.ExternalLinked externalLinked) Set translation for entry.voidsetTranslation(SourceTextEntry entry, PrepareTMXEntry trans, boolean defaultTranslation, TMXEntry.ExternalLinked externalLinked, IProject.AllTranslations previous) Set translation for entry with optimistic lock checking: if previous translation is not the same like in storage, OptimisticLockingFail exception will be generated.voidteamSync()Fast team sync for execute from SaveThread.voidPrepare for future team sync.
-
Constructor Details
-
RealProject
Create new project instance. It required to callcreateProject()orloadProject(boolean)methods just after constructor before use project.- Parameters:
props- project properties
-
-
Method Details
-
saveProjectProperties
Description copied from interface:IProjectSave project properties only.- Specified by:
saveProjectPropertiesin interfaceIProject- Throws:
Exception
-
createProject
public void createProject()Create new project. -
loadProject
public void loadProject(boolean onlineMode) Load exist project in a "big" sense -- loads project's properties, glossaries, tms, source files etc. -
align
Align project.- Throws:
Exception
-
isProjectLoaded
public boolean isProjectLoaded()Description copied from interface:IProjectGet project loaded status.- Specified by:
isProjectLoadedin interfaceIProject- Returns:
- true if project loaded
-
getStatistics
Description copied from interface:IProjectGet statistics info.- Specified by:
getStatisticsin interfaceIProject
-
closeProject
public void closeProject()Signals to the core thread that a project is being closed now, and if it's still being loaded, core thread shouldn't throw any error.- Specified by:
closeProjectin interfaceIProject
-
compileProject
Builds translated files corresponding to sourcePattern and creates fresh TM files. Convenience method. Assumes we want to run external post-processing commands.- Specified by:
compileProjectin interfaceIProject- Parameters:
sourcePattern- The regexp of files to create- Throws:
Exception
-
compileProject
Builds translated files corresponding to sourcePattern and creates fresh TM files. Calls the actual compile project method, assumes we don't want to commit target files.- Parameters:
sourcePattern- The regexp of files to createdoPostProcessing- Whether or not we should perform external post-processing.- Throws:
Exception
-
compileProjectAndCommit
public void compileProjectAndCommit(String sourcePattern, boolean doPostProcessing, boolean commitTargetFiles) throws Exception Builds translated files corresponding to sourcePattern and creates fresh TM files.- Specified by:
compileProjectAndCommitin interfaceIProject- Parameters:
sourcePattern- The regexp of files to createdoPostProcessing- Whether or not we should perform external post-processing.commitTargetFiles- Whether or not we should commit target files- Throws:
Exception- If any error occurs during the compilation process.
-
saveProject
public void saveProject(boolean doTeamSync) Saves the translation memory and preferences.This method must be executed in the Core.executeExclusively.
- Specified by:
saveProjectin interfaceIProject
-
teamSyncPrepare
Prepare for future team sync. This method must be executed in the Core.executeExclusively.- Specified by:
teamSyncPreparein interfaceIProject- Throws:
Exception
-
isTeamSyncPrepared
public boolean isTeamSyncPrepared()Description copied from interface:IProjectCheck if team synchronization prepared.- Specified by:
isTeamSyncPreparedin interfaceIProject
-
teamSync
public void teamSync()Fast team sync for execute from SaveThread. This method must be executed in the Core.executeExclusively. -
getAllEntries
Get all source segments. It's unmodifiable list, so, there is no need synchronization to read it.- Specified by:
getAllEntriesin interfaceIProject
-
getTranslationInfo
Description copied from interface:IProjectGet translation info for specified entry. It looks first for multiple, then for default. This method ALWAYS returns TMXEntry, because note can exist even for non-translated segment. Use TMXEntry.isTranslated() for check if translation text really exist. Translation can be checked for default/alternative by the TMXEntry.defaultTranslation.- Specified by:
getTranslationInfoin interfaceIProject- Parameters:
ste- source entry- Returns:
- translation
-
getAllTranslations
Description copied from interface:IProjectGet default and alternative translations for optimistic locking.- Specified by:
getAllTranslationsin interfaceIProject
-
getProjectProperties
Returns the active Project's Properties.- Specified by:
getProjectPropertiesin interfaceIProject- Returns:
- project properties
-
isProjectModified
public boolean isProjectModified()Returns whether the project was modified. I.e. translations were changed since last save.- Specified by:
isProjectModifiedin interfaceIProject
-
setTranslation
public void setTranslation(SourceTextEntry entry, PrepareTMXEntry trans, boolean defaultTranslation, TMXEntry.ExternalLinked externalLinked, IProject.AllTranslations previous) throws IProject.OptimisticLockingFail Description copied from interface:IProjectSet translation for entry with optimistic lock checking: if previous translation is not the same like in storage, OptimisticLockingFail exception will be generated. Use when user has typed a new translation.- Specified by:
setTranslationin interfaceIProject- Parameters:
entry- entrytrans- translation. It can't be null- Throws:
IProject.OptimisticLockingFail
-
setTranslation
public void setTranslation(SourceTextEntry entry, PrepareTMXEntry trans, boolean defaultTranslation, TMXEntry.ExternalLinked externalLinked) Description copied from interface:IProjectSet translation for entry.Optimistic locking will not be checked.
- Specified by:
setTranslationin interfaceIProject- Parameters:
entry- entrytrans- translation. It can't be null
-
setNote
Description copied from interface:IProjectChange note only for translation. -
iterateByDefaultTranslations
Description copied from interface:IProjectIterate by all default translations in project.- Specified by:
iterateByDefaultTranslationsin interfaceIProject
-
iterateByMultipleTranslations
Description copied from interface:IProjectIterate by all multiple translations in project.- Specified by:
iterateByMultipleTranslationsin interfaceIProject
-
isOrphaned
Description copied from interface:IProjectCheck if orphaned.- Specified by:
isOrphanedin interfaceIProject
-
isOrphaned
Description copied from interface:IProjectCheck if orphaned.- Specified by:
isOrphanedin interfaceIProject
-
getTransMemories
Description copied from interface:IProjectGet all translation memories from /tm/ folder.- Specified by:
getTransMemoriesin interfaceIProject- Returns:
- translation memories
-
getOtherTargetLanguageTMs
Description copied from interface:IProjectGet all translation memories from /other_lang/ folder.- Specified by:
getOtherTargetLanguageTMsin interfaceIProject- Returns:
- translation memories
-
getSourceTokenizer
Returns tokenizer for source language.- Specified by:
getSourceTokenizerin interfaceIProject
-
getTargetTokenizer
Returns tokenizer for target language.- Specified by:
getTargetTokenizerin interfaceIProject
-
getProjectFiles
Get info about each source file in project. It's unmodifiable list, so, there is no need synchronization to read it.- Specified by:
getProjectFilesin interfaceIProject
-
getTargetPathForSourceFile
Description copied from interface:IProjectFor a given source file, calculate the path of the target file that would be created by running Create Translated Documents (the file may not exist yet).The target path must be calculated because it can depend on project properties such as the target language, etc.
- Specified by:
getTargetPathForSourceFilein interfaceIProject- Parameters:
currentSource- The relative path (under thesourcedirectory) of the source file, e.g.Bundle.properties- Returns:
- The relative path (under the
targetdirectory) of the corresponding target file, e.g.Bundle_fr_FR.properties
-
getSourceFilesOrder
Description copied from interface:IProjectGet ordered list of source file names.- Specified by:
getSourceFilesOrderin interfaceIProject
-
setSourceFilesOrder
Description copied from interface:IProjectSet ordered list of source file names.- Specified by:
setSourceFilesOrderin interfaceIProject
-
isRemoteProject
public boolean isRemoteProject()Description copied from interface:IProjectTells whether a project is a team project- Specified by:
isRemoteProjectin interfaceIProject- Returns:
- whether the project is a team project
-
commitSourceFiles
Description copied from interface:IProjectCommit source files in a team project.- Specified by:
commitSourceFilesin interfaceIProject- Throws:
Exception- if any error occurs during the commit process
-