Search in sources :

Example 1 with IProject

use of org.omegat.core.data.IProject in project omegat by omegat-org.

the class SegmentPropertiesArea method setProperties.

private void setProperties(SourceTextEntry ste) {
    properties.clear();
    if (ste != null) {
        for (String s : ste.getRawProperties()) {
            properties.add(s);
        }
        if (ste.getDuplicate() != DUPLICATE.NONE) {
            setProperty(KEY_ISDUP, ste.getDuplicate());
        }
        if (ste.getSourceTranslation() != null) {
            setProperty(KEY_TRANSLATION, ste.getSourceTranslation());
            if (ste.isSourceTranslationFuzzy()) {
                setProperty(KEY_TRANSLATIONISFUZZY, true);
            }
        }
        setKeyProperties(ste.getKey());
        IProject project = Core.getProject();
        if (project.isProjectLoaded()) {
            TMXEntry trg = project.getTranslationInfo(ste);
            setTranslationProperties(trg);
        }
    }
    viewImpl.update();
}
Also used : IProject(org.omegat.core.data.IProject) TMXEntry(org.omegat.core.data.TMXEntry)

Example 2 with IProject

use of org.omegat.core.data.IProject in project omegat by omegat-org.

the class Searcher method searchProject.

private void searchProject() {
    // reset the number of search hits
    m_numFinds = 0;
    // search the Memory, if requested
    if (m_searchExpression.memory) {
        // search through all project entries
        IProject dataEngine = m_project;
        for (int i = 0; i < m_project.getAllEntries().size(); i++) {
            // stop searching if the max. nr of hits has been reached
            if (m_numFinds >= expression.numberOfResults) {
                return;
            }
            // get the source and translation of the next entry
            SourceTextEntry ste = dataEngine.getAllEntries().get(i);
            TMXEntry te = m_project.getTranslationInfo(ste);
            checkEntry(ste.getSrcText(), te.translation, te.note, ste.getComment(), te, i, null);
            checkStop.checkInterrupted();
        }
        // search in orphaned
        if (!m_searchExpression.excludeOrphans) {
            m_project.iterateByDefaultTranslations(new IProject.DefaultTranslationsIterator() {

                final String file = OStrings.getString("CT_ORPHAN_STRINGS");

                public void iterate(String source, TMXEntry en) {
                    // stop searching if the max. nr of hits has been reached
                    if (m_numFinds >= expression.numberOfResults) {
                        return;
                    }
                    checkStop.checkInterrupted();
                    if (m_project.isOrphaned(source)) {
                        checkEntry(en.source, en.translation, en.note, null, en, ENTRY_ORIGIN_ORPHAN, file);
                    }
                }
            });
            m_project.iterateByMultipleTranslations(new IProject.MultipleTranslationsIterator() {

                final String file = OStrings.getString("CT_ORPHAN_STRINGS");

                public void iterate(EntryKey source, TMXEntry en) {
                    // reached
                    if (m_numFinds >= expression.numberOfResults) {
                        return;
                    }
                    checkStop.checkInterrupted();
                    if (m_project.isOrphaned(source)) {
                        checkEntry(en.source, en.translation, en.note, null, en, ENTRY_ORIGIN_ORPHAN, file);
                    }
                }
            });
        }
    }
    // search the TM, if requested
    if (m_searchExpression.tm) {
        // that case.
        if (!expression.searchAuthor && !expression.searchDateAfter && !expression.searchDateBefore) {
            for (Map.Entry<String, ExternalTMX> tmEn : m_project.getTransMemories().entrySet()) {
                final String fileTM = tmEn.getKey();
                if (!searchEntries(tmEn.getValue().getEntries(), fileTM)) {
                    return;
                }
                checkStop.checkInterrupted();
            }
            for (Map.Entry<Language, ProjectTMX> tmEn : m_project.getOtherTargetLanguageTMs().entrySet()) {
                final Language langTM = tmEn.getKey();
                if (!searchEntriesAlternative(tmEn.getValue().getDefaults(), langTM.getLanguage())) {
                    return;
                }
                if (!searchEntriesAlternative(tmEn.getValue().getAlternatives(), langTM.getLanguage())) {
                    return;
                }
                checkStop.checkInterrupted();
            }
        }
    }
    // search the glossary, if requested
    if (m_searchExpression.glossary) {
        String intro = OStrings.getString("SW_GLOSSARY_RESULT");
        List<GlossaryEntry> entries = Core.getGlossaryManager().getLocalEntries();
        for (GlossaryEntry en : entries) {
            checkEntry(en.getSrcText(), en.getLocText(), null, null, null, ENTRY_ORIGIN_GLOSSARY, intro);
            // stop searching if the max. nr of hits has been reached
            if (m_numFinds >= expression.numberOfResults) {
                return;
            }
            checkStop.checkInterrupted();
        }
    }
}
Also used : ProjectTMX(org.omegat.core.data.ProjectTMX) EntryKey(org.omegat.core.data.EntryKey) IProject(org.omegat.core.data.IProject) Language(org.omegat.util.Language) GlossaryEntry(org.omegat.gui.glossary.GlossaryEntry) SourceTextEntry(org.omegat.core.data.SourceTextEntry) ExternalTMX(org.omegat.core.data.ExternalTMX) HashMap(java.util.HashMap) Map(java.util.Map) PrepareTMXEntry(org.omegat.core.data.PrepareTMXEntry) TMXEntry(org.omegat.core.data.TMXEntry)

Example 3 with IProject

use of org.omegat.core.data.IProject in project omegat by omegat-org.

the class CalcStandardStatistics method run.

@Override
public void run() {
    IProject p = Core.getProject();
    String result = buildProjectStats(p, null, callback);
    callback.setTextData(result);
    callback.finishData();
    String internalDir = p.getProjectProperties().getProjectInternal();
    // removing old stats
    try {
        File oldstats = new File(internalDir + "word_counts");
        if (oldstats.exists()) {
            oldstats.delete();
        }
    } catch (Exception e) {
    }
    // now dump file based word counts to disk
    String fn = internalDir + OConsts.STATS_FILENAME;
    Statistics.writeStat(fn, result);
    callback.setDataFile(fn);
}
Also used : File(java.io.File) IProject(org.omegat.core.data.IProject)

Example 4 with IProject

use of org.omegat.core.data.IProject in project omegat by omegat-org.

the class ExternalFinder method setProjectConfig.

/**
 * Set the project-specific configuration. Has no effect if no project is
 * loaded. Any existing configuration file will be overwritten with the new
 * one. Pass null to delete the config file.
 */
public static void setProjectConfig(ExternalFinderConfiguration newConfig) {
    IProject currentProject = Core.getProject();
    if (!currentProject.isProjectLoaded()) {
        return;
    }
    ExternalFinderConfiguration oldConfig = projectConfig;
    projectConfig = newConfig;
    if (!Objects.equals(newConfig, oldConfig)) {
        File projectFile = getProjectFile(currentProject);
        writeConfig(newConfig, projectFile);
    }
}
Also used : ExternalFinderConfiguration(org.omegat.externalfinder.item.ExternalFinderConfiguration) File(java.io.File) IProject(org.omegat.core.data.IProject)

Example 5 with IProject

use of org.omegat.core.data.IProject in project omegat by omegat-org.

the class EditorController method gotoEntry.

public void gotoEntry(final int entryNum, final CaretPosition pos) {
    UIThreadsUtil.mustBeSwingThread();
    if (!Core.getProject().isProjectLoaded()) {
        return;
    }
    if (m_docSegList == null) {
        // document didn't loaded yet
        return;
    }
    Cursor hourglassCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
    Cursor oldCursor = editor.getCursor();
    editor.setCursor(hourglassCursor);
    commitAndDeactivate();
    if (entryNum == 0) {
        // it was empty project, need to display first entry
        displayedFileIndex = 0;
        displayedEntryIndex = 0;
        loadDocument();
    } else {
        IProject dataEngine = Core.getProject();
        for (int i = 0; i < dataEngine.getProjectFiles().size(); i++) {
            IProject.FileInfo fi = dataEngine.getProjectFiles().get(i);
            SourceTextEntry firstEntry = fi.entries.get(0);
            SourceTextEntry lastEntry = fi.entries.get(fi.entries.size() - 1);
            if (firstEntry.entryNum() <= entryNum && lastEntry.entryNum() >= entryNum) {
                // this file
                if (i != displayedFileIndex) {
                    // it's other file than displayed
                    displayedFileIndex = i;
                    loadDocument();
                }
                // find correct displayedEntryIndex
                for (int j = 0; j < m_docSegList.length; j++) {
                    if (m_docSegList[j].segmentNumberInProject >= entryNum) {
                        // 
                        displayedEntryIndex = j;
                        break;
                    }
                }
                break;
            }
        }
    }
    activateEntry(pos);
    editor.setCursor(oldCursor);
}
Also used : SourceTextEntry(org.omegat.core.data.SourceTextEntry) FileInfo(org.omegat.core.data.IProject.FileInfo) Cursor(java.awt.Cursor) IProject(org.omegat.core.data.IProject) Point(java.awt.Point)

Aggregations

IProject (org.omegat.core.data.IProject)15 SourceTextEntry (org.omegat.core.data.SourceTextEntry)5 Point (java.awt.Point)4 File (java.io.File)4 FileInfo (org.omegat.core.data.IProject.FileInfo)3 TMXEntry (org.omegat.core.data.TMXEntry)3 Map (java.util.Map)2 EntryKey (org.omegat.core.data.EntryKey)2 PrepareTMXEntry (org.omegat.core.data.PrepareTMXEntry)2 StatisticsInfo (org.omegat.core.statistics.StatisticsInfo)2 Language (org.omegat.util.Language)2 Cursor (java.awt.Cursor)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 TimeoutException (java.util.concurrent.TimeoutException)1 Before (org.junit.Before)1 KnownException (org.omegat.core.KnownException)1