From 70bc29b7fa9cdda732a98f6cc60e598ec5154542 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Fri, 3 May 2024 15:42:51 +0900 Subject: [PATCH] chore: introduce acceptance test - Use AssertJ-Swing for test framework - Add Sample project folder - Test Menu - help - about dialog for sample Signed-off-by: Hiroshi Miura --- build.gradle | 33 ++ gradle/libs.versions.toml | 2 + .../omegat/gui/accesstool/AccessTools.java | 7 +- src/org/omegat/gui/dialogs/AboutDialog.java | 18 + .../omegat/gui/main/BaseMainWindowMenu.java | 18 +- .../gui/main/BaseMainWindowMenuHandler.java | 77 ++++ .../omegat/gui/main/MainWindowBurgerMenu.java | 2 +- .../gui/main/MainWindowMenuHandler.java | 2 +- test-acceptance/data/project/.gitignore | 3 + test-acceptance/data/project/dictionary/.keep | 0 .../data/project/glossary/glossary.txt | 2 + test-acceptance/data/project/omegat.project | 33 ++ .../data/project/omegat/ignored_words.txt | 0 .../data/project/omegat/learned_words.txt | 0 .../data/project/omegat/project_save.tmx | 17 + .../data/project/source/Bundle.properties | 36 ++ test-acceptance/data/project/target/.keep | 0 test-acceptance/data/project/tm/.keep | 0 .../src/org/omegat/TestMainInitializer.java | 20 + .../omegat/gui/dialogs/AboutDialogTest.java | 60 +++ .../org/omegat/gui/main/DockingDefaults.xml | 59 +++ .../src/org/omegat/gui/main/TestCoreGUI.java | 115 +++++ .../org/omegat/gui/main/TestMainWindow.java | 292 +++++++++++++ .../gui/main/TestMainWindowMenuHandler.java | 393 ++++++++++++++++++ 24 files changed, 1177 insertions(+), 12 deletions(-) create mode 100644 src/org/omegat/gui/main/BaseMainWindowMenuHandler.java create mode 100644 test-acceptance/data/project/.gitignore create mode 100644 test-acceptance/data/project/dictionary/.keep create mode 100644 test-acceptance/data/project/glossary/glossary.txt create mode 100644 test-acceptance/data/project/omegat.project create mode 100644 test-acceptance/data/project/omegat/ignored_words.txt create mode 100644 test-acceptance/data/project/omegat/learned_words.txt create mode 100644 test-acceptance/data/project/omegat/project_save.tmx create mode 100644 test-acceptance/data/project/source/Bundle.properties create mode 100644 test-acceptance/data/project/target/.keep create mode 100644 test-acceptance/data/project/tm/.keep create mode 100644 test-acceptance/src/org/omegat/TestMainInitializer.java create mode 100644 test-acceptance/src/org/omegat/gui/dialogs/AboutDialogTest.java create mode 100644 test-acceptance/src/org/omegat/gui/main/DockingDefaults.xml create mode 100644 test-acceptance/src/org/omegat/gui/main/TestCoreGUI.java create mode 100644 test-acceptance/src/org/omegat/gui/main/TestMainWindow.java create mode 100644 test-acceptance/src/org/omegat/gui/main/TestMainWindowMenuHandler.java diff --git a/build.gradle b/build.gradle index a70b5b6e23..e49bebaf3d 100644 --- a/build.gradle +++ b/build.gradle @@ -193,6 +193,13 @@ sourceSets { srcDir 'test/fixtures' } } + testAcceptance { + java { + compileClasspath += main.output + test.output + runtimeClasspath += main.output + test.output + srcDir 'test-acceptance/src' + } + } testIntegration { java { srcDir 'test-integration/src' @@ -204,6 +211,8 @@ configurations { all [testRuntime, testCompile]*.exclude group: 'org.languagetool', module: 'language-all' testIntegrationImplementation.extendsFrom implementation + testAcceptanceImplementation.extendsFrom testImplementation + testAcceptanceRuntime.extendsFrom testRuntime jaxb genMac } @@ -332,6 +341,7 @@ dependencies { testFixturesApi(libs.slf4j.api) testFixturesImplementation(libs.commons.io) testFixturesImplementation(libs.omegat.vldocking) + testFixturesImplementation(libs.assertj.swing.junit) testImplementation(libs.xmlunit.legacy) // LanguageTool unit tests exercise these languages @@ -352,6 +362,14 @@ dependencies { // genMac only genMac(libs.omegat.appbundler) + testAcceptanceImplementation sourceSets.main.output + testAcceptanceImplementation(libs.commons.io) + testAcceptanceImplementation(libs.slf4j.jdk14) + testAcceptanceImplementation(libs.slf4j.format.jdk14) + testAcceptanceImplementation(testFixtures(project.rootProject)) + testAcceptanceImplementation(libs.assertj.swing.junit) + testAcceptanceImplementation(libs.bundles.jackson) + testIntegrationImplementation sourceSets.main.output, sourceSets.test.output testIntegrationImplementation(testFixtures(project.rootProject)) testIntegrationRuntimeOnly(libs.slf4j.jdk14) @@ -1580,6 +1598,21 @@ tasks.register('testOnJava21', Test) { group = 'verification' } +tasks.register('testAcceptance', Test) { + description = 'Run Acceptance GUI test' + group = 'verification' + javaLauncher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(17) + vendor = JvmVendorSpec.ADOPTIUM + } + jvmArgs(["--add-opens", "java.desktop/sun.awt.X11=ALL-UNNAMED", + "--add-opens", "java.base/java.util=ALL-UNNAMED"]) + testClassesDirs = sourceSets.testAcceptance.output.classesDirs + classpath = sourceSets.testAcceptance.runtimeClasspath + systemProperties = System.properties + shouldRunAfter(tasks.test) +} + ext.mavenStyleVersion = version.replace('_', '-') publishing { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c995c787c8..17e1fde4ee 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -49,6 +49,7 @@ jna = "5.13.0" jfa = "1.2.0" tipoftheday = "0.4.4" flatlaf="3.4.1" +assertj_swing_junit = "4.0.0-beta-1" [libraries] slf4j-api = {group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j"} @@ -132,6 +133,7 @@ jna = {group = "net.java.dev.jna", name = "jna-platform", version.ref = "jna"} jfa = {group = "de.jangassen", name = "jfa", version.ref = "jfa"} flatlaf = {group = "com.formdev", name = "flatlaf", version.ref = "flatlaf"} language-detector = {group = "org.omegat", name = "language-detector", version.ref = "languagedetector"} +assertj_swing_junit = {group = "tokyo.northside", name = "assertj-swing-junit", version.ref = "assertj_swing_junit"} [bundles] groovy = ["groovy-jsr223", "groovy-dateutil", "groovy-json", "groovy-xml", "groovy-swing", "groovy-templates", "ivy"] diff --git a/src/org/omegat/gui/accesstool/AccessTools.java b/src/org/omegat/gui/accesstool/AccessTools.java index d1705a4aba..3598235974 100644 --- a/src/org/omegat/gui/accesstool/AccessTools.java +++ b/src/org/omegat/gui/accesstool/AccessTools.java @@ -49,9 +49,8 @@ import org.omegat.core.Core; import org.omegat.core.CoreEvents; import org.omegat.core.events.IProjectEventListener; +import org.omegat.gui.main.BaseMainWindowMenuHandler; import org.omegat.gui.main.MainMenuIcons; -import org.omegat.gui.main.MainWindow; -import org.omegat.gui.main.MainWindowMenuHandler; import org.omegat.gui.main.ProjectUICommands; import org.omegat.util.OConsts; import org.omegat.util.OStrings; @@ -72,14 +71,14 @@ public class AccessTools extends JPanel { private ProjectComboBoxModel projectComboBoxModel; private SourceComboBoxModel sourceComboBoxModel; - private final MainWindowMenuHandler mainWindowMenuHandler; + private final BaseMainWindowMenuHandler mainWindowMenuHandler; private URI selectedProject = null; private static final int MAX_PATH_LENGTH_SHOWN = 25; private static final float CHECKBOX_HEIGHT_RATIO = 1.8f; - public AccessTools(final MainWindow mainWindow, final MainWindowMenuHandler mainWindowMenuHandler) { + public AccessTools(final BaseMainWindowMenuHandler mainWindowMenuHandler) { this.mainWindowMenuHandler = mainWindowMenuHandler; initComponents(); } diff --git a/src/org/omegat/gui/dialogs/AboutDialog.java b/src/org/omegat/gui/dialogs/AboutDialog.java index c67ab4d5e2..0bafb9e2b4 100644 --- a/src/org/omegat/gui/dialogs/AboutDialog.java +++ b/src/org/omegat/gui/dialogs/AboutDialog.java @@ -59,6 +59,15 @@ public class AboutDialog extends JDialog { /** A return status code - returned if OK button has been pressed */ public static final int RET_OK = 1; + public static final String DIALOG_NAME = "about_dialog"; + public static final String OK_BUTTON_NAME = "about_dialog_ok_button"; + public static final String ABOUT_TEXT_NAME = "about_dialog_about_text"; + public static final String VERSION_LABEL_NAME = "about_dialog_version_label"; + public static final String MEMORY_USAGE_LABEL_NAME = "about_dialog_memory_usage_label"; + public static final String JAVA_VERSION_LABEL_NAME = "about_dialog_java_version_label"; + public static final String LICENSE_BUTTON_NAME = "about_dialog_license_button"; + public static final String COPY_SUPPORT_INFO_BUTTON = "about_dialog_copy_support_info_button"; + /** Creates new form AboutDialog */ public AboutDialog(Frame parent) { super(parent, true); @@ -67,6 +76,15 @@ public AboutDialog(Frame parent) { initComponents(); + setName(DIALOG_NAME); + licenseButton.setName(LICENSE_BUTTON_NAME); + okButton.setName(OK_BUTTON_NAME); + abouttext.setName(ABOUT_TEXT_NAME); + versionLabel.setName(VERSION_LABEL_NAME); + memoryusage.setName(MEMORY_USAGE_LABEL_NAME); + javaversion.setName(JAVA_VERSION_LABEL_NAME); + copySupportInfoButton.setName(COPY_SUPPORT_INFO_BUTTON); + StaticUIUtils.setCaretUpdateEnabled(abouttext, false); abouttext.setText(StringUtil.format(OStrings.getString("ABOUTDIALOG_CONTRIBUTORS"), getContributors(), getLibraries())); diff --git a/src/org/omegat/gui/main/BaseMainWindowMenu.java b/src/org/omegat/gui/main/BaseMainWindowMenu.java index 74fef3d850..822ce5a203 100644 --- a/src/org/omegat/gui/main/BaseMainWindowMenu.java +++ b/src/org/omegat/gui/main/BaseMainWindowMenu.java @@ -110,19 +110,22 @@ public abstract class BaseMainWindowMenu implements ActionListener, MenuListener private static final Logger LOGGER = Logger.getLogger(BaseMainWindowMenu.class.getName()); + public static final String HELP_MENU = "help_menu"; + public static final String HELP_ABOUT_MENUITEM = "help_about_menuitem"; + /** MainWindow instance. */ - protected final MainWindow mainWindow; + protected final IMainWindow mainWindow; /** menu bar instance */ protected final JMenuBar mainMenu = new JMenuBar(); /** MainWindow menu handler instance. */ - protected final MainWindowMenuHandler mainWindowMenuHandler; + protected final BaseMainWindowMenuHandler mainWindowMenuHandler; private final Map menus = new EnumMap<>(MenuExtender.MenuKey.class); - public BaseMainWindowMenu(final MainWindow mainWindow, - final MainWindowMenuHandler mainWindowMenuHandler) { + public BaseMainWindowMenu(final IMainWindow mainWindow, + final BaseMainWindowMenuHandler mainWindowMenuHandler) { this.mainWindow = mainWindow; this.mainWindowMenuHandler = mainWindowMenuHandler; } @@ -204,6 +207,7 @@ protected void createComponents() { toolsMenu = createMenu("TF_MENU_TOOLS", MenuExtender.MenuKey.TOOLS); optionsMenu = createMenu("MW_OPTIONSMENU", MenuExtender.MenuKey.OPTIONS); helpMenu = createMenu("TF_MENU_HELP", MenuExtender.MenuKey.HELP); + helpMenu.setName(HELP_MENU); projectNewMenuItem = createMenuItem("TF_MENU_FILE_CREATE"); projectTeamNewMenuItem = createMenuItem("TF_MENU_FILE_TEAM_CREATE"); @@ -410,6 +414,7 @@ protected void createComponents() { helpContentsMenuItem = createMenuItem("TF_MENU_HELP_CONTENTS"); helpAboutMenuItem = createMenuItem("TF_MENU_HELP_ABOUT"); + helpAboutMenuItem.setName(HELP_ABOUT_MENUITEM); helpLastChangesMenuItem = createMenuItem("TF_MENU_HELP_LAST_CHANGES"); helpLogMenuItem = createMenuItem("TF_MENU_HELP_LOG"); helpUpdateCheckMenuItem = createMenuItem("TF_MENU_HELP_CHECK_FOR_UPDATES"); @@ -653,8 +658,9 @@ public void menuCanceled(MenuEvent e) { 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() { + mainWindow.getApplicationFrame().getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, + key); + mainWindow.getApplicationFrame().getRootPane().getActionMap().put(key, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { Log.logInfoRB("LOG_MENU_CLICK", key); diff --git a/src/org/omegat/gui/main/BaseMainWindowMenuHandler.java b/src/org/omegat/gui/main/BaseMainWindowMenuHandler.java new file mode 100644 index 0000000000..305d2f1410 --- /dev/null +++ b/src/org/omegat/gui/main/BaseMainWindowMenuHandler.java @@ -0,0 +1,77 @@ +/************************************************************************** + OmegaT - Computer Assisted Translation (CAT) tool + with fuzzy matching, translation memory, keyword search, + glossaries, and translation leveraging into updated projects. + + Copyright (C) 2000-2006 Keith Godfrey, Maxym Mykhalchuk, Henry Pijffers, + Benjamin Siband, and Kim Bruning + 2007 Zoltan Bartko + 2008 Andrzej Sawula, Alex Buloichik + 2009 Didier Briel, Alex Buloichik + 2010 Wildrich Fourie, Didier Briel + 2012 Wildrich Fourie, Guido Leenders, Didier Briel + 2013 Zoltan Bartko, Didier Briel, Yu Tang + 2014 Aaron Madlon-Kay + 2015 Yu Tang, Aaron Madlon-Kay, Didier Briel + 2017 Didier Briel + 2019 Thomas Cordonnier + Home page: https://www.omegat.org/ + Support center: https://omegat.org/support + + This file is part of OmegaT. + + OmegaT is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OmegaT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + **************************************************************************/ +package org.omegat.gui.main; + +/** + * @author Hiroshi Miura + */ +public abstract class BaseMainWindowMenuHandler { + + /** + * Common base class for menu handler. + *

+ * There should be a mandatory methods for mandatory + * commands. + */ + public BaseMainWindowMenuHandler() { + } + + public void projectExitMenuItemActionPerformed() { + System.exit(0); + } + + public void editFindInProjectMenuItemActionPerformed() { + } + + public void optionsPreferencesMenuItemActionPerformed() { + } + + public void projectNewMenuItemActionPerformed() { + } + + public void projectOpenMenuItemActionPerformed() { + } + + public void projectTeamNewMenuItemActionPerformed() { + } + + void findInProjectReuseLastWindow() { + } + + public void helpAboutMenuItemActionPerformed() { + } + +} diff --git a/src/org/omegat/gui/main/MainWindowBurgerMenu.java b/src/org/omegat/gui/main/MainWindowBurgerMenu.java index 689f2e950e..e0a7b3c750 100644 --- a/src/org/omegat/gui/main/MainWindowBurgerMenu.java +++ b/src/org/omegat/gui/main/MainWindowBurgerMenu.java @@ -69,6 +69,6 @@ void createMenuBar() { burgerMenu.add(helpMenu); burgerMenu.add(burgerMenu); mainMenu.add(burgerMenu); - mainMenu.add(new AccessTools(mainWindow, mainWindowMenuHandler)); + mainMenu.add(new AccessTools(mainWindowMenuHandler)); } } diff --git a/src/org/omegat/gui/main/MainWindowMenuHandler.java b/src/org/omegat/gui/main/MainWindowMenuHandler.java index dea8af13a8..ac132146d6 100644 --- a/src/org/omegat/gui/main/MainWindowMenuHandler.java +++ b/src/org/omegat/gui/main/MainWindowMenuHandler.java @@ -106,7 +106,7 @@ * @author Yu Tang * @author Aaron Madlon-Kay */ -public final class MainWindowMenuHandler { +public final class MainWindowMenuHandler extends BaseMainWindowMenuHandler { private static final String PROP_ORIGIN = ProjectTMX.PROP_ORIGIN; private final MainWindow mainWindow; diff --git a/test-acceptance/data/project/.gitignore b/test-acceptance/data/project/.gitignore new file mode 100644 index 0000000000..2f3bf92e42 --- /dev/null +++ b/test-acceptance/data/project/.gitignore @@ -0,0 +1,3 @@ +project_stats.txt +project_stats.json +*.bak diff --git a/test-acceptance/data/project/dictionary/.keep b/test-acceptance/data/project/dictionary/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test-acceptance/data/project/glossary/glossary.txt b/test-acceptance/data/project/glossary/glossary.txt new file mode 100644 index 0000000000..af39f3a7f4 --- /dev/null +++ b/test-acceptance/data/project/glossary/glossary.txt @@ -0,0 +1,2 @@ +# Glossary in tab-separated format -*- coding: utf-8 -*- +Introduction 紹介 diff --git a/test-acceptance/data/project/omegat.project b/test-acceptance/data/project/omegat.project new file mode 100644 index 0000000000..df72303659 --- /dev/null +++ b/test-acceptance/data/project/omegat.project @@ -0,0 +1,33 @@ + + + + __DEFAULT__ + + **/.svn/** + **/CVS/** + **/.cvs/** + **/.git/** + **/.hg/** + **/.repositories/** + **/desktop.ini + **/Thumbs.db + **/.DS_Store + **/~$* + + __DEFAULT__ + __DEFAULT__ + __DEFAULT__ + __DEFAULT__ + __DEFAULT__ + __DEFAULT__ + + en + fr + org.omegat.tokenizer.LuceneEnglishTokenizer + org.omegat.tokenizer.LuceneFrenchTokenizer + false + true + true + + + diff --git a/test-acceptance/data/project/omegat/ignored_words.txt b/test-acceptance/data/project/omegat/ignored_words.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test-acceptance/data/project/omegat/learned_words.txt b/test-acceptance/data/project/omegat/learned_words.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test-acceptance/data/project/omegat/project_save.tmx b/test-acceptance/data/project/omegat/project_save.tmx new file mode 100644 index 0000000000..ae4a8b233b --- /dev/null +++ b/test-acceptance/data/project/omegat/project_save.tmx @@ -0,0 +1,17 @@ + + + +

+ + + + + Birds in Oregon + + + Birds in Oregon + + + + + diff --git a/test-acceptance/data/project/source/Bundle.properties b/test-acceptance/data/project/source/Bundle.properties new file mode 100644 index 0000000000..47ddb2e48c --- /dev/null +++ b/test-acceptance/data/project/source/Bundle.properties @@ -0,0 +1,36 @@ +# +# OmegaT - Computer Assisted Translation (CAT) tool +# with fuzzy matching, translation memory, keyword search, +# glossaries, and translation leveraging into updated projects. +# +# Copyright (C) 2023 Hiroshi Miura +# Home page: https://www.omegat.org/ +# Support center: https://omegat.org/support +# +# This file is part of OmegaT. +# +# OmegaT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OmegaT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +MT_ENGINE_APERTIUM=Apertium + +MT_JSON_ERROR=Error while reading MT results + +APERTIUM_ERROR=Error {0}: {1} +APERTIUM_CUSTOM_SERVER_LABEL=Connect to custom server instead of apertium.org +APERTIUM_CUSTOM_SERVER_URL_LABEL=Custom server URL +APERTIUM_CUSTOM_SERVER_KEY_LABEL=API key (optional) +APERTIUM_CUSTOM_SERVER_NOTFOUND=Unable to connect to server. Ensure the server URL is correct. +APERTIUM_CUSTOM_SERVER_INVALID=The server is not a valid Apertium server. Ensure the URL is correct. +APERTIUM_MARKUNKNOWN_LABEL=Mark unknown words + diff --git a/test-acceptance/data/project/target/.keep b/test-acceptance/data/project/target/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test-acceptance/data/project/tm/.keep b/test-acceptance/data/project/tm/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test-acceptance/src/org/omegat/TestMainInitializer.java b/test-acceptance/src/org/omegat/TestMainInitializer.java new file mode 100644 index 0000000000..d4d59676cd --- /dev/null +++ b/test-acceptance/src/org/omegat/TestMainInitializer.java @@ -0,0 +1,20 @@ +package org.omegat; + +import javax.swing.UIManager; + +import org.omegat.filters2.master.PluginUtils; + +public final class TestMainInitializer { + + private TestMainInitializer() { + } + + public static void initClassloader() { + ClassLoader cl = ClassLoader.getSystemClassLoader(); + MainClassLoader mainClassLoader = (cl instanceof MainClassLoader) ? (MainClassLoader) cl + : new MainClassLoader(cl); + PluginUtils.getThemePluginJars().forEach(mainClassLoader::add); + UIManager.put("ClassLoader", mainClassLoader); + } + +} diff --git a/test-acceptance/src/org/omegat/gui/dialogs/AboutDialogTest.java b/test-acceptance/src/org/omegat/gui/dialogs/AboutDialogTest.java new file mode 100644 index 0000000000..04f60ab024 --- /dev/null +++ b/test-acceptance/src/org/omegat/gui/dialogs/AboutDialogTest.java @@ -0,0 +1,60 @@ +/************************************************************************** + OmegaT - Computer Assisted Translation (CAT) tool + with fuzzy matching, translation memory, keyword search, + glossaries, and translation leveraging into updated projects. + + Copyright (C) 2024 Hiroshi Miura + Home page: https://www.omegat.org/ + Support center: https://omegat.org/support + + This file is part of OmegaT. + + OmegaT is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OmegaT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + **************************************************************************/ + +package org.omegat.gui.dialogs; + +import static org.junit.Assert.assertTrue; + +import java.util.regex.Pattern; + +import org.junit.Test; + +import org.omegat.gui.main.BaseMainWindowMenu; +import org.omegat.gui.main.TestCoreGUI; +import org.omegat.util.OStrings; + +public class AboutDialogTest extends TestCoreGUI { + + @Test + public void testAboutDialog() throws InterruptedException { + window.menuItem(BaseMainWindowMenu.HELP_MENU).click(); + window.menuItem(BaseMainWindowMenu.HELP_ABOUT_MENUITEM).click(); + // Check about dialog + window.dialog(AboutDialog.DIALOG_NAME).requireModal(); + Pattern pattern = Pattern.compile(OStrings.getApplicationDisplayName() + + "\\s+\\S+\\s+\\d+\\.\\d+\\.\\d+(\\s+)?\\([@0-9A-Fa-fv]+\\)"); + window.dialog(AboutDialog.DIALOG_NAME).label(AboutDialog.VERSION_LABEL_NAME).requireText(pattern); + // String aboutMessage = + // window.dialog(AboutDialog.DIALOG_NAME).textBox().text(); + String javaVersion = window.dialog(AboutDialog.DIALOG_NAME).label(AboutDialog.JAVA_VERSION_LABEL_NAME) + .text(); + assertTrue(javaVersion.contains(System.getProperty("java.version"))); + // check license dialog + window.dialog(AboutDialog.DIALOG_NAME).button(AboutDialog.LICENSE_BUTTON_NAME).click(); + // close about dialog + window.dialog(AboutDialog.DIALOG_NAME).button(AboutDialog.OK_BUTTON_NAME).click(); + } + +} diff --git a/test-acceptance/src/org/omegat/gui/main/DockingDefaults.xml b/test-acceptance/src/org/omegat/gui/main/DockingDefaults.xml new file mode 100644 index 0000000000..1df3d58856 --- /dev/null +++ b/test-acceptance/src/org/omegat/gui/main/DockingDefaults.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test-acceptance/src/org/omegat/gui/main/TestCoreGUI.java b/test-acceptance/src/org/omegat/gui/main/TestCoreGUI.java new file mode 100644 index 0000000000..e5a1bf2992 --- /dev/null +++ b/test-acceptance/src/org/omegat/gui/main/TestCoreGUI.java @@ -0,0 +1,115 @@ +/************************************************************************** + OmegaT - Computer Assisted Translation (CAT) tool + with fuzzy matching, translation memory, keyword search, + glossaries, and translation leveraging into updated projects. + + Copyright (C) 2024 Hiroshi Miura + Home page: https://www.omegat.org/ + Support center: https://omegat.org/support + + This file is part of OmegaT. + + OmegaT is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OmegaT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + **************************************************************************/ +package org.omegat.gui.main; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collections; + +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +import org.apache.commons.io.FileUtils; +import org.assertj.swing.edt.GuiActionRunner; +import org.assertj.swing.fixture.FrameFixture; +import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase; + +import org.omegat.TestMainInitializer; +import org.omegat.core.Core; +import org.omegat.core.CoreEvents; +import org.omegat.core.TestCoreInitializer; +import org.omegat.core.data.NotLoadedProject; +import org.omegat.core.threads.IAutoSave; +import org.omegat.filters2.master.FilterMaster; +import org.omegat.filters2.master.PluginUtils; +import org.omegat.util.Preferences; +import org.omegat.util.RuntimePreferences; +import org.omegat.util.gui.UIDesignManager; + +public abstract class TestCoreGUI extends AssertJSwingJUnitTestCase { + + protected FrameFixture window; + protected JFrame frame; + + @Override + protected void onSetUp() throws Exception { + Path tmp = Files.createTempDirectory("omegat"); + FileUtils.forceDeleteOnExit(tmp.toFile()); + RuntimePreferences.setConfigDir(tmp.toString()); + TestMainInitializer.initClassloader(); + // same order as Main.main + Preferences.init(); + PluginUtils.loadPlugins(Collections.emptyMap()); + FilterMaster.setFilterClasses(PluginUtils.getFilterClasses()); + Preferences.initFilters(); + Preferences.initSegmentation(); + // + frame = GuiActionRunner.execute(() -> { + Core.setProject(new NotLoadedProject()); + UIDesignManager.initialize(); + TestMainWindow mw = new TestMainWindow(TestMainWindowMenuHandler.class); + TestCoreInitializer.initMainWindow(mw); + TestCoreInitializer.initAutoSave(autoSave); + + CoreEvents.fireApplicationStartup(); + SwingUtilities.invokeLater(() -> { + // setVisible can't be executed directly, because we need to + // call all application startup listeners for initialize UI + Core.getMainWindow().getApplicationFrame().setVisible(true); + }); + return mw.getApplicationFrame(); + }); + + window = new FrameFixture(robot(), frame); + window.show(); + } + + static IAutoSave autoSave = new IAutoSave() { + public void enable() { + } + + public void disable() { + } + }; + + static class TestMainWindowMenu extends BaseMainWindowMenu { + + TestMainWindowMenu(IMainWindow mainWindow, BaseMainWindowMenuHandler mainWindowMenuHandler) { + super(mainWindow, mainWindowMenuHandler); + initComponents(); + } + + @Override + void createMenuBar() { + mainMenu.add(projectMenu); + mainMenu.add(editMenu); + mainMenu.add(gotoMenu); + mainMenu.add(viewMenu); + mainMenu.add(toolsMenu); + mainMenu.add(optionsMenu); + mainMenu.add(helpMenu); + } + } +} diff --git a/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java b/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java new file mode 100644 index 0000000000..e9f24910e2 --- /dev/null +++ b/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java @@ -0,0 +1,292 @@ +/************************************************************************** + OmegaT - Computer Assisted Translation (CAT) tool + with fuzzy matching, translation memory, keyword search, + glossaries, and translation leveraging into updated projects. + + Copyright (C) 2024 Hiroshi Miura + Home page: https://www.omegat.org/ + Support center: https://omegat.org/support + + This file is part of OmegaT. + + OmegaT is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OmegaT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + **************************************************************************/ +package org.omegat.gui.main; + +import java.awt.BorderLayout; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; +import java.awt.Rectangle; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; +import javax.swing.plaf.FontUIResource; + +import tokyo.northside.logging.ILogger; +import tokyo.northside.logging.LoggerFactory; + +import org.omegat.core.Core; +import org.omegat.core.CoreEvents; +import org.omegat.core.events.IApplicationEventListener; +import org.omegat.core.events.IProjectEventListener; +import org.omegat.gui.search.SearchWindowController; +import org.omegat.util.OConsts; +import org.omegat.util.OStrings; +import org.omegat.util.Preferences; +import org.omegat.util.gui.FontUtil; +import org.omegat.util.gui.StaticUIUtils; +import org.omegat.util.gui.UIDesignManager; +import org.omegat.util.gui.UIScale; + +import com.vlsolutions.swing.docking.Dockable; +import com.vlsolutions.swing.docking.DockingDesktop; + +@SuppressWarnings("serial") +class TestMainWindow implements IMainWindow { + private final JFrame applicationFrame; + private FontUIResource font; + private final ILogger logger = LoggerFactory.getLogger(TestMainWindow.class, + OStrings.getResourceBundle()); + public final BaseMainWindowMenu menu; + public final DockingDesktop desktop; + + /** + * Set of all open search windows. + */ + private final List searches = new ArrayList<>(); + + TestMainWindow(Class mainWindowMenuHandler) throws IOException { + applicationFrame = new JFrame(); + applicationFrame.setPreferredSize(new Dimension(1920, 1040)); + font = FontUtil.getScaledFont(); + try { + BaseMainWindowMenuHandler handler = mainWindowMenuHandler + .getDeclaredConstructor(IMainWindow.class).newInstance(this); + menu = new TestCoreGUI.TestMainWindowMenu(this, handler); + } catch (Exception e) { + throw new RuntimeException(); + } + applicationFrame.setJMenuBar(menu.mainMenu); + applicationFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + + desktop = new DockingDesktop(); + desktop.addDockableStateWillChangeListener(event -> { + if (event.getFutureState().isClosed()) { + event.cancel(); + } + }); + applicationFrame.getContentPane().add(desktop, BorderLayout.CENTER); + + StaticUIUtils.setWindowIcon(applicationFrame); + + updateTitle(); + + CoreEvents.registerProjectChangeListener(eventType -> { + updateTitle(); + if (eventType == IProjectEventListener.PROJECT_CHANGE_TYPE.CLOSE) { + closeSearchWindows(); + } + }); + + CoreEvents.registerApplicationEventListener(new IApplicationEventListener() { + public void onApplicationStartup() { + initializeScreenLayout(); + // Ensure any "closed" Dockables are visible. These can be newly + // added panes not included in an older layout file, or e.g. + // panes + // installed by plugins. + UIDesignManager.ensureDockablesVisible(desktop); + UIDesignManager.removeUnusedMenuSeparators(menu.getOptionsMenu().getPopupMenu()); + } + + public void onApplicationShutdown() { + } + }); + + UIScale.addPropertyChangeListener(evt -> CoreEvents.fireFontChanged(FontUtil.getScaledFont())); + CoreEvents.registerFontChangedEventListener( + newFont -> font = (newFont instanceof FontUIResource) ? (FontUIResource) newFont + : new FontUIResource(newFont)); + + // Set up prompt to reload if segmentation or filters settings change + Preferences.addPropertyChangeListener(evt -> { + if (Core.getProject().isProjectLoaded()) { + String prop = evt.getPropertyName(); + if (prop.equals(Preferences.PROPERTY_SRX) + && Core.getProject().getProjectProperties().getProjectSRX() == null) { + SwingUtilities.invokeLater(ProjectUICommands::promptReload); + } else if (prop.equals(Preferences.PROPERTY_FILTERS) + && Core.getProject().getProjectProperties().getProjectFilters() == null) { + SwingUtilities.invokeLater(ProjectUICommands::promptReload); + } + } + }); + + applicationFrame.pack(); + } + + /** + * Sets the title of the main window appropriately + */ + private void updateTitle() { + String s = OStrings.getDisplayNameAndVersion(); + applicationFrame.setTitle(s); + } + + private void closeSearchWindows() { + synchronized (searches) { + // dispose other windows + for (SearchWindowController sw : searches) { + sw.dispose(); + } + searches.clear(); + } + } + + /** + * Initialize the size of OmegaT window, then load the layout prefs. + */ + public void initializeScreenLayout() { + /* + * (23dec22) Set a reasonable default window size assuming a + * standard"pro" laptop resolution of 1920x1080. Smaller screens do not + * need to be considered since OmegaT will just use the whole window + * size in such cases. + */ + + // Check the real available space accounting for macOS DOCK, Windows + // Toolbar, etc. + Rectangle localAvailableSpace = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getMaximumWindowBounds(); + int screenWidth = localAvailableSpace.width; + int screenHeight = localAvailableSpace.height; + int omegatWidth = OConsts.OMEGAT_WINDOW_WIDTH; + int omegatHeight = OConsts.OMEGAT_WINDOW_HEIGHT; + + if (omegatWidth > screenWidth) { + omegatWidth = screenWidth; + } + + if (omegatHeight > screenHeight) { + omegatHeight = screenHeight; + } + + // Attempt to center the OmegaT main window on the screen + int omegatLeftPosition = (screenWidth - omegatWidth) / 2; + + Rectangle defaultWindowSize = new Rectangle(omegatLeftPosition, 0, omegatWidth, omegatHeight); + applicationFrame.setBounds(defaultWindowSize); + } + + @Override + public JFrame getApplicationFrame() { + return applicationFrame; + } + + @Override + public void lockUI() { + } + + @Override + public void unlockUI() { + } + + @Override + public Font getApplicationFont() { + return font; + } + + @Override + public void showStatusMessageRB(final String messageKey, final Object... params) { + } + + @Override + public void showTimedStatusMessageRB(final String messageKey, final Object... params) { + } + + @Override + public void showProgressMessage(final String messageText) { + } + + @Override + public void showLengthMessage(final String messageText) { + } + + @Override + public void showLockInsertMessage(final String messageText, final String toolTip) { + } + + @Override + public void displayWarningRB(final String warningKey, final Object... params) { + logger.atWarn().setMessageRB(warningKey).addArgument(params).log(); + } + + @Override + public void displayWarningRB(final String warningKey, final String supercedesKey, + final Object... params) { + } + + @Override + public void displayErrorRB(final Throwable ex, final String errorKey, final Object... params) { + } + + @Override + public void showErrorDialogRB(final String title, final String message, final Object... args) { + } + + @Override + public int showConfirmDialog(final Object message, final String title, final int optionType, + final int messageType) throws HeadlessException { + return 0; + } + + @Override + public void showMessageDialog(final String message) { + } + + /** + * {@inheritDoc} + */ + public void addDockable(Dockable pane) { + desktop.addDockable(pane); + } + + @Override + public void setCursor(final Cursor cursor) { + applicationFrame.setCursor(cursor); + } + + @Override + public Cursor getCursor() { + return applicationFrame.getCursor(); + } + + @Override + public IMainMenu getMainMenu() { + return menu; + } + + @Override + public DockingDesktop getDesktop() { + return desktop; + } + +} diff --git a/test-acceptance/src/org/omegat/gui/main/TestMainWindowMenuHandler.java b/test-acceptance/src/org/omegat/gui/main/TestMainWindowMenuHandler.java new file mode 100644 index 0000000000..2cbeb9267e --- /dev/null +++ b/test-acceptance/src/org/omegat/gui/main/TestMainWindowMenuHandler.java @@ -0,0 +1,393 @@ +/************************************************************************** + OmegaT - Computer Assisted Translation (CAT) tool + with fuzzy matching, translation memory, keyword search, + glossaries, and translation leveraging into updated projects. + + Copyright (C) 2024 Hiroshi Miura + Home page: https://www.omegat.org/ + Support center: https://omegat.org/support + + This file is part of OmegaT. + + OmegaT is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OmegaT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + **************************************************************************/ +package org.omegat.gui.main; + +import java.awt.Component; +import java.awt.KeyboardFocusManager; +import java.io.File; + +import javax.swing.JDialog; +import javax.swing.text.JTextComponent; + +import org.omegat.core.Core; +import org.omegat.core.data.SourceTextEntry; +import org.omegat.core.data.TMXEntry; +import org.omegat.gui.dialogs.AboutDialog; +import org.omegat.gui.dialogs.LogDialog; +import org.omegat.gui.editor.EditorUtils; +import org.omegat.gui.editor.SegmentExportImport; +import org.omegat.gui.exttrans.MachineTranslationInfo; +import org.omegat.gui.filelist.IProjectFilesList; +import org.omegat.gui.filters2.FiltersCustomizerController; +import org.omegat.gui.preferences.PreferencesWindowController; +import org.omegat.gui.preferences.view.EditingBehaviorController; +import org.omegat.gui.segmentation.SegmentationCustomizerController; +import org.omegat.gui.stat.StatisticsWindow; +import org.omegat.util.Log; +import org.omegat.util.Preferences; +import org.omegat.util.StaticUtils; +import org.omegat.util.StringUtil; + +public class TestMainWindowMenuHandler extends BaseMainWindowMenuHandler { + + IMainWindow mainWindow; + + public TestMainWindowMenuHandler(IMainWindow mw) { + this.mainWindow = mw; + } + + /** + * Create a new project. + */ + public void projectNewMenuItemActionPerformed() { + ProjectUICommands.projectCreate(); + } + + public void projectExitMenuItemActionPerformed() { + mainWindow.getApplicationFrame().setVisible(false); + mainWindow.getApplicationFrame().setEnabled(false); + } + + public void viewFileListMenuItemActionPerformed() { + IProjectFilesList projWin = Core.getProjectFilesList(); + if (projWin == null) { + return; + } + projWin.setActive(!projWin.isActive()); + } + + public void editUndoMenuItemActionPerformed() { + Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + if (focused == Core.getNotes()) { + Core.getNotes().undo(); + } else { + Core.getEditor().undo(); + } + } + + public void editRedoMenuItemActionPerformed() { + Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + if (focused == Core.getNotes()) { + Core.getNotes().redo(); + } else { + Core.getEditor().redo(); + } + } + + public void editOverwriteTranslationMenuItemActionPerformed() { + } + + public void editInsertTranslationMenuItemActionPerformed() { + } + + public void editOverwriteMachineTranslationMenuItemActionPerformed() { + MachineTranslationInfo tr = Core.getMachineTranslatePane().getDisplayedTranslation(); + if (tr == null) { + Core.getMachineTranslatePane().forceLoad(); + } else if (!StringUtil.isEmpty(tr.result)) { + Core.getEditor().replaceEditText(tr.result, String.format("MT:[%s]", tr.translatorName)); + } + } + + /** + * replaces entire edited segment text with a the source text of a segment + * at cursor position + */ + public void editOverwriteSourceMenuItemActionPerformed() { + if (!Core.getProject().isProjectLoaded()) { + return; + } + String toInsert = Core.getEditor().getCurrentEntry().getSrcText(); + if (Preferences.isPreference(Preferences.GLOSSARY_REPLACE_ON_INSERT)) { + toInsert = EditorUtils.replaceGlossaryEntries(toInsert); + } + Core.getEditor().replaceEditText(toInsert); + } + + /** inserts the source text of a segment at cursor position */ + public void editInsertSourceMenuItemActionPerformed() { + if (!Core.getProject().isProjectLoaded()) { + return; + } + String toInsert = Core.getEditor().getCurrentEntry().getSrcText(); + if (Preferences.isPreference(Preferences.GLOSSARY_REPLACE_ON_INSERT)) { + toInsert = EditorUtils.replaceGlossaryEntries(toInsert); + } + Core.getEditor().insertText(toInsert); + } + + /** select the source text of the current segment */ + public void editSelectSourceMenuItemActionPerformed() { + if (!Core.getProject().isProjectLoaded()) { + return; + } + Core.getEditor().selectSourceText(); + } + + public void editExportSelectionMenuItemActionPerformed() { + if (!Core.getProject().isProjectLoaded()) { + return; + } + String selection = Core.getEditor().getSelectedText(); + if (selection == null) { + SourceTextEntry ste = Core.getEditor().getCurrentEntry(); + TMXEntry te = Core.getProject().getTranslationInfo(ste); + if (te.isTranslated()) { + selection = te.translation; + } else { + selection = ste.getSrcText(); + } + } + SegmentExportImport.exportCurrentSelection(selection); + } + + public void editSearchDictionaryMenuItemActionPerformed() { + if (!Core.getProject().isProjectLoaded()) { + return; + } + String selection = Core.getEditor().getSelectedText(); + if (selection == null) { + SourceTextEntry ste = Core.getEditor().getCurrentEntry(); + selection = ste.getSrcText(); + } + Core.getDictionaries().searchText(selection); + } + + public void editCreateGlossaryEntryMenuItemActionPerformed() { + if (!Core.getProject().isProjectLoaded()) { + return; + } + Core.getGlossary().showCreateGlossaryEntryDialog(Core.getMainWindow().getApplicationFrame()); + } + + public void editFindInProjectMenuItemActionPerformed() { + } + + void findInProjectReuseLastWindow() { + } + + public void editReplaceInProjectMenuItemActionPerformed() { + } + + private String getTrimmedSelectedTextInMainWindow() { + String selection = null; + Component component = mainWindow.getApplicationFrame().getMostRecentFocusOwner(); + if (component instanceof JTextComponent) { + selection = ((JTextComponent) component).getSelectedText(); + if (!StringUtil.isEmpty(selection)) { + selection = EditorUtils.removeDirectionChars(selection); + selection = selection.trim(); + } + } + return selection; + } + + /** Set active match to #1. */ + public void editSelectFuzzy1MenuItemActionPerformed() { + Core.getMatcher().setActiveMatch(0); + } + + /** Set active match to #2. */ + public void editSelectFuzzy2MenuItemActionPerformed() { + Core.getMatcher().setActiveMatch(1); + } + + /** Set active match to #3. */ + public void editSelectFuzzy3MenuItemActionPerformed() { + Core.getMatcher().setActiveMatch(2); + } + + /** Set active match to #4. */ + public void editSelectFuzzy4MenuItemActionPerformed() { + Core.getMatcher().setActiveMatch(3); + } + + /** Set active match to #5. */ + public void editSelectFuzzy5MenuItemActionPerformed() { + Core.getMatcher().setActiveMatch(4); + } + + /** Set active match to the next one */ + public void editSelectFuzzyNextMenuItemActionPerformed() { + Core.getMatcher().setNextActiveMatch(); + } + + /** Set active match to the previous one */ + public void editSelectFuzzyPrevMenuItemActionPerformed() { + Core.getMatcher().setPrevActiveMatch(); + } + + public void insertCharsLRMActionPerformed() { + Core.getEditor().insertText("\u200E"); + } + + public void insertCharsRLMActionPerformed() { + Core.getEditor().insertText("\u200F"); + } + + public void insertCharsLREActionPerformed() { + Core.getEditor().insertText("\u202A"); + } + + public void insertCharsRLEActionPerformed() { + Core.getEditor().insertText("\u202B"); + } + + public void insertCharsPDFActionPerformed() { + Core.getEditor().insertText("\u202C"); + } + + public void editMultipleDefaultActionPerformed() { + Core.getEditor().setAlternateTranslationForCurrentEntry(false); + } + + public void editMultipleAlternateActionPerformed() { + Core.getEditor().setAlternateTranslationForCurrentEntry(true); + } + + public void editRegisterUntranslatedMenuItemActionPerformed() { + Core.getEditor().registerUntranslated(); + } + + public void editRegisterEmptyMenuItemActionPerformed() { + Core.getEditor().registerEmptyTranslation(); + } + + public void editRegisterIdenticalMenuItemActionPerformed() { + Core.getEditor().registerIdenticalTranslation(); + } + + public void toolsShowStatisticsStandardMenuItemActionPerformed() { + new StatisticsWindow(Core.getMainWindow().getApplicationFrame(), StatisticsWindow.STAT_TYPE.STANDARD) + .setVisible(true); + } + + public void toolsShowStatisticsMatchesMenuItemActionPerformed() { + new StatisticsWindow(Core.getMainWindow().getApplicationFrame(), StatisticsWindow.STAT_TYPE.MATCHES) + .setVisible(true); + } + + public void toolsShowStatisticsMatchesPerFileMenuItemActionPerformed() { + new StatisticsWindow(Core.getMainWindow().getApplicationFrame(), + StatisticsWindow.STAT_TYPE.MATCHES_PER_FILE).setVisible(true); + } + + public void optionsAutoCompleteShowAutomaticallyItemActionPerformed() { + /* + * Preferences.setPreference(Preferences. + * AC_SHOW_SUGGESTIONS_AUTOMATICALLY, + * mainWindow.menu.optionsAutoCompleteShowAutomaticallyItem.isSelected() + * ); + */ } + + public void optionsAutoCompleteHistoryCompletionMenuItemActionPerformed() { + /* + * Preferences.setPreference(Preferences.AC_HISTORY_COMPLETION_ENABLED, + * mainWindow.menu.optionsAutoCompleteHistoryCompletionMenuItem. + * isSelected()); + */ } + + public void optionsAutoCompleteHistoryPredictionMenuItemActionPerformed() { + /* + * Preferences.setPreference(Preferences.AC_HISTORY_PREDICTION_ENABLED, + * mainWindow.menu.optionsAutoCompleteHistoryPredictionMenuItem. + * isSelected()); + */ } + + public void optionsMTAutoFetchCheckboxMenuItemActionPerformed() { + /* + * boolean enabled = + * mainWindow.menu.optionsMTAutoFetchCheckboxMenuItem.isSelected(); + * Preferences.setPreference(Preferences.MT_AUTO_FETCH, enabled); + */ } + + public void optionsGlossaryFuzzyMatchingCheckBoxMenuItemActionPerformed() { + /* + * Preferences.setPreference(Preferences.GLOSSARY_STEMMING, + * mainWindow.menu.optionsGlossaryFuzzyMatchingCheckBoxMenuItem. + * isSelected()); Preferences.save(); + */ } + + public void optionsDictionaryFuzzyMatchingCheckBoxMenuItemActionPerformed() { + /* + * Preferences.setPreference(Preferences.DICTIONARY_FUZZY_MATCHING, + * mainWindow.menu.optionsDictionaryFuzzyMatchingCheckBoxMenuItem. + * isSelected()); Preferences.save(); + */ } + + /** + * Displays the filters setup dialog to allow customizing file filters in + * detail. + */ + public void optionsSetupFileFiltersMenuItemActionPerformed() { + new PreferencesWindowController().show(mainWindow.getApplicationFrame(), + FiltersCustomizerController.class); + } + + /** + * Displays the segmentation setup dialog to allow customizing the + * segmentation rules in detail. + */ + public void optionsSentsegMenuItemActionPerformed() { + new PreferencesWindowController().show(mainWindow.getApplicationFrame(), + SegmentationCustomizerController.class); + } + + /** + * Displays the workflow setup dialog to allow customizing the diverse + * workflow options. + */ + public void optionsWorkflowMenuItemActionPerformed() { + new PreferencesWindowController().show(mainWindow.getApplicationFrame(), + EditingBehaviorController.class); + } + + /** + * Restores defaults for all dockable parts. May be expanded in the future + * to reset the entire GUI to its defaults. + */ + public void viewRestoreGUIMenuItemActionPerformed() { + } + + public void optionsAccessConfigDirMenuItemActionPerformed() { + openFile(new File(StaticUtils.getConfigDir())); + } + + /** + * Show log + */ + public void helpLogMenuItemActionPerformed() { + new LogDialog(mainWindow.getApplicationFrame()).setVisible(true); + } + + public void helpAboutMenuItemActionPerformed() { + JDialog aboutDialog = new AboutDialog(mainWindow.getApplicationFrame()); + aboutDialog.setVisible(true); + } + + private void openFile(File file) { + Log.log("TestMainWindowMenuHanlder.openFile called with " + file.toString()); + } +}