Search in sources :

Example 1 with StatisticsInfo

use of org.omegat.core.statistics.StatisticsInfo in project omegat by omegat-org.

the class FalseFriendsTest method setUp.

@Before
public final void setUp() {
    final ProjectProperties props = new ProjectProperties() {

        public Language getSourceLanguage() {
            return new Language("en");
        }

        public Language getTargetLanguage() {
            return new Language("pl");
        }
    };
    Core.setProject(new IProject() {

        public void setTranslation(SourceTextEntry entry, PrepareTMXEntry trans, boolean defaultTranslation, TMXEntry.ExternalLinked externalLinked) {
        }

        public void setTranslation(SourceTextEntry entry, PrepareTMXEntry trans, boolean defaultTranslation, ExternalLinked externalLinked, AllTranslations previousTranslations) throws OptimisticLockingFail {
        }

        public void setNote(SourceTextEntry entry, TMXEntry oldTrans, String note) {
        }

        public void saveProjectProperties() throws Exception {
        }

        public void saveProject(boolean doTeamSync) {
        }

        public void iterateByMultipleTranslations(MultipleTranslationsIterator it) {
        }

        public void iterateByDefaultTranslations(DefaultTranslationsIterator it) {
        }

        public boolean isProjectModified() {
            return false;
        }

        public boolean isProjectLoaded() {
            return true;
        }

        public boolean isOrphaned(EntryKey entry) {
            return false;
        }

        public boolean isOrphaned(String source) {
            return false;
        }

        public TMXEntry getTranslationInfo(SourceTextEntry ste) {
            return null;
        }

        public AllTranslations getAllTranslations(SourceTextEntry ste) {
            return null;
        }

        public Map<String, ExternalTMX> getTransMemories() {
            return null;
        }

        public ITokenizer getTargetTokenizer() {
            return null;
        }

        public StatisticsInfo getStatistics() {
            return null;
        }

        public ITokenizer getSourceTokenizer() {
            return null;
        }

        public ProjectProperties getProjectProperties() {
            return props;
        }

        public List<FileInfo> getProjectFiles() {
            return null;
        }

        public Map<Language, ProjectTMX> getOtherTargetLanguageTMs() {
            return null;
        }

        public List<SourceTextEntry> getAllEntries() {
            return null;
        }

        public void compileProject(String sourcePattern) throws Exception {
        }

        public void closeProject() {
        }

        public List<String> getSourceFilesOrder() {
            return null;
        }

        public void setSourceFilesOrder(List<String> filesList) {
        }

        @Override
        public String getTargetPathForSourceFile(String sourceFile) {
            return null;
        }

        @Override
        public boolean isTeamSyncPrepared() {
            return false;
        }

        @Override
        public void teamSync() {
        }

        @Override
        public void teamSyncPrepare() throws Exception {
        }

        @Override
        public boolean isRemoteProject() {
            return false;
        }

        @Override
        public void commitSourceFiles() throws Exception {
        }

        @Override
        public void compileProjectAndCommit(String sourcePattern, boolean doPostProcessing, boolean commitTargetFiles) throws Exception {
        }
    });
    LanguageToolWrapper.setBridgeFromCurrentProject();
}
Also used : ExternalLinked(org.omegat.core.data.TMXEntry.ExternalLinked) EntryKey(org.omegat.core.data.EntryKey) StatisticsInfo(org.omegat.core.statistics.StatisticsInfo) ProjectProperties(org.omegat.core.data.ProjectProperties) IProject(org.omegat.core.data.IProject) ExternalLinked(org.omegat.core.data.TMXEntry.ExternalLinked) ITokenizer(org.omegat.tokenizer.ITokenizer) Language(org.omegat.util.Language) SourceTextEntry(org.omegat.core.data.SourceTextEntry) List(java.util.List) PrepareTMXEntry(org.omegat.core.data.PrepareTMXEntry) Map(java.util.Map) PrepareTMXEntry(org.omegat.core.data.PrepareTMXEntry) TMXEntry(org.omegat.core.data.TMXEntry) Before(org.junit.Before)

Example 2 with StatisticsInfo

use of org.omegat.core.statistics.StatisticsInfo in project omegat by omegat-org.

the class EditorController method showStat.

/**
 * Calculate statistic for file, request statistic for project and display in status bar.
 */
public void showStat() {
    IProject project = Core.getProject();
    IProject.FileInfo fi = project.getProjectFiles().get(displayedFileIndex);
    int translatedInFile = 0;
    int translatedUniqueInFile = 0;
    int uniqueInFile = 0;
    boolean isUnique;
    for (SourceTextEntry ste : fi.entries) {
        isUnique = ste.getDuplicate() != SourceTextEntry.DUPLICATE.NEXT;
        if (isUnique) {
            uniqueInFile++;
        }
        if (project.getTranslationInfo(ste).isTranslated()) {
            translatedInFile++;
            if (isUnique) {
                translatedUniqueInFile++;
            }
        }
    }
    StatisticsInfo stat = project.getStatistics();
    final MainWindowUI.StatusBarMode progressMode = Preferences.getPreferenceEnumDefault(Preferences.SB_PROGRESS_MODE, MainWindowUI.StatusBarMode.DEFAULT);
    if (progressMode == MainWindowUI.StatusBarMode.DEFAULT) {
        StringBuilder pMsg = new StringBuilder(1024).append(" ");
        pMsg.append(translatedInFile).append("/").append(fi.entries.size()).append(" (").append(stat.numberofTranslatedSegments).append("/").append(stat.numberOfUniqueSegments).append(", ").append(stat.numberOfSegmentsTotal).append(") ");
        mw.showProgressMessage(pMsg.toString());
    } else {
        /*
             * Percentage mode based on idea by Yu Tang
             * http://dirtysexyquery.blogspot.tw/2013/03/omegat-custom-progress-format.html
             */
        java.text.NumberFormat nfPer = java.text.NumberFormat.getPercentInstance();
        nfPer.setRoundingMode(java.math.RoundingMode.DOWN);
        nfPer.setMaximumFractionDigits(1);
        String message = StringUtil.format(OStrings.getString("MW_PROGRESS_DEFAULT_PERCENTAGE"), (translatedUniqueInFile == 0) ? "0%" : nfPer.format((double) translatedUniqueInFile / uniqueInFile), uniqueInFile - translatedUniqueInFile, (stat.numberofTranslatedSegments == 0) ? "0%" : nfPer.format((double) stat.numberofTranslatedSegments / stat.numberOfUniqueSegments), stat.numberOfUniqueSegments - stat.numberofTranslatedSegments, stat.numberOfSegmentsTotal);
        mw.showProgressMessage(message);
    }
}
Also used : MainWindowUI(org.omegat.gui.main.MainWindowUI) StatisticsInfo(org.omegat.core.statistics.StatisticsInfo) SourceTextEntry(org.omegat.core.data.SourceTextEntry) FileInfo(org.omegat.core.data.IProject.FileInfo) IProject(org.omegat.core.data.IProject) Point(java.awt.Point)

Aggregations

IProject (org.omegat.core.data.IProject)2 SourceTextEntry (org.omegat.core.data.SourceTextEntry)2 StatisticsInfo (org.omegat.core.statistics.StatisticsInfo)2 Point (java.awt.Point)1 List (java.util.List)1 Map (java.util.Map)1 Before (org.junit.Before)1 EntryKey (org.omegat.core.data.EntryKey)1 FileInfo (org.omegat.core.data.IProject.FileInfo)1 PrepareTMXEntry (org.omegat.core.data.PrepareTMXEntry)1 ProjectProperties (org.omegat.core.data.ProjectProperties)1 TMXEntry (org.omegat.core.data.TMXEntry)1 ExternalLinked (org.omegat.core.data.TMXEntry.ExternalLinked)1 MainWindowUI (org.omegat.gui.main.MainWindowUI)1 ITokenizer (org.omegat.tokenizer.ITokenizer)1 Language (org.omegat.util.Language)1