Search in sources :

Example 1 with NotLoadedProject

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

the class TestCore method setUpCore.

@Before
public final void setUpCore() throws Exception {
    configDir = Files.createTempDirectory("omegat").toFile();
    TestPreferencesInitializer.init(configDir.getAbsolutePath());
    final IMainMenu mainMenu = new IMainMenu() {

        public JMenu getToolsMenu() {
            return new JMenu();
        }

        public JMenu getProjectMenu() {
            return new JMenu();
        }

        public JMenu getOptionsMenu() {
            return new JMenu();
        }

        public JMenu getMachineTranslationMenu() {
            return new JMenu();
        }

        public JMenu getGlossaryMenu() {
            return new JMenu();
        }

        public JMenu getAutoCompletionMenu() {
            return new JMenu();
        }

        public void invokeAction(String action, int modifiers) {
        }
    };
    Core.setMainWindow(new IMainWindow() {

        public void addDockable(Dockable pane) {
        }

        public void displayErrorRB(Throwable ex, String errorKey, Object... params) {
        }

        public Font getApplicationFont() {
            return new Font("Dialog", Font.PLAIN, 12);
        }

        public JFrame getApplicationFrame() {
            return new JFrame();
        }

        public void lockUI() {
        }

        public void showLengthMessage(String messageText) {
        }

        public void showProgressMessage(String messageText) {
        }

        public void showStatusMessageRB(String messageKey, Object... params) {
        }

        public void showTimedStatusMessageRB(String messageKey, Object... params) {
        }

        public void displayWarningRB(String warningKey, Object... params) {
        }

        public void displayWarningRB(String warningKey, String supercedesKey, Object... params) {
        }

        public void showErrorDialogRB(String title, String message, Object... args) {
        }

        public void unlockUI() {
        }

        public IMainMenu getMainMenu() {
            return mainMenu;
        }

        public Cursor getCursor() {
            return null;
        }

        public void setCursor(Cursor cursor) {
        }

        public int showConfirmDialog(Object message, String title, int optionType, int messageType) throws HeadlessException {
            return 0;
        }

        public void showMessageDialog(String message) {
        }

        public void showLockInsertMessage(String messageText, String toolTip) {
        }
    });
    Core.setCurrentProject(new NotLoadedProject());
    final IEditorSettings editorSettings = new IEditorSettings() {

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

        @Override
        public void setUseTabForAdvance(boolean useTabForAdvance) {
        }

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

        @Override
        public void setMarkTranslated(boolean markTranslated) {
        }

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

        @Override
        public void setMarkUntranslated(boolean markUntranslated) {
        }

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

        @Override
        public void setMarkAutoPopulated(boolean markAutoPopulated) {
        }

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

        @Override
        public void setDisplaySegmentSources(boolean displaySegmentSources) {
        }

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

        @Override
        public void setMarkNonUniqueSegments(boolean markNonUniqueSegments) {
        }

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

        @Override
        public void setMarkNotedSegments(boolean markNotedSegments) {
        }

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

        @Override
        public void setMarkNBSP(boolean markNBSP) {
        }

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

        @Override
        public void setMarkWhitespace(boolean markWhitespace) {
        }

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

        @Override
        public void setMarkBidi(boolean markBidi) {
        }

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

        @Override
        public void setAutoSpellChecking(boolean isNeedToSpell) {
        }

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

        @Override
        public void setDoFontFallback(boolean doFallback) {
        }

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

        @Override
        public void setDisplayModificationInfo(String displayModificationInfo) {
        }

        @Override
        public void updateTagValidationPreferences() {
        }

        @Override
        public void updateViewPreferences() {
        }

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

        @Override
        public void setMarkLanguageChecker(boolean markLanguageChecker) {
        }

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

        @Override
        public void setMarkGlossaryMatches(boolean markGlossaryMatches) {
        }

        @Override
        public void setMarkParagraphDelimitations(boolean mark) {
        }

        @Override
        public boolean isMarkParagraphDelimitations() {
            return false;
        }
    };
    TestCoreInitializer.initEditor(new IEditor() {

        @Override
        public void windowDeactivated() {
        }

        @Override
        public void undo() {
        }

        @Override
        public void setFilter(IEditorFilter filter) {
        }

        @Override
        public void setAlternateTranslationForCurrentEntry(boolean alternate) {
        }

        @Override
        public void requestFocus() {
        }

        @Override
        public void replaceEditTextAndMark(String text) {
        }

        @Override
        public void replaceEditText(String text) {
        }

        @Override
        public void removeFilter() {
        }

        @Override
        public void remarkOneMarker(String markerClassName) {
        }

        @Override
        public void registerUntranslated() {
        }

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

        @Override
        public void registerIdenticalTranslation() {
        }

        @Override
        public void registerEmptyTranslation() {
        }

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

        @Override
        public void refreshView(boolean doCommit) {
        }

        @Override
        public void redo() {
        }

        @Override
        public void prevEntryWithNote() {
        }

        @Override
        public void prevEntry() {
        }

        @Override
        public void nextUntranslatedEntry() {
        }

        @Override
        public void nextUniqueEntry() {
        }

        @Override
        public void nextTranslatedEntry() {
        }

        @Override
        public void nextEntryWithNote() {
        }

        @Override
        public void nextEntry() {
        }

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

        @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 void gotoFile(int fileIndex) {
        }

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

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

        @Override
        public void gotoEntry(int entryNum) {
        }

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

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

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

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

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

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

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

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

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

        @Override
        public IAutoCompleter getAutoCompleter() {
            return null;
        }

        @Override
        public void commitAndLeave() {
        }

        @Override
        public void commitAndDeactivate() {
        }

        @Override
        public void changeCase(CHANGE_CASE_TO newCase) {
        }

        @Override
        public void activateEntry() {
        }
    });
}
Also used : IEditor(org.omegat.gui.editor.IEditor) HeadlessException(java.awt.HeadlessException) IMainWindow(org.omegat.gui.main.IMainWindow) Dockable(com.vlsolutions.swing.docking.Dockable) Mark(org.omegat.gui.editor.mark.Mark) Cursor(java.awt.Cursor) Font(java.awt.Font) JFrame(javax.swing.JFrame) SourceTextEntry(org.omegat.core.data.SourceTextEntry) IAutoCompleter(org.omegat.gui.editor.autocompleter.IAutoCompleter) IEditorFilter(org.omegat.gui.editor.IEditorFilter) EntryKey(org.omegat.core.data.EntryKey) IPopupMenuConstructor(org.omegat.gui.editor.IPopupMenuConstructor) IEditorSettings(org.omegat.gui.editor.IEditorSettings) NotLoadedProject(org.omegat.core.data.NotLoadedProject) IMainMenu(org.omegat.gui.main.IMainMenu) JMenu(javax.swing.JMenu) Before(org.junit.Before)

Example 2 with NotLoadedProject

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

the class Core method initializeConsole.

/**
 * Initialize application components.
 */
public static void initializeConsole(final Map<String, String> params) throws Exception {
    cmdLineParams = params;
    tagValidation = new TagValidationTool();
    currentProject = new NotLoadedProject();
    mainWindow = new ConsoleWindow();
}
Also used : ConsoleWindow(org.omegat.gui.main.ConsoleWindow) NotLoadedProject(org.omegat.core.data.NotLoadedProject) TagValidationTool(org.omegat.core.tagvalidation.TagValidationTool)

Example 3 with NotLoadedProject

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

the class Main method selectProjectConsoleMode.

/**
 * creates the project class and adds it to the Core. Loads the project if
 * specified. An exit occurs on error loading the project. This method is
 * for the different console modes, to prevent code duplication.
 *
 * @param loadProject
 *            load the project or not
 * @return the project.
 */
private static RealProject selectProjectConsoleMode(boolean loadProject) {
    System.out.println(OStrings.getString("CONSOLE_LOADING_PROJECT"));
    // check if project okay
    ProjectProperties projectProperties = null;
    try {
        projectProperties = ProjectFileStorage.loadProjectProperties(projectLocation);
        projectProperties.verifyProject();
    } catch (Exception ex) {
        Log.logErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE");
        System.out.println(OStrings.getString("PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"));
        System.exit(1);
    }
    RealProject p = new RealProject(projectProperties);
    Core.setProject(p);
    if (loadProject) {
        p.loadProject(true);
        if (!p.isProjectLoaded()) {
            Core.setProject(new NotLoadedProject());
        } else {
            executeConsoleScript(IProjectEventListener.PROJECT_CHANGE_TYPE.LOAD);
        }
    }
    return p;
}
Also used : NotLoadedProject(org.omegat.core.data.NotLoadedProject) ProjectProperties(org.omegat.core.data.ProjectProperties) RealProject(org.omegat.core.data.RealProject) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 4 with NotLoadedProject

use of org.omegat.core.data.NotLoadedProject 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 5 with NotLoadedProject

use of org.omegat.core.data.NotLoadedProject 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)

Aggregations

NotLoadedProject (org.omegat.core.data.NotLoadedProject)7 ProjectProperties (org.omegat.core.data.ProjectProperties)3 TagValidationTool (org.omegat.core.tagvalidation.TagValidationTool)3 IMainWindow (org.omegat.gui.main.IMainWindow)3 Before (org.junit.Before)2 EntryKey (org.omegat.core.data.EntryKey)2 SourceTextEntry (org.omegat.core.data.SourceTextEntry)2 Segmenter (org.omegat.core.segmentation.Segmenter)2 ISpellChecker (org.omegat.core.spellchecker.ISpellChecker)2 SpellChecker (org.omegat.core.spellchecker.SpellChecker)2 SaveThread (org.omegat.core.threads.SaveThread)2 FilterMaster (org.omegat.filters2.master.FilterMaster)2 CommentsTextArea (org.omegat.gui.comments.CommentsTextArea)2 DictionariesTextArea (org.omegat.gui.dictionaries.DictionariesTextArea)2 EditorController (org.omegat.gui.editor.EditorController)2 IEditor (org.omegat.gui.editor.IEditor)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 ProtectedPartsMarker (org.omegat.gui.editor.mark.ProtectedPartsMarker)2