Class RealProject

  • All Implemented Interfaces:
    IProject

    public class RealProject
    extends java.lang.Object
    implements 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.
    • Method Detail

      • saveProjectProperties

        public void saveProjectProperties()
                                   throws java.lang.Exception
        Description copied from interface: IProject
        Save project properties only.
        Specified by:
        saveProjectProperties in interface IProject
        Throws:
        java.lang.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

        public java.util.Map<EntryKey,​ITMXEntry> align​(ProjectProperties props,
                                                             java.io.File translatedDir)
                                                      throws java.lang.Exception
        Align project.
        Throws:
        java.lang.Exception
      • isProjectLoaded

        public boolean isProjectLoaded()
        Get project loaded status.
        Specified by:
        isProjectLoaded in interface IProject
        Returns:
        true if project loaded
      • 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:
        closeProject in interface IProject
      • compileProject

        public void compileProject​(java.lang.String sourcePattern)
                            throws java.lang.Exception
        Builds translated files corresponding to sourcePattern and creates fresh TM files. Convenience method. Assumes we want to run external post-processing commands.
        Specified by:
        compileProject in interface IProject
        Parameters:
        sourcePattern - The regexp of files to create
        Throws:
        java.lang.Exception
      • compileProject

        public void compileProject​(java.lang.String sourcePattern,
                                   boolean doPostProcessing)
                            throws java.lang.Exception
        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 create
        doPostProcessing - Whether or not we should perform external post-processing.
        Throws:
        java.lang.Exception
      • compileProjectAndCommit

        public void compileProjectAndCommit​(java.lang.String sourcePattern,
                                            boolean doPostProcessing,
                                            boolean commitTargetFiles)
                                     throws java.lang.Exception
        Builds translated files corresponding to sourcePattern and creates fresh TM files.
        Specified by:
        compileProjectAndCommit in interface IProject
        Parameters:
        sourcePattern - The regexp of files to create
        doPostProcessing - Whether or not we should perform external post-processing.
        commitTargetFiles - Whether or not we should commit target files
        Throws:
        java.lang.Exception
      • saveProject

        public void saveProject​(boolean doTeamSync)
        Saves the translation memory and preferences. This method must be executed in the Core.executeExclusively.
        Specified by:
        saveProject in interface IProject
      • teamSyncPrepare

        public void teamSyncPrepare()
                             throws java.lang.Exception
        Prepare for future team sync. This method must be executed in the Core.executeExclusively.
        Specified by:
        teamSyncPrepare in interface IProject
        Throws:
        java.lang.Exception
      • isTeamSyncPrepared

        public boolean isTeamSyncPrepared()
        Description copied from interface: IProject
        Check if team synchronization prepared.
        Specified by:
        isTeamSyncPrepared in interface IProject
      • teamSync

        public void teamSync()
        Fast team sync for execute from SaveThread. This method must be executed in the Core.executeExclusively.
        Specified by:
        teamSync in interface IProject
      • getAllEntries

        public java.util.List<SourceTextEntry> getAllEntries()
        Get all source segments. It's unmodifiable list, so, there is no need synchronization to read it.
        Specified by:
        getAllEntries in interface IProject
      • getTranslationInfo

        public TMXEntry getTranslationInfo​(SourceTextEntry ste)
        Description copied from interface: IProject
        Get 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:
        getTranslationInfo in interface IProject
        Parameters:
        ste - source entry
        Returns:
        translation
      • isProjectModified

        public boolean isProjectModified()
        Returns whether the project was modified. I.e. translations were changed since last save.
        Specified by:
        isProjectModified in interface IProject
      • setNote

        public void setNote​(SourceTextEntry entry,
                            TMXEntry oldTE,
                            java.lang.String note)
        Description copied from interface: IProject
        Change note only for translation.
        Specified by:
        setNote in interface IProject
        Parameters:
        entry - entry
        oldTE - old translation
        note - note text
      • isOrphaned

        public boolean isOrphaned​(java.lang.String source)
        Description copied from interface: IProject
        Check if orphaned.
        Specified by:
        isOrphaned in interface IProject
      • isOrphaned

        public boolean isOrphaned​(EntryKey entry)
        Description copied from interface: IProject
        Check if orphaned.
        Specified by:
        isOrphaned in interface IProject
      • getTransMemories

        public java.util.Map<java.lang.String,​ExternalTMX> getTransMemories()
        Description copied from interface: IProject
        Get all translation memories from /tm/ folder.
        Specified by:
        getTransMemories in interface IProject
        Returns:
        translation memories
      • getOtherTargetLanguageTMs

        public java.util.Map<Language,​ProjectTMX> getOtherTargetLanguageTMs()
        Description copied from interface: IProject
        Get all translation memories from /other_lang/ folder.
        Specified by:
        getOtherTargetLanguageTMs in interface IProject
        Returns:
        translation memories
      • getProjectFiles

        public java.util.List<IProject.FileInfo> getProjectFiles()
        Get info about each source file in project. It's unmodifiable list, so, there is no need synchronization to read it.
        Specified by:
        getProjectFiles in interface IProject
      • getTargetPathForSourceFile

        public java.lang.String getTargetPathForSourceFile​(java.lang.String currentSource)
        Description copied from interface: IProject
        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).

        The target path must be calculated because it can depend on project properties such as the target language, etc.

        Specified by:
        getTargetPathForSourceFile in interface IProject
        Parameters:
        currentSource - The relative path (under the source directory) of the source file, e.g. Bundle.properties
        Returns:
        The relative path (under the target directory) of the corresponding target file, e.g. Bundle_fr_FR.properties
      • getSourceFilesOrder

        public java.util.List<java.lang.String> getSourceFilesOrder()
        Description copied from interface: IProject
        Get ordered list of source file names.
        Specified by:
        getSourceFilesOrder in interface IProject
      • setSourceFilesOrder

        public void setSourceFilesOrder​(java.util.List<java.lang.String> filesList)
        Description copied from interface: IProject
        Set ordered list of source file names.
        Specified by:
        setSourceFilesOrder in interface IProject
      • isRemoteProject

        public boolean isRemoteProject()
        Description copied from interface: IProject
        Tells whether a project is a team project
        Specified by:
        isRemoteProject in interface IProject
        Returns:
        whether the project is a team project
      • commitSourceFiles

        public void commitSourceFiles()
                               throws java.lang.Exception
        Description copied from interface: IProject
        Commit source files in a team project.
        Specified by:
        commitSourceFiles in interface IProject
        Throws:
        java.lang.Exception