public class RealProject extends java.lang.Object implements IProject
Modifier and Type | Class and Description |
---|---|
protected class |
RealProject.LoadFilesCallback |
IProject.AllTranslations, IProject.DefaultTranslationsIterator, IProject.FileInfo, IProject.MultipleTranslationsIterator, IProject.OptimisticLockingFail
Modifier and Type | Field and Description |
---|---|
protected java.util.List<SourceTextEntry> |
allProjectEntries
List of all segments in project.
|
protected ProjectProperties |
config |
protected ImportFromAutoTMX |
importHandler |
protected java.util.List<IProject.FileInfo> |
projectFilesList
Segments count in project files.
|
protected ProjectTMX |
projectTMX |
protected RemoteRepositoryProvider |
remoteRepositoryProvider |
Constructor and Description |
---|
RealProject(ProjectProperties props)
Create new project instance.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,TMXEntry> |
align(ProjectProperties props,
java.io.File translatedDir)
Align project.
|
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.
|
void |
commitSourceFiles()
Commit source files in a team project.
|
void |
compileProject(java.lang.String sourcePattern)
Builds translated files corresponding to sourcePattern and creates fresh TM files.
|
void |
compileProject(java.lang.String sourcePattern,
boolean doPostProcessing)
Builds translated files corresponding to sourcePattern and creates fresh TM files.
|
void |
compileProjectAndCommit(java.lang.String sourcePattern,
boolean doPostProcessing,
boolean commitTargetFiles)
Builds translated files corresponding to sourcePattern and creates fresh TM files.
|
void |
createProject()
Create new project.
|
protected ITokenizer |
createTokenizer(java.lang.String cmdLine,
java.lang.Class<?> projectPref)
Create tokenizer class.
|
protected void |
findNonUniqueSegments() |
java.util.List<SourceTextEntry> |
getAllEntries()
Get all source segments.
|
IProject.AllTranslations |
getAllTranslations(SourceTextEntry ste)
Get default and alternative translations for optimistic locking.
|
java.util.Map<Language,ProjectTMX> |
getOtherTargetLanguageTMs()
Get all translation memories from /other_lang/ folder.
|
java.util.List<IProject.FileInfo> |
getProjectFiles()
Get info about each source file in project.
|
ProjectProperties |
getProjectProperties()
Returns the active Project's Properties.
|
java.util.List<java.lang.String> |
getSourceFilesOrder()
Get ordered list of source file names.
|
ITokenizer |
getSourceTokenizer()
Returns tokenizer for source language.
|
StatisticsInfo |
getStatistics()
Get statistics for project.
|
java.lang.String |
getTargetPathForSourceFile(java.lang.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).
|
ITokenizer |
getTargetTokenizer()
Returns tokenizer for target language.
|
TMXEntry |
getTranslationInfo(SourceTextEntry ste)
Get translation info for specified entry.
|
java.util.Map<java.lang.String,ExternalTMX> |
getTransMemories()
Get all translation memories from /tm/ folder.
|
boolean |
isOrphaned(EntryKey entry)
Check if orphaned.
|
boolean |
isOrphaned(java.lang.String source)
Check if orphaned.
|
boolean |
isProjectLoaded()
Get project loaded status.
|
boolean |
isProjectModified()
Returns whether the project was modified.
|
boolean |
isRemoteProject()
Tells whether a project is a team project
|
boolean |
isTeamSyncPrepared()
Check if team synchronization prepared.
|
void |
iterateByDefaultTranslations(IProject.DefaultTranslationsIterator it)
Iterate by all default translations in project.
|
void |
iterateByMultipleTranslations(IProject.MultipleTranslationsIterator it)
Iterate by all multiple translations in project.
|
void |
loadProject(boolean onlineMode)
Load exist project in a "big" sense -- loads project's properties, glossaries, tms, source files etc.
|
protected boolean |
lockProject()
Lock omegat.project file against rename or move project.
|
protected void |
mergeTMX(ProjectTMX baseTMX,
ProjectTMX headTMX,
java.lang.StringBuilder commitDetails)
Do 3-way merge of:
Base: baseTMX
File 1: projectTMX (mine)
File 2: headTMX (theirs)
|
protected java.lang.String |
patchFileNameForEntryKey(java.lang.String filename)
This method converts directory separators into Unix-style.
|
void |
saveProject(boolean doTeamSync)
Saves the translation memory and preferences.
|
void |
saveProjectProperties()
Save project properties only.
|
void |
setNote(SourceTextEntry entry,
TMXEntry oldTE,
java.lang.String note)
Change note only for translation.
|
void |
setSourceFilesOrder(java.util.List<java.lang.String> filesList)
Set ordered list of source file names.
|
void |
setTranslation(SourceTextEntry entry,
PrepareTMXEntry trans,
boolean defaultTranslation,
TMXEntry.ExternalLinked externalLinked)
Set translation for entry.
|
void |
setTranslation(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.
|
void |
teamSync()
Fast team sync for execute from SaveThread.
|
void |
teamSyncPrepare()
Prepare for future team sync.
|
protected void |
unlockProject()
Unlock omegat.project file against rename or move project.
|
protected final ProjectProperties config
protected final RemoteRepositoryProvider remoteRepositoryProvider
protected java.util.List<SourceTextEntry> allProjectEntries
protected ImportFromAutoTMX importHandler
protected ProjectTMX projectTMX
protected java.util.List<IProject.FileInfo> projectFilesList
public RealProject(ProjectProperties props)
createProject()
or loadProject(boolean)
methods just after constructor before
use project.props
- project propertiespublic void saveProjectProperties() throws java.lang.Exception
IProject
saveProjectProperties
in interface IProject
java.lang.Exception
public void createProject()
public void loadProject(boolean onlineMode)
public java.util.Map<java.lang.String,TMXEntry> align(ProjectProperties props, java.io.File translatedDir) throws java.lang.Exception
java.lang.Exception
public boolean isProjectLoaded()
isProjectLoaded
in interface IProject
public StatisticsInfo getStatistics()
getStatistics
in interface IProject
public void closeProject()
closeProject
in interface IProject
protected boolean lockProject()
protected void unlockProject()
public void compileProject(java.lang.String sourcePattern) throws java.lang.Exception
compileProject
in interface IProject
sourcePattern
- The regexp of files to createjava.lang.Exception
public void compileProject(java.lang.String sourcePattern, boolean doPostProcessing) throws java.lang.Exception
sourcePattern
- The regexp of files to createdoPostProcessing
- Whether or not we should perform external post-processing.java.lang.Exception
public void compileProjectAndCommit(java.lang.String sourcePattern, boolean doPostProcessing, boolean commitTargetFiles) throws java.lang.Exception
compileProjectAndCommit
in interface IProject
sourcePattern
- The regexp of files to createdoPostProcessing
- Whether or not we should perform external post-processing.commitTargetFiles
- Whether or not we should commit target filesjava.lang.Exception
public void saveProject(boolean doTeamSync)
saveProject
in interface IProject
public void teamSyncPrepare() throws java.lang.Exception
teamSyncPrepare
in interface IProject
java.lang.Exception
public boolean isTeamSyncPrepared()
IProject
isTeamSyncPrepared
in interface IProject
public void teamSync()
protected void mergeTMX(ProjectTMX baseTMX, ProjectTMX headTMX, java.lang.StringBuilder commitDetails)
protected void findNonUniqueSegments()
public java.util.List<SourceTextEntry> getAllEntries()
getAllEntries
in interface IProject
public TMXEntry getTranslationInfo(SourceTextEntry ste)
IProject
getTranslationInfo
in interface IProject
ste
- source entrypublic IProject.AllTranslations getAllTranslations(SourceTextEntry ste)
IProject
getAllTranslations
in interface IProject
public ProjectProperties getProjectProperties()
getProjectProperties
in interface IProject
public boolean isProjectModified()
isProjectModified
in interface IProject
public void setTranslation(SourceTextEntry entry, PrepareTMXEntry trans, boolean defaultTranslation, TMXEntry.ExternalLinked externalLinked, IProject.AllTranslations previous) throws IProject.OptimisticLockingFail
IProject
setTranslation
in interface IProject
entry
- entrytrans
- translation. It can't be nullIProject.OptimisticLockingFail
public void setTranslation(SourceTextEntry entry, PrepareTMXEntry trans, boolean defaultTranslation, TMXEntry.ExternalLinked externalLinked)
IProject
setTranslation
in interface IProject
entry
- entrytrans
- translation. It can't be nullpublic void setNote(SourceTextEntry entry, TMXEntry oldTE, java.lang.String note)
IProject
public void iterateByDefaultTranslations(IProject.DefaultTranslationsIterator it)
IProject
iterateByDefaultTranslations
in interface IProject
public void iterateByMultipleTranslations(IProject.MultipleTranslationsIterator it)
IProject
iterateByMultipleTranslations
in interface IProject
public boolean isOrphaned(java.lang.String source)
IProject
isOrphaned
in interface IProject
public boolean isOrphaned(EntryKey entry)
IProject
isOrphaned
in interface IProject
public java.util.Map<java.lang.String,ExternalTMX> getTransMemories()
IProject
getTransMemories
in interface IProject
public java.util.Map<Language,ProjectTMX> getOtherTargetLanguageTMs()
IProject
getOtherTargetLanguageTMs
in interface IProject
public ITokenizer getSourceTokenizer()
getSourceTokenizer
in interface IProject
public ITokenizer getTargetTokenizer()
getTargetTokenizer
in interface IProject
protected ITokenizer createTokenizer(java.lang.String cmdLine, java.lang.Class<?> projectPref)
--ITokenizer
and --ITokenizerTarget
DefaultTokenizer
cmdLine
- Tokenizer class specified on command linepublic java.util.List<IProject.FileInfo> getProjectFiles()
getProjectFiles
in interface IProject
public java.lang.String getTargetPathForSourceFile(java.lang.String currentSource)
IProject
The target path must be calculated because it can depend on project properties such as the target language, etc.
getTargetPathForSourceFile
in interface IProject
currentSource
- The relative path (under the source
directory) of the
source file, e.g. Bundle.properties
target
directory) of the corresponding
target file, e.g. Bundle_fr_FR.properties
public java.util.List<java.lang.String> getSourceFilesOrder()
IProject
getSourceFilesOrder
in interface IProject
public void setSourceFilesOrder(java.util.List<java.lang.String> filesList)
IProject
setSourceFilesOrder
in interface IProject
protected java.lang.String patchFileNameForEntryKey(java.lang.String filename)
Also it can use --alternate-filename-from
and --alternate-filename-to
command line
parameters for change filename in entry key. It allows to have many versions of one file in one
project.
Because the filename can be stored in the project TMX, it also removes any XML-unsafe chars.
filename
- filesystem's filenamepublic boolean isRemoteProject()
IProject
isRemoteProject
in interface IProject
public void commitSourceFiles() throws java.lang.Exception
IProject
commitSourceFiles
in interface IProject
java.lang.Exception