Search in sources :

Example 16 with ProjectProperties

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

the class GlossaryAutoCompleterViewTest method setUp.

@Before
public final void setUp() {
    Core.setProject(new NotLoadedProject() {

        @Override
        public ITokenizer getTargetTokenizer() {
            return new DefaultTokenizer();
        }

        @Override
        public ProjectProperties getProjectProperties() {
            try {
                return new ProjectProperties() {

                    @Override
                    public Language getTargetLanguage() {
                        return new Language(Locale.ENGLISH);
                    }
                };
            } catch (Exception e) {
                return null;
            }
        }
    });
    TestCoreInitializer.initEditor(new IEditor() {

        @Override
        public String getCurrentFile() {
            return null;
        }

        @Override
        public String getCurrentTargetFile() {
            return null;
        }

        @Override
        public SourceTextEntry getCurrentEntry() {
            return null;
        }

        @Override
        public int getCurrentEntryNumber() {
            return 0;
        }

        @Override
        public void activateEntry() {
        }

        @Override
        public void commitAndDeactivate() {
        }

        @Override
        public void commitAndLeave() {
        }

        @Override
        public void nextEntry() {
        }

        @Override
        public void prevEntry() {
        }

        @Override
        public void nextEntryWithNote() {
        }

        @Override
        public void prevEntryWithNote() {
        }

        @Override
        public void nextUntranslatedEntry() {
        }

        @Override
        public void nextTranslatedEntry() {
        }

        @Override
        public void nextUniqueEntry() {
        }

        @Override
        public void gotoFile(int fileIndex) {
        }

        @Override
        public void gotoEntry(int entryNum) {
        }

        @Override
        public void gotoEntry(int entryNum, CaretPosition pos) {
        }

        @Override
        public void gotoEntry(String srcString, EntryKey key) {
        }

        @Override
        public void gotoEntryAfterFix(int fixedEntry, String fixedSource) {
        }

        @Override
        public void refreshViewAfterFix(List<Integer> fixedEntries) {
        }

        @Override
        public void refreshView(boolean doCommit) {
        }

        @Override
        public void requestFocus() {
        }

        @Override
        public void changeCase(CHANGE_CASE_TO newCase) {
        }

        @Override
        public void replaceEditText(String text) {
        }

        @Override
        public void replaceEditTextAndMark(String text) {
        }

        @Override
        public void insertText(String text) {
        }

        @Override
        public void insertTextAndMark(String text) {
        }

        @Override
        public void insertTag(String tag) {
        }

        @Override
        public void gotoHistoryForward() {
        }

        @Override
        public void gotoHistoryBack() {
        }

        @Override
        public IEditorSettings getSettings() {
            return null;
        }

        @Override
        public void undo() {
        }

        @Override
        public void redo() {
        }

        @Override
        public String getSelectedText() {
            return null;
        }

        @Override
        public void setAlternateTranslationForCurrentEntry(boolean alternate) {
        }

        @Override
        public void markActiveEntrySource(SourceTextEntry requiredActiveEntry, List<Mark> marks, String markerClassName) {
        }

        @Override
        public void registerPopupMenuConstructors(int priority, IPopupMenuConstructor constructor) {
        }

        @Override
        public void remarkOneMarker(String markerClassName) {
        }

        @Override
        public IEditorFilter getFilter() {
            return null;
        }

        @Override
        public void setFilter(IEditorFilter filter) {
        }

        @Override
        public void removeFilter() {
        }

        @Override
        public String getCurrentTranslation() {
            return null;
        }

        @Override
        public void windowDeactivated() {
        }

        @Override
        public void registerUntranslated() {
        }

        @Override
        public void registerEmptyTranslation() {
        }

        @Override
        public void registerIdenticalTranslation() {
        }

        @Override
        public IAutoCompleter getAutoCompleter() {
            return null;
        }
    });
    TestCoreInitializer.initGlossary(new IGlossaries() {

        @Override
        public List<GlossaryEntry> getDisplayedEntries() {
            return currentEntries;
        }

        @Override
        public void showCreateGlossaryEntryDialog(Frame parent) {
        }
    });
    currentEntries.clear();
}
Also used : IEditor(org.omegat.gui.editor.IEditor) Frame(java.awt.Frame) DefaultTokenizer(org.omegat.tokenizer.DefaultTokenizer) Mark(org.omegat.gui.editor.mark.Mark) ITokenizer(org.omegat.tokenizer.ITokenizer) Language(org.omegat.util.Language) SourceTextEntry(org.omegat.core.data.SourceTextEntry) ArrayList(java.util.ArrayList) List(java.util.List) IAutoCompleter(org.omegat.gui.editor.autocompleter.IAutoCompleter) EntryKey(org.omegat.core.data.EntryKey) IEditorFilter(org.omegat.gui.editor.IEditorFilter) IPopupMenuConstructor(org.omegat.gui.editor.IPopupMenuConstructor) IEditorSettings(org.omegat.gui.editor.IEditorSettings) ProjectProperties(org.omegat.core.data.ProjectProperties) NotLoadedProject(org.omegat.core.data.NotLoadedProject) Before(org.junit.Before)

Example 17 with ProjectProperties

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

the class GlossaryReaderTBXTest method testRead.

@Test
public void testRead() throws Exception {
    Core.setProject(new NotLoadedProject() {

        public ProjectProperties getProjectProperties() {
            try {
                return new ProjectProperties(new File("stub")) {

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

                    @Override
                    public Language getTargetLanguage() {
                        return new Language("hu");
                    }
                };
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    });
    List<GlossaryEntry> g = GlossaryReaderTBX.read(new File("test/data/glossaries/sampleTBXfile.tbx"), false);
    assertEquals(1, g.size());
    assertEquals("alpha smoothing factor", g.get(0).getSrcText());
    assertEquals("hu translation", g.get(0).getLocText());
}
Also used : Language(org.omegat.util.Language) NotLoadedProject(org.omegat.core.data.NotLoadedProject) ProjectProperties(org.omegat.core.data.ProjectProperties) File(java.io.File) Test(org.junit.Test)

Example 18 with ProjectProperties

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

the class ProjectFileStorageTest method testLoadDefaults.

@Test
public void testLoadDefaults() throws Exception {
    ProjectProperties props = ProjectFileStorage.loadPropertiesFile(tempDir, new File(PROJECT_DIR, "defaultdirs.project"));
    try {
        props.verifyProject();
        fail("Project props should fail verification when dirs don't exist yet");
    } catch (ProjectException ex) {
    }
    props.autocreateDirectories();
    props.verifyProject();
    assertTrue(props.getSourceRoot().endsWith("source/"));
    assertTrue(props.getTargetRoot().endsWith("target/"));
    assertTrue(props.getGlossaryRoot().endsWith("glossary/"));
    assertTrue(props.getWriteableGlossary().endsWith("glossary/glossary.txt"));
    assertTrue(props.getTMRoot().endsWith("tm/"));
    assertTrue(props.getDictRoot().endsWith("dictionary/"));
    assertEquals(tempDir.getName(), props.getProjectName());
    assertEquals(new Language("en-us"), props.getSourceLanguage());
    assertEquals(new Language("fr-fr"), props.getTargetLanguage());
    assertEquals(LuceneEnglishTokenizer.class, props.getSourceTokenizer());
    assertEquals(LuceneFrenchTokenizer.class, props.getTargetTokenizer());
    assertTrue(props.isSentenceSegmentingEnabled());
    assertTrue(props.isSupportDefaultTranslations());
    assertFalse(props.isRemoveTags());
    assertTrue(props.getExternalCommand().isEmpty());
    List<String> excludes = props.getSourceRootExcludes();
    assertEquals(6, excludes.size());
    assertEquals("**/.svn/**", excludes.get(0));
}
Also used : ProjectException(org.omegat.core.data.ProjectException) ProjectProperties(org.omegat.core.data.ProjectProperties) File(java.io.File) Test(org.junit.Test)

Example 19 with ProjectProperties

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

the class ProjectFileStorageTest method testLoadCustomGlossaryDir.

@Test
public void testLoadCustomGlossaryDir() throws Exception {
    ProjectProperties props = ProjectFileStorage.loadPropertiesFile(tempDir, new File(PROJECT_DIR, "customglossarydir.project"));
    props.autocreateDirectories();
    props.verifyProject();
    assertTrue(props.getWriteableGlossary().endsWith("foo/glossary.txt"));
}
Also used : ProjectProperties(org.omegat.core.data.ProjectProperties) File(java.io.File) Test(org.junit.Test)

Example 20 with ProjectProperties

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

the class ProjectFileStorageTest method testLoadCustomGlossaryDirAndFile.

@Test
public void testLoadCustomGlossaryDirAndFile() throws Exception {
    ProjectProperties props = ProjectFileStorage.loadPropertiesFile(tempDir, new File(PROJECT_DIR, "customglossarydirfile.project"));
    props.autocreateDirectories();
    props.verifyProject();
    assertTrue(props.getWriteableGlossary().endsWith("foo/bar.txt"));
}
Also used : ProjectProperties(org.omegat.core.data.ProjectProperties) File(java.io.File) Test(org.junit.Test)

Aggregations

ProjectProperties (org.omegat.core.data.ProjectProperties)29 File (java.io.File)20 Test (org.junit.Test)11 IOException (java.io.IOException)10 ExecutionException (java.util.concurrent.ExecutionException)6 KnownException (org.omegat.core.KnownException)6 Omegat (gen.core.project.Omegat)4 Cursor (java.awt.Cursor)4 List (java.util.List)4 Language (org.omegat.util.Language)4 ArrayList (java.util.ArrayList)3 NotLoadedProject (org.omegat.core.data.NotLoadedProject)3 ProjectPropertiesDialog (org.omegat.gui.dialogs.ProjectPropertiesDialog)3 RepositoryDefinition (gen.core.project.RepositoryDefinition)2 RepositoryMapping (gen.core.project.RepositoryMapping)2 InputStream (java.io.InputStream)2 Properties (java.util.Properties)2 ZipEntry (java.util.zip.ZipEntry)2 ZipFile (java.util.zip.ZipFile)2 Before (org.junit.Before)2