Search in sources :

Example 6 with FilterMaster

use of org.omegat.filters2.master.FilterMaster in project omegat by omegat-org.

the class Searcher method searchFiles.

private void searchFiles() throws IOException {
    Path root = Paths.get(searchExpression.rootDir);
    FilterMaster fm = Core.getFilterMaster();
    final SearchCallback searchCallback = new SearchCallback(m_project.getProjectProperties());
    int depth = searchExpression.recursive ? Integer.MAX_VALUE : 0;
    Files.walk(root, depth, FileVisitOption.FOLLOW_LINKS).forEach(path -> {
        String filename = path.toString();
        FileInfo fi = new FileInfo();
        // determine actual file name w/ no root path info
        fi.filePath = root.relativize(path).toString();
        searchCallback.setCurrentFile(fi);
        try {
            fm.loadFile(filename, new FilterContext(m_project.getProjectProperties()), searchCallback);
        } catch (TranslationException | IOException ex) {
            Log.log(ex);
        }
        searchCallback.fileFinished();
        checkStop.checkInterrupted();
    });
}
Also used : Path(java.nio.file.Path) FileInfo(org.omegat.core.data.IProject.FileInfo) FilterMaster(org.omegat.filters2.master.FilterMaster) TranslationException(org.omegat.filters2.TranslationException) IOException(java.io.IOException) FilterContext(org.omegat.filters2.FilterContext)

Example 7 with FilterMaster

use of org.omegat.filters2.master.FilterMaster in project omegat by omegat-org.

the class AlignFilePickerController method getSupportedFiles.

private static List<File> getSupportedFiles(List<?> files) {
    List<File> result = new ArrayList<File>(files.size());
    FilterMaster fm = Core.getFilterMaster();
    for (Object o : files) {
        File file = (File) o;
        if (fm.isFileSupported(file, true)) {
            result.add(file);
        }
    }
    return result;
}
Also used : FilterMaster(org.omegat.filters2.master.FilterMaster) ArrayList(java.util.ArrayList) File(java.io.File)

Example 8 with FilterMaster

use of org.omegat.filters2.master.FilterMaster in project omegat by omegat-org.

the class Core method initializeGUI.

/**
 * Initialize application components.
 */
public static void initializeGUI(final Map<String, String> params) throws Exception {
    cmdLineParams = params;
    // 1. Initialize project
    currentProject = new NotLoadedProject();
    // 2. Initialize application frame
    MainWindow me = new MainWindow();
    mainWindow = me;
    // Load recent used projects
    RecentProjects.updateMenu();
    Core.registerMarker(new ProtectedPartsMarker());
    Core.registerMarker(new RemoveTagMarker());
    Core.registerMarker(new NBSPMarker());
    Core.registerMarker(new TransTipsMarker());
    Core.registerMarker(new WhitespaceMarkerFactory.SpaceMarker());
    Core.registerMarker(new WhitespaceMarkerFactory.TabMarker());
    Core.registerMarker(new WhitespaceMarkerFactory.LFMarker());
    Core.registerMarker(new BidiMarkerFactory.RLMMarker());
    Core.registerMarker(new BidiMarkerFactory.LRMMarker());
    Core.registerMarker(new BidiMarkerFactory.PDFMarker());
    Core.registerMarker(new BidiMarkerFactory.LROMarker());
    Core.registerMarker(new BidiMarkerFactory.RLOMarker());
    Core.registerMarker(new ReplaceMarker());
    Core.registerMarker(new ComesFromAutoTMMarker());
    Core.registerMarker(new FontFallbackMarker());
    LanguageToolWrapper.init();
    segmenter = new Segmenter(Preferences.getSRX());
    filterMaster = new FilterMaster(Preferences.getFilters());
    // 3. Initialize other components. They add themselves to the main window.
    editor = new EditorController(me);
    tagValidation = new TagValidationTool();
    issuesWindow = new IssuesPanelController(me);
    matcher = new MatchesTextArea(me);
    GlossaryTextArea glossaryArea = new GlossaryTextArea(me);
    glossary = glossaryArea;
    glossaryManager = new GlossaryManager(glossaryArea);
    notes = new NotesTextArea(me);
    comments = new CommentsTextArea(me);
    machineTranslatePane = new MachineTranslateTextArea(me);
    dictionaries = new DictionariesTextArea(me);
    spellChecker = new SpellChecker();
    multiple = new MultipleTransPane(me);
    new SegmentPropertiesArea(me);
    SaveThread th = new SaveThread();
    saveThread = th;
    th.start();
}
Also used : NBSPMarker(org.omegat.gui.editor.mark.NBSPMarker) MachineTranslateTextArea(org.omegat.gui.exttrans.MachineTranslateTextArea) EditorController(org.omegat.gui.editor.EditorController) MultipleTransPane(org.omegat.gui.multtrans.MultipleTransPane) DictionariesTextArea(org.omegat.gui.dictionaries.DictionariesTextArea) WhitespaceMarkerFactory(org.omegat.gui.editor.mark.WhitespaceMarkerFactory) GlossaryManager(org.omegat.gui.glossary.GlossaryManager) ReplaceMarker(org.omegat.gui.editor.mark.ReplaceMarker) NotesTextArea(org.omegat.gui.notes.NotesTextArea) IMainWindow(org.omegat.gui.main.IMainWindow) MainWindow(org.omegat.gui.main.MainWindow) IssuesPanelController(org.omegat.gui.issues.IssuesPanelController) BidiMarkerFactory(org.omegat.gui.editor.mark.BidiMarkerFactory) ProtectedPartsMarker(org.omegat.gui.editor.mark.ProtectedPartsMarker) FontFallbackMarker(org.omegat.gui.editor.mark.FontFallbackMarker) SaveThread(org.omegat.core.threads.SaveThread) RemoveTagMarker(org.omegat.gui.editor.mark.RemoveTagMarker) CommentsTextArea(org.omegat.gui.comments.CommentsTextArea) ComesFromAutoTMMarker(org.omegat.gui.editor.mark.ComesFromAutoTMMarker) Segmenter(org.omegat.core.segmentation.Segmenter) TagValidationTool(org.omegat.core.tagvalidation.TagValidationTool) MatchesTextArea(org.omegat.gui.matches.MatchesTextArea) GlossaryTextArea(org.omegat.gui.glossary.GlossaryTextArea) NotLoadedProject(org.omegat.core.data.NotLoadedProject) FilterMaster(org.omegat.filters2.master.FilterMaster) ISpellChecker(org.omegat.core.spellchecker.ISpellChecker) SpellChecker(org.omegat.core.spellchecker.SpellChecker) SegmentPropertiesArea(org.omegat.gui.properties.SegmentPropertiesArea) TransTipsMarker(org.omegat.gui.glossary.TransTipsMarker)

Example 9 with FilterMaster

use of org.omegat.filters2.master.FilterMaster in project omegat by omegat-org.

the class ExternalTMFactoryTest method setUp.

@Before
public final void setUp() {
    Core.setSegmenter(new Segmenter(SRX.getDefault()));
    FilterMaster.setFilterClasses(Arrays.asList(PoFilter.class, MozillaLangFilter.class));
    Core.setFilterMaster(new FilterMaster(FilterMaster.createDefaultFiltersConfig()));
    ProjectProperties props = new ProjectProperties() {

        public Language getSourceLanguage() {
            return sourceLang;
        }

        public Language getTargetLanguage() {
            return targetLang;
        }

        @Override
        public boolean isSentenceSegmentingEnabled() {
            return true;
        }
    };
    Core.setProject(new NotLoadedProject() {

        @Override
        public ProjectProperties getProjectProperties() {
            return props;
        }
    });
}
Also used : FilterMaster(org.omegat.filters2.master.FilterMaster) PoFilter(org.omegat.filters2.po.PoFilter) MozillaLangFilter(org.omegat.filters2.mozlang.MozillaLangFilter) Segmenter(org.omegat.core.segmentation.Segmenter) Before(org.junit.Before)

Example 10 with FilterMaster

use of org.omegat.filters2.master.FilterMaster in project omegat by omegat-org.

the class TmxComplianceBase method setUp.

@Before
public final void setUp() throws Exception {
    Core.setFilterMaster(new FilterMaster(FilterMaster.createDefaultFiltersConfig()));
    Core.setSegmenter(new Segmenter(SRX.getDefault()));
    TestPreferencesInitializer.init();
    outFile = new File("build/testdata/" + getClass().getSimpleName() + "-" + name.getMethodName() + ".out");
    outFile.getParentFile().mkdirs();
    if (outFile.exists()) {
        if (!outFile.delete()) {
            throw new IOException("Can't remove " + outFile.getAbsolutePath());
        }
    }
}
Also used : FilterMaster(org.omegat.filters2.master.FilterMaster) Segmenter(org.omegat.core.segmentation.Segmenter) IOException(java.io.IOException) File(java.io.File) Before(org.junit.Before)

Aggregations

FilterMaster (org.omegat.filters2.master.FilterMaster)16 File (java.io.File)9 Segmenter (org.omegat.core.segmentation.Segmenter)7 IOException (java.io.IOException)4 Before (org.junit.Before)4 FilterContext (org.omegat.filters2.FilterContext)4 RandomAccessFile (java.io.RandomAccessFile)3 Filters (gen.core.filters.Filters)2 CancellationException (java.util.concurrent.CancellationException)2 NotLoadedProject (org.omegat.core.data.NotLoadedProject)2 ISpellChecker (org.omegat.core.spellchecker.ISpellChecker)2 SpellChecker (org.omegat.core.spellchecker.SpellChecker)2 TagValidationTool (org.omegat.core.tagvalidation.TagValidationTool)2 SaveThread (org.omegat.core.threads.SaveThread)2 CommentsTextArea (org.omegat.gui.comments.CommentsTextArea)2 DictionariesTextArea (org.omegat.gui.dictionaries.DictionariesTextArea)2 EditorController (org.omegat.gui.editor.EditorController)2 ComesFromAutoTMMarker (org.omegat.gui.editor.mark.ComesFromAutoTMMarker)2 FontFallbackMarker (org.omegat.gui.editor.mark.FontFallbackMarker)2 NBSPMarker (org.omegat.gui.editor.mark.NBSPMarker)2