Search in sources :

Example 1 with IApplicationEventListener

use of org.omegat.core.events.IApplicationEventListener in project omegat by omegat-org.

the class ScriptsMonitor method hookApplicationEvent.

private void hookApplicationEvent() {
    if (m_applicationEventListener != null) {
        CoreEvents.unregisterApplicationEventListener(m_applicationEventListener);
    }
    // APPLICATION_STARTUP is not working because it is registered too late.
    // addEventScripts(EventType.APPLICATION_STARTUP);
    addEventScripts(EventType.APPLICATION_SHUTDOWN);
    m_applicationEventListener = new IApplicationEventListener() {

        @Override
        public void onApplicationStartup() {
        // for (ScriptItem si : m_eventsScript.get(EventType.APPLICATION_STARTUP)) {
        // m_scriptingWindow.executeScriptFile(si, true);
        // }
        }

        @Override
        public void onApplicationShutdown() {
            for (ScriptItem si : m_eventsScript.get(EventType.APPLICATION_SHUTDOWN)) {
                m_scriptingWindow.executeScriptFile(si);
            }
        }
    };
    CoreEvents.registerApplicationEventListener(m_applicationEventListener);
}
Also used : IApplicationEventListener(org.omegat.core.events.IApplicationEventListener)

Example 2 with IApplicationEventListener

use of org.omegat.core.events.IApplicationEventListener in project omegat by omegat-org.

the class LanguageToolWrapper method init.

public static void init() {
    Core.registerMarker(new LanguageToolMarker());
    IssueProviders.addIssueProvider(new LanguageToolIssueProvider());
    CoreEvents.registerProjectChangeListener(e -> {
        switch(e) {
            case CREATE:
            case LOAD:
                setBridgeFromCurrentProject();
                break;
            case CLOSE:
                bridge.stop();
                bridge = null;
                break;
            default:
        }
    });
    CoreEvents.registerApplicationEventListener(new IApplicationEventListener() {

        @Override
        public void onApplicationShutdown() {
            if (bridge != null) {
                bridge.stop();
            }
        }

        @Override
        public void onApplicationStartup() {
        }
    });
}
Also used : IApplicationEventListener(org.omegat.core.events.IApplicationEventListener)

Example 3 with IApplicationEventListener

use of org.omegat.core.events.IApplicationEventListener in project omegat by omegat-org.

the class TaaSPlugin method loadPlugins.

/**
 * Register plugin into OmegaT.
 */
public static void loadPlugins() {
    TaaSGlossary glossary;
    TaaSClient client = getClient();
    try {
        client.init();
        if (client.isAllowed()) {
            glossary = new TaaSGlossary();
            try (InputStream in = TaaSGlossary.class.getResourceAsStream("filter.xslt")) {
                if (in == null) {
                    throw new Exception("filter.xslt is unaccessible");
                }
                TransformerFactory factory = TransformerFactory.newInstance();
                Source xslt = new StreamSource(in);
                filterTransformer = factory.newTransformer(xslt);
            }
        } else {
            glossary = null;
        }
    } catch (Exception ex) {
        Log.log(ex);
        return;
    }
    CoreEvents.registerApplicationEventListener(new IApplicationEventListener() {

        public void onApplicationStartup() {
            JMenuItem lookup = new JCheckBoxMenuItem();
            lookup.setSelected(Preferences.isPreferenceDefault(Preferences.TAAS_LOOKUP, false));
            Mnemonics.setLocalizedText(lookup, OStrings.getString("TAAS_MENU_LOOKUP"));
            lookup.addActionListener(e -> {
                if (client.isAllowed()) {
                    Preferences.setPreference(Preferences.TAAS_LOOKUP, lookup.isSelected());
                    Preferences.save();
                } else {
                    lookup.setSelected(false);
                    new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), TaaSPreferencesController.class);
                }
            });
            Core.getMainWindow().getMainMenu().getGlossaryMenu().add(lookup);
            PreferencesControllers.addSupplier(TaaSPreferencesController::new);
            Preferences.addPropertyChangeListener(Preferences.TAAS_LOOKUP, e -> lookup.setSelected((Boolean) e.getNewValue()));
            if (client.isAllowed()) {
                Core.getGlossaryManager().addGlossaryProvider(glossary);
            }
        }

        public void onApplicationShutdown() {
        }
    });
}
Also used : OutputStream(java.io.OutputStream) Transformer(javax.xml.transform.Transformer) StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) StreamSource(javax.xml.transform.stream.StreamSource) PreferencesWindowController(org.omegat.gui.preferences.PreferencesWindowController) Log(org.omegat.util.Log) Mnemonics(org.openide.awt.Mnemonics) IApplicationEventListener(org.omegat.core.events.IApplicationEventListener) Source(javax.xml.transform.Source) CoreEvents(org.omegat.core.CoreEvents) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) PreferencesControllers(org.omegat.gui.preferences.PreferencesControllers) StringReader(java.io.StringReader) JMenuItem(javax.swing.JMenuItem) Core(org.omegat.core.Core) OStrings(org.omegat.util.OStrings) TransformerFactory(javax.xml.transform.TransformerFactory) Preferences(org.omegat.util.Preferences) InputStream(java.io.InputStream) TransformerFactory(javax.xml.transform.TransformerFactory) IApplicationEventListener(org.omegat.core.events.IApplicationEventListener) InputStream(java.io.InputStream) StreamSource(javax.xml.transform.stream.StreamSource) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) PreferencesWindowController(org.omegat.gui.preferences.PreferencesWindowController) JMenuItem(javax.swing.JMenuItem)

Example 4 with IApplicationEventListener

use of org.omegat.core.events.IApplicationEventListener in project omegat by omegat-org.

the class MainWindowMenu method initComponents.

/**
 * Initialize menu items.
 */
@SuppressWarnings("serial")
JMenuBar initComponents() {
    mainMenu = new JMenuBar();
    mainMenu.add(projectMenu = createMenu("TF_MENU_FILE"));
    mainMenu.add(editMenu = createMenu("TF_MENU_EDIT"));
    mainMenu.add(gotoMenu = createMenu("MW_GOTOMENU"));
    mainMenu.add(viewMenu = createMenu("MW_VIEW_MENU"));
    mainMenu.add(toolsMenu = createMenu("TF_MENU_TOOLS"));
    mainMenu.add(optionsMenu = createMenu("MW_OPTIONSMENU"));
    mainMenu.add(helpMenu = createMenu("TF_MENU_HELP"));
    projectMenu.add(projectNewMenuItem = createMenuItem("TF_MENU_FILE_CREATE"));
    projectMenu.add(projectTeamNewMenuItem = createMenuItem("TF_MENU_FILE_TEAM_CREATE"));
    projectMenu.add(projectOpenMenuItem = createMenuItem("TF_MENU_FILE_OPEN"));
    projectMenu.add(projectOpenRecentMenuItem = createMenu("TF_MENU_FILE_OPEN_RECENT"));
    projectMenu.add(projectImportMenuItem = createMenuItem("TF_MENU_FILE_IMPORT"));
    projectMenu.add(projectWikiImportMenuItem = createMenuItem("TF_MENU_WIKI_IMPORT"));
    projectMenu.add(projectReloadMenuItem = createMenuItem("TF_MENU_PROJECT_RELOAD"));
    projectMenu.add(projectCloseMenuItem = createMenuItem("TF_MENU_FILE_CLOSE"));
    projectMenu.addSeparator();
    projectMenu.add(projectSaveMenuItem = createMenuItem("TF_MENU_FILE_SAVE"));
    projectMenu.addSeparator();
    projectMenu.add(projectCommitSourceFiles = createMenuItem("TF_MENU_FILE_COMMIT"));
    projectMenu.add(projectCommitTargetFiles = createMenuItem("TF_MENU_FILE_TARGET"));
    projectMenu.addSeparator();
    projectMenu.add(projectCompileMenuItem = createMenuItem("TF_MENU_FILE_COMPILE"));
    projectMenu.add(projectSingleCompileMenuItem = createMenuItem("TF_MENU_FILE_SINGLE_COMPILE"));
    projectMenu.addSeparator();
    projectMenu.add(projectMedOpenMenuItem = createMenuItem("TF_MENU_FILE_MED_OPEN"));
    projectMenu.add(projectMedCreateMenuItem = createMenuItem("TF_MENU_FILE_MED_CREATE"));
    projectMenu.addSeparator();
    projectMenu.add(projectEditMenuItem = createMenuItem("MW_PROJECTMENU_EDIT"));
    projectMenu.add(viewFileListMenuItem = createMenuItem("TF_MENU_FILE_PROJWIN"));
    projectMenu.add(projectAccessProjectFilesMenu = createMenu("TF_MENU_FILE_ACCESS_PROJECT_FILES"));
    projectAccessProjectFilesMenu.add(projectAccessRootMenuItem = createMenuItem("TF_MENU_FILE_ACCESS_ROOT"));
    projectAccessProjectFilesMenu.add(projectAccessDictionaryMenuItem = createMenuItem("TF_MENU_FILE_ACCESS_DICTIONARY"));
    projectAccessProjectFilesMenu.add(projectAccessGlossaryMenuItem = createMenuItem("TF_MENU_FILE_ACCESS_GLOSSARY"));
    projectAccessProjectFilesMenu.add(projectAccessSourceMenuItem = createMenuItem("TF_MENU_FILE_ACCESS_SOURCE"));
    projectAccessProjectFilesMenu.add(projectAccessTargetMenuItem = createMenuItem("TF_MENU_FILE_ACCESS_TARGET"));
    projectAccessProjectFilesMenu.add(projectAccessTMMenuItem = createMenuItem("TF_MENU_FILE_ACCESS_TM"));
    projectAccessProjectFilesMenu.addSeparator();
    projectAccessProjectFilesMenu.add(projectAccessCurrentSourceDocumentMenuItem = createMenuItem("TF_MENU_FILE_ACCESS_CURRENT_SOURCE_DOCUMENT"));
    projectAccessProjectFilesMenu.add(projectAccessCurrentTargetDocumentMenuItem = createMenuItem("TF_MENU_FILE_ACCESS_CURRENT_TARGET_DOCUMENT"));
    projectAccessProjectFilesMenu.add(projectAccessWriteableGlossaryMenuItem = createMenuItem("TF_MENU_FILE_ACCESS_WRITEABLE_GLOSSARY"));
    projectAccessProjectFilesMenu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(MenuEvent e) {
            if (Core.getProject().isProjectLoaded()) {
                String sourcePath = Core.getEditor().getCurrentFile();
                projectAccessCurrentSourceDocumentMenuItem.setEnabled(!StringUtil.isEmpty(sourcePath) && new File(Core.getProject().getProjectProperties().getSourceRoot(), sourcePath).isFile());
                String targetPath = Core.getEditor().getCurrentTargetFile();
                projectAccessCurrentTargetDocumentMenuItem.setEnabled(!StringUtil.isEmpty(targetPath) && new File(Core.getProject().getProjectProperties().getTargetRoot(), targetPath).isFile());
                String glossaryPath = Core.getProject().getProjectProperties().getWriteableGlossary();
                projectAccessWriteableGlossaryMenuItem.setEnabled(!StringUtil.isEmpty(glossaryPath) && new File(glossaryPath).isFile());
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    projectExitMenuItem = createMenuItem("TF_MENU_FILE_QUIT");
    // all except MacOSX
    if (!Platform.isMacOSX()) {
        projectMenu.addSeparator();
        projectMenu.add(projectExitMenuItem);
    }
    editMenu.add(editUndoMenuItem = createMenuItem("TF_MENU_EDIT_UNDO"));
    editMenu.add(editRedoMenuItem = createMenuItem("TF_MENU_EDIT_REDO"));
    editMenu.addSeparator();
    editMenu.add(editOverwriteTranslationMenuItem = createMenuItem("TF_MENU_EDIT_RECYCLE"));
    editMenu.add(editInsertTranslationMenuItem = createMenuItem("TF_MENU_EDIT_INSERT"));
    editMenu.addSeparator();
    editMenu.add(editOverwriteMachineTranslationMenuItem = createMenuItem("TF_MENU_EDIT_OVERWRITE_MACHITE_TRANSLATION"));
    editMenu.addSeparator();
    editMenu.add(editOverwriteSourceMenuItem = createMenuItem("TF_MENU_EDIT_SOURCE_OVERWRITE"));
    editMenu.add(editInsertSourceMenuItem = createMenuItem("TF_MENU_EDIT_SOURCE_INSERT"));
    editMenu.addSeparator();
    editMenu.add(editTagPainterMenuItem = createMenuItem("TF_MENU_EDIT_TAGPAINT"));
    editMenu.add(editTagNextMissedMenuItem = createMenuItem("TF_MENU_EDIT_TAG_NEXT_MISSED"));
    editMenu.addSeparator();
    editMenu.add(editExportSelectionMenuItem = createMenuItem("TF_MENU_EDIT_EXPORT_SELECTION"));
    editMenu.add(editCreateGlossaryEntryMenuItem = createMenuItem("TF_MENU_EDIT_CREATE_GLOSSARY_ENTRY"));
    editMenu.addSeparator();
    editMenu.add(editFindInProjectMenuItem = createMenuItem("TF_MENU_EDIT_FIND"));
    editMenu.add(editReplaceInProjectMenuItem = createMenuItem("TF_MENU_EDIT_REPLACE"));
    editMenu.addSeparator();
    editMenu.add(switchCaseSubMenu = createMenu("TF_EDIT_MENU_SWITCH_CASE"));
    editMenu.add(selectFuzzySubMenu = createMenu("TF_MENU_EDIT_COMPARE"));
    selectFuzzySubMenu.add(editSelectFuzzyPrevMenuItem = createMenuItem("TF_MENU_EDIT_COMPARE_PREV"));
    selectFuzzySubMenu.add(editSelectFuzzyNextMenuItem = createMenuItem("TF_MENU_EDIT_COMPARE_NEXT"));
    selectFuzzySubMenu.addSeparator();
    selectFuzzySubMenu.add(editSelectFuzzy1MenuItem = createMenuItem("TF_MENU_EDIT_COMPARE_1"));
    selectFuzzySubMenu.add(editSelectFuzzy2MenuItem = createMenuItem("TF_MENU_EDIT_COMPARE_2"));
    selectFuzzySubMenu.add(editSelectFuzzy3MenuItem = createMenuItem("TF_MENU_EDIT_COMPARE_3"));
    selectFuzzySubMenu.add(editSelectFuzzy4MenuItem = createMenuItem("TF_MENU_EDIT_COMPARE_4"));
    selectFuzzySubMenu.add(editSelectFuzzy5MenuItem = createMenuItem("TF_MENU_EDIT_COMPARE_5"));
    editMenu.add(insertCharsSubMenu = createMenu("TF_MENU_EDIT_INSERT_CHARS"));
    insertCharsSubMenu.add(insertCharsLRM = createMenuItem("TF_MENU_EDIT_INSERT_CHARS_LRM"));
    insertCharsSubMenu.add(insertCharsRLM = createMenuItem("TF_MENU_EDIT_INSERT_CHARS_RLM"));
    insertCharsSubMenu.addSeparator();
    insertCharsSubMenu.add(insertCharsLRE = createMenuItem("TF_MENU_EDIT_INSERT_CHARS_LRE"));
    insertCharsSubMenu.add(insertCharsRLE = createMenuItem("TF_MENU_EDIT_INSERT_CHARS_RLE"));
    insertCharsSubMenu.add(insertCharsPDF = createMenuItem("TF_MENU_EDIT_INSERT_CHARS_PDF"));
    editMenu.addSeparator();
    editMenu.add(editMultipleDefault = createMenuItem("MULT_MENU_DEFAULT"));
    editMenu.add(editMultipleAlternate = createMenuItem("MULT_MENU_MULTIPLE"));
    editMenu.addSeparator();
    editMenu.add(editRegisterUntranslatedMenuItem = createMenuItem("TF_MENU_EDIT_UNTRANSLATED_TRANSLATION"));
    editMenu.add(editRegisterEmptyMenuItem = createMenuItem("TF_MENU_EDIT_EMPTY_TRANSLATION"));
    editMenu.add(editRegisterIdenticalMenuItem = createMenuItem("TF_MENU_EDIT_IDENTICAL_TRANSLATION"));
    switchCaseSubMenu.add(lowerCaseMenuItem = createMenuItem("TF_EDIT_MENU_SWITCH_CASE_TO_LOWER"));
    switchCaseSubMenu.add(upperCaseMenuItem = createMenuItem("TF_EDIT_MENU_SWITCH_CASE_TO_UPPER"));
    switchCaseSubMenu.add(titleCaseMenuItem = createMenuItem("TF_EDIT_MENU_SWITCH_CASE_TO_TITLE"));
    switchCaseSubMenu.add(sentenceCaseMenuItem = createMenuItem("TF_EDIT_MENU_SWITCH_CASE_TO_SENTENCE"));
    switchCaseSubMenu.addSeparator();
    switchCaseSubMenu.add(cycleSwitchCaseMenuItem = createMenuItem("TF_EDIT_MENU_SWITCH_CASE_CYCLE"));
    gotoMenu.add(gotoNextUntranslatedMenuItem = createMenuItem("TF_MENU_EDIT_UNTRANS"));
    gotoMenu.add(gotoNextTranslatedMenuItem = createMenuItem("TF_MENU_EDIT_TRANS"));
    gotoMenu.add(gotoNextSegmentMenuItem = createMenuItem("TF_MENU_EDIT_NEXT"));
    gotoMenu.add(gotoPreviousSegmentMenuItem = createMenuItem("TF_MENU_EDIT_PREV"));
    gotoMenu.add(gotoSegmentMenuItem = createMenuItem("TF_MENU_EDIT_GOTO"));
    gotoMenu.add(gotoNextNoteMenuItem = createMenuItem("TF_MENU_EDIT_NEXT_NOTE"));
    gotoMenu.add(gotoPreviousNoteMenuItem = createMenuItem("TF_MENU_EDIT_PREV_NOTE"));
    gotoMenu.add(gotoNextUniqueMenuItem = createMenuItem("TF_MENU_GOTO_NEXT_UNIQUE"));
    gotoMenu.add(gotoMatchSourceSegment = createMenuItem("TF_MENU_GOTO_SELECTED_MATCH_SOURCE"));
    gotoMenu.addSeparator();
    gotoMenu.add(gotoHistoryForwardMenuItem = createMenuItem("TF_MENU_GOTO_FORWARD_IN_HISTORY"));
    gotoMenu.add(gotoHistoryBackMenuItem = createMenuItem("TF_MENU_GOTO_BACK_IN_HISTORY"));
    viewMenu.add(viewMarkTranslatedSegmentsCheckBoxMenuItem = createCheckboxMenuItem("TF_MENU_DISPLAY_MARK_TRANSLATED"));
    viewMenu.add(viewMarkUntranslatedSegmentsCheckBoxMenuItem = createCheckboxMenuItem("TF_MENU_DISPLAY_MARK_UNTRANSLATED"));
    viewMenu.add(viewDisplaySegmentSourceCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_MENU_DISPLAY_SEGMENT_SOURCES"));
    viewMenu.add(viewMarkNonUniqueSegmentsCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_MENU_MARK_NON_UNIQUE_SEGMENTS"));
    viewMenu.add(viewMarkNotedSegmentsCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_MENU_MARK_NOTED_SEGMENTS"));
    viewMenu.add(viewMarkNBSPCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_MENU_MARK_NBSP"));
    viewMenu.add(viewMarkWhitespaceCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_MENU_MARK_WHITESPACE"));
    viewMenu.add(viewMarkBidiCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_MENU_MARK_BIDI"));
    viewMenu.add(viewMarkAutoPopulatedCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_MENU_MARK_AUTOPOPULATED"));
    viewMenu.add(viewMarkGlossaryMatchesCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_GLOSSARY_MARK"));
    viewMenu.add(viewMarkLanguageCheckerCheckBoxMenuItem = createCheckboxMenuItem("LT_OPTIONS_MENU_ENABLED"));
    viewMenu.add(viewMarkFontFallbackCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_MENU_MARK_FONT_FALLBACK"));
    viewMenu.add(viewModificationInfoMenu = createMenu("MW_VIEW_MENU_MODIFICATION_INFO"));
    ButtonGroup viewModificationInfoMenuBG = new ButtonGroup();
    viewModificationInfoMenu.add(viewDisplayModificationInfoNoneRadioButtonMenuItem = createRadioButtonMenuItem("MW_VIEW_MENU_MODIFICATION_INFO_NONE", viewModificationInfoMenuBG));
    viewModificationInfoMenu.add(viewDisplayModificationInfoSelectedRadioButtonMenuItem = createRadioButtonMenuItem("MW_VIEW_MENU_MODIFICATION_INFO_SELECTED", viewModificationInfoMenuBG));
    viewModificationInfoMenu.add(viewDisplayModificationInfoAllRadioButtonMenuItem = createRadioButtonMenuItem("MW_VIEW_MENU_MODIFICATION_INFO_ALL", viewModificationInfoMenuBG));
    viewMarkTranslatedSegmentsCheckBoxMenuItem.setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_TRANSLATED.getColor()));
    viewMarkUntranslatedSegmentsCheckBoxMenuItem.setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_UNTRANSLATED.getColor()));
    viewDisplaySegmentSourceCheckBoxMenuItem.setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_SOURCE.getColor()));
    viewMarkNonUniqueSegmentsCheckBoxMenuItem.setIcon(MainMenuIcons.newTextIcon(Styles.EditorColor.COLOR_NON_UNIQUE.getColor(), 'M'));
    viewMarkNotedSegmentsCheckBoxMenuItem.setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_NOTED.getColor()));
    viewMarkNBSPCheckBoxMenuItem.setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_NBSP.getColor()));
    viewMarkWhitespaceCheckBoxMenuItem.setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_WHITESPACE.getColor()));
    viewMarkBidiCheckBoxMenuItem.setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_BIDIMARKERS.getColor()));
    viewModificationInfoMenu.setIcon(MainMenuIcons.newBlankIcon());
    viewMarkAutoPopulatedCheckBoxMenuItem.setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_MARK_COMES_FROM_TM_XAUTO.getColor()));
    viewMarkGlossaryMatchesCheckBoxMenuItem.setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_TRANSTIPS.getColor()));
    viewMarkLanguageCheckerCheckBoxMenuItem.setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_LANGUAGE_TOOLS.getColor()));
    viewMarkFontFallbackCheckBoxMenuItem.setIcon(MainMenuIcons.newTextIcon(UIManager.getColor("Label.foreground"), new Font("Serif", Font.ITALIC, 16), 'F'));
    viewMenu.addSeparator();
    viewMenu.add(viewRestoreGUIMenuItem = createMenuItem("MW_OPTIONSMENU_RESTORE_GUI"));
    toolsMenu.add(toolsCheckIssuesMenuItem = createMenuItem("TF_MENU_TOOLS_CHECK_ISSUES"));
    toolsMenu.add(toolsCheckIssuesCurrentFileMenuItem = createMenuItem("TF_MENU_TOOLS_CHECK_ISSUES_CURRENT_FILE"));
    toolsMenu.add(toolsShowStatisticsStandardMenuItem = createMenuItem("TF_MENU_TOOLS_STATISTICS_STANDARD"));
    toolsMenu.add(toolsShowStatisticsMatchesMenuItem = createMenuItem("TF_MENU_TOOLS_STATISTICS_MATCHES"));
    toolsMenu.add(toolsShowStatisticsMatchesPerFileMenuItem = createMenuItem("TF_MENU_TOOLS_STATISTICS_MATCHES_PER_FILE"));
    toolsMenu.addSeparator();
    toolsMenu.add(toolsAlignFilesMenuItem = createMenuItem("TF_MENU_TOOLS_ALIGN_FILES"));
    optionsPreferencesMenuItem = createMenuItem("MW_OPTIONSMENU_PREFERENCES");
    if (!Platform.isMacOSX()) {
        optionsMenu.add(optionsPreferencesMenuItem);
        optionsMenu.addSeparator();
    }
    optionsMenu.add(optionsMachineTranslateMenu = createMenu("TF_OPTIONSMENU_MACHINETRANSLATE"));
    optionsMachineTranslateMenu.add(optionsMTAutoFetchCheckboxMenuItem = createCheckboxMenuItem("MT_AUTO_FETCH"));
    optionsMachineTranslateMenu.addSeparator();
    optionsMenu.add(optionsGlossaryMenu = createMenu("TF_OPTIONSMENU_GLOSSARY"));
    optionsGlossaryMenu.addSeparator();
    // TaaS options come next (but are added from elsewhere)
    optionsMenu.add(optionsDictionaryMenu = createMenu("TF_OPTIONSMENU_DICTIONARY"));
    optionsDictionaryMenu.add(optionsDictionaryFuzzyMatchingCheckBoxMenuItem = createCheckboxMenuItem("TF_OPTIONSMENU_DICTIONARY_FUZZY"));
    optionsMenu.add(optionsAutoCompleteMenu = createMenu("MW_OPTIONSMENU_AUTOCOMPLETE"));
    // add any autocomplete view configuration menu items below
    optionsAutoCompleteMenu.add(optionsAutoCompleteShowAutomaticallyItem = createCheckboxMenuItem("MW_OPTIONSMENU_AUTOCOMPLETE_SHOW_AUTOMATICALLY"));
    optionsAutoCompleteMenu.add(optionsAutoCompleteHistoryCompletionMenuItem = createCheckboxMenuItem("MW_OPTIONSMENU_AUTOCOMPLETE_HISTORY_COMPLETION"));
    optionsAutoCompleteMenu.add(optionsAutoCompleteHistoryPredictionMenuItem = createCheckboxMenuItem("MW_OPTIONSMENU_AUTOCOMPLETE_HISTORY_PREDICTION"));
    optionsMenu.addSeparator();
    optionsMenu.add(optionsSetupFileFiltersMenuItem = createMenuItem("TF_MENU_DISPLAY_FILTERS"));
    optionsMenu.add(optionsSentsegMenuItem = createMenuItem("MW_OPTIONSMENU_SENTSEG"));
    optionsMenu.add(optionsWorkflowMenuItem = createMenuItem("MW_OPTIONSMENU_WORKFLOW"));
    optionsMenu.addSeparator();
    optionsMenu.add(optionsAccessConfigDirMenuItem = createMenuItem("MW_OPTIONSMENU_ACCESS_CONFIG_DIR"));
    optionsMenu.addSeparator();
    helpMenu.add(helpContentsMenuItem = createMenuItem("TF_MENU_HELP_CONTENTS"));
    helpMenu.add(helpAboutMenuItem = createMenuItem("TF_MENU_HELP_ABOUT"));
    helpMenu.add(helpLastChangesMenuItem = createMenuItem("TF_MENU_HELP_LAST_CHANGES"));
    helpMenu.add(helpLogMenuItem = createMenuItem("TF_MENU_HELP_LOG"));
    setActionCommands();
    PropertiesShortcuts.getMainMenuShortcuts().bindKeyStrokes(mainMenu);
    String key = "findInProjectReuseLastWindow";
    KeyStroke stroke = PropertiesShortcuts.getMainMenuShortcuts().getKeyStroke(key);
    mainWindow.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, key);
    mainWindow.getRootPane().getActionMap().put(key, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Log.logInfoRB("LOG_MENU_CLICK", key);
            mainWindowMenuHandler.findInProjectReuseLastWindow();
        }
    });
    if (Platform.isMacOSX()) {
        initMacSpecific();
    }
    CoreEvents.registerApplicationEventListener(new IApplicationEventListener() {

        public void onApplicationStartup() {
            updateCheckboxesOnStart();
            onProjectStatusChanged(false);
        }

        public void onApplicationShutdown() {
        }
    });
    CoreEvents.registerProjectChangeListener(e -> onProjectStatusChanged(Core.getProject().isProjectLoaded()));
    Preferences.addPropertyChangeListener(e -> {
        if (e.getNewValue() instanceof Boolean) {
            JMenuItem item = getItemForPreference(e.getPropertyName());
            if (item != null) {
                item.setSelected((Boolean) e.getNewValue());
            }
        }
    });
    return mainMenu;
}
Also used : IApplicationEventListener(org.omegat.core.events.IApplicationEventListener) MenuListener(javax.swing.event.MenuListener) ActionEvent(java.awt.event.ActionEvent) Font(java.awt.Font) ButtonGroup(javax.swing.ButtonGroup) KeyStroke(javax.swing.KeyStroke) JMenuItem(javax.swing.JMenuItem) File(java.io.File) AbstractAction(javax.swing.AbstractAction) JMenuBar(javax.swing.JMenuBar) MenuEvent(javax.swing.event.MenuEvent)

Aggregations

IApplicationEventListener (org.omegat.core.events.IApplicationEventListener)4 JMenuItem (javax.swing.JMenuItem)2 Font (java.awt.Font)1 ActionEvent (java.awt.event.ActionEvent)1 File (java.io.File)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 AbstractAction (javax.swing.AbstractAction)1 ButtonGroup (javax.swing.ButtonGroup)1 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)1 JMenuBar (javax.swing.JMenuBar)1 KeyStroke (javax.swing.KeyStroke)1 MenuEvent (javax.swing.event.MenuEvent)1 MenuListener (javax.swing.event.MenuListener)1 Source (javax.xml.transform.Source)1 Transformer (javax.xml.transform.Transformer)1 TransformerFactory (javax.xml.transform.TransformerFactory)1 StreamResult (javax.xml.transform.stream.StreamResult)1