diff --git a/src/org/omegat/gui/glossary/GlossaryTextArea.java b/src/org/omegat/gui/glossary/GlossaryTextArea.java
index 3246931b2a..0adcf31804 100644
--- a/src/org/omegat/gui/glossary/GlossaryTextArea.java
+++ b/src/org/omegat/gui/glossary/GlossaryTextArea.java
@@ -37,6 +37,7 @@
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Window;
+import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -50,6 +51,7 @@
import java.util.List;
import java.util.Locale;
+import javax.swing.Action;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
@@ -61,6 +63,8 @@
import javax.swing.text.JTextComponent;
import javax.swing.text.StyledDocument;
+import org.openide.awt.AbstractMnemonicsAction;
+
import org.omegat.core.Core;
import org.omegat.core.data.ProjectProperties;
import org.omegat.core.data.SourceTextEntry;
@@ -68,12 +72,9 @@
import org.omegat.gui.common.EntryInfoThreadPane;
import org.omegat.gui.dialogs.CreateGlossaryEntry;
import org.omegat.gui.editor.EditorUtils;
-import org.omegat.gui.glossary.actions.AddEntryAction;
-import org.omegat.gui.glossary.actions.InsertSectionAction;
-import org.omegat.gui.glossary.actions.SettingsNotifications;
-import org.omegat.gui.glossary.actions.SettingsOpenFileAction;
import org.omegat.gui.main.DockableScrollPane;
import org.omegat.gui.main.IMainWindow;
+import org.omegat.gui.main.ProjectUICommands;
import org.omegat.gui.shortcuts.PropertiesShortcuts;
import org.omegat.util.HttpConnectionUtils;
import org.omegat.util.Log;
@@ -431,4 +432,67 @@ public void populatePaneMenu(JPopupMenu menu) {
.setPreference(Preferences.GLOSSARY_SORT_BY_LENGTH, sortOrderLocLength.isSelected()));
menu.add(sortOrderLocLength);
}
+
+ public static class AddEntryAction extends AbstractMnemonicsAction {
+ GlossaryTextArea glossaryTextArea;
+
+ public AddEntryAction(GlossaryTextArea glossaryTextArea) {
+ super(OStrings.getString("GUI_GLOSSARYWINDOW_addentry"), OStrings.getLocale());
+ this.glossaryTextArea = glossaryTextArea;
+ }
+
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ glossaryTextArea.showCreateGlossaryEntryDialog(Core.getMainWindow().getApplicationFrame());
+ }
+ }
+
+ public static class InsertSectionAction extends AbstractMnemonicsAction {
+ private final String selection;
+
+ public InsertSectionAction(String selection) {
+ super(OStrings.getString("GUI_GLOSSARYWINDOW_insertselection"), OStrings.getLocale());
+ this.selection = selection;
+ }
+
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ Core.getEditor().insertText(selection);
+ }
+ }
+
+ public static class SettingsNotifications extends AbstractMnemonicsAction {
+ public SettingsNotifications() {
+ super(OStrings.getString("GUI_GLOSSARYWINDOW_SETTINGS_NOTIFICATIONS"), OStrings.getLocale());
+ }
+
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ Object notify = e.getSource();
+ if (notify instanceof JCheckBoxMenuItem) {
+ Preferences.setPreference(Preferences.NOTIFY_GLOSSARY_HITS, ((JCheckBoxMenuItem) notify).isSelected());
+ }
+ }
+ }
+
+ @SuppressWarnings("serial")
+ public static class SettingsOpenFileAction extends AbstractMnemonicsAction {
+ public SettingsOpenFileAction() {
+ super(OStrings.getString("GUI_GLOSSARYWINDOW_SETTINGS_OPEN_FILE"), OStrings.getLocale());
+ final String key = "projectAccessWriteableGlossaryMenuItem";
+ putValue(Action.ACTION_COMMAND_KEY, key);
+ try {
+ KeyStroke keyStoroke = PropertiesShortcuts.getMainMenuShortcuts().getKeyStroke(key);
+ putValue(Action.ACCELERATOR_KEY, keyStoroke);
+ } catch (Exception ignored) {
+ }
+ }
+
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ Log.logInfoRB("LOG_MENU_CLICK", e.getActionCommand());
+ int modifier = e.getModifiers();
+ ProjectUICommands.openWritableGlossaryFile((modifier & ActionEvent.ALT_MASK) != modifier);
+ }
+ }
}
diff --git a/src/org/omegat/gui/glossary/actions/AddEntryAction.java b/src/org/omegat/gui/glossary/actions/AddEntryAction.java
deleted file mode 100644
index 6d06d0326e..0000000000
--- a/src/org/omegat/gui/glossary/actions/AddEntryAction.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**************************************************************************
- 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.glossary.actions;
-
-import java.awt.event.ActionEvent;
-
-import org.openide.awt.AbstractMnemonicsAction;
-
-import org.omegat.core.Core;
-import org.omegat.gui.glossary.GlossaryTextArea;
-import org.omegat.util.OStrings;
-
-public class AddEntryAction extends AbstractMnemonicsAction {
- GlossaryTextArea glossaryTextArea;
-
- public AddEntryAction(GlossaryTextArea glossaryTextArea) {
- super(OStrings.getString("GUI_GLOSSARYWINDOW_addentry"), OStrings.getLocale());
- this.glossaryTextArea = glossaryTextArea;
- }
-
- @Override
- public void actionPerformed(final ActionEvent e) {
- glossaryTextArea.showCreateGlossaryEntryDialog(Core.getMainWindow().getApplicationFrame());
- }
-}
diff --git a/src/org/omegat/gui/glossary/actions/InsertSectionAction.java b/src/org/omegat/gui/glossary/actions/InsertSectionAction.java
deleted file mode 100644
index b5ff6678e1..0000000000
--- a/src/org/omegat/gui/glossary/actions/InsertSectionAction.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**************************************************************************
- 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.glossary.actions;
-
-import java.awt.event.ActionEvent;
-
-import org.openide.awt.AbstractMnemonicsAction;
-
-import org.omegat.core.Core;
-import org.omegat.util.OStrings;
-
-public class InsertSectionAction extends AbstractMnemonicsAction {
- private final String selection;
-
- public InsertSectionAction(String selection) {
- super(OStrings.getString("GUI_GLOSSARYWINDOW_insertselection"), OStrings.getLocale());
- this.selection = selection;
- }
-
- @Override
- public void actionPerformed(final ActionEvent e) {
- Core.getEditor().insertText(selection);
- }
-}
diff --git a/src/org/omegat/gui/glossary/actions/SettingsNotifications.java b/src/org/omegat/gui/glossary/actions/SettingsNotifications.java
deleted file mode 100644
index e6dc9b6a6b..0000000000
--- a/src/org/omegat/gui/glossary/actions/SettingsNotifications.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**************************************************************************
- 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.glossary.actions;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.JCheckBoxMenuItem;
-
-import org.openide.awt.AbstractMnemonicsAction;
-
-import org.omegat.util.OStrings;
-import org.omegat.util.Preferences;
-
-public class SettingsNotifications extends AbstractMnemonicsAction {
- public SettingsNotifications() {
- super(OStrings.getString("GUI_GLOSSARYWINDOW_SETTINGS_NOTIFICATIONS"), OStrings.getLocale());
- }
-
- @Override
- public void actionPerformed(final ActionEvent e) {
- Object notify = e.getSource();
- if (notify instanceof JCheckBoxMenuItem) {
- Preferences.setPreference(Preferences.NOTIFY_GLOSSARY_HITS, ((JCheckBoxMenuItem) notify).isSelected());
- }
- }
-}
diff --git a/src/org/omegat/gui/glossary/actions/SettingsOpenFileAction.java b/src/org/omegat/gui/glossary/actions/SettingsOpenFileAction.java
deleted file mode 100644
index 93cb0c467c..0000000000
--- a/src/org/omegat/gui/glossary/actions/SettingsOpenFileAction.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**************************************************************************
- 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.glossary.actions;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.Action;
-
-import org.openide.awt.AbstractMnemonicsAction;
-
-import org.omegat.gui.main.ProjectUICommands;
-import org.omegat.gui.shortcuts.PropertiesShortcuts;
-import org.omegat.util.Log;
-import org.omegat.util.OStrings;
-
-@SuppressWarnings("serial")
-public class SettingsOpenFileAction extends AbstractMnemonicsAction {
- public SettingsOpenFileAction() {
- super(OStrings.getString("GUI_GLOSSARYWINDOW_SETTINGS_OPEN_FILE"), OStrings.getLocale());
- final String key = "projectAccessWriteableGlossaryMenuItem";
- putValue(Action.ACTION_COMMAND_KEY, key);
- putValue(Action.ACCELERATOR_KEY, PropertiesShortcuts.getMainMenuShortcuts().getKeyStrokeOrNull(key));
- }
-
- @Override
- public void actionPerformed(final ActionEvent e) {
- Log.logInfoRB("LOG_MENU_CLICK", e.getActionCommand());
- int modifier = e.getModifiers();
- ProjectUICommands.openWritableGlossaryFile((modifier & ActionEvent.ALT_MASK) != modifier);
- }
-}
diff --git a/src/org/omegat/gui/main/ProjectUICommands.java b/src/org/omegat/gui/main/ProjectUICommands.java
index 817acbe067..3a2618afb0 100644
--- a/src/org/omegat/gui/main/ProjectUICommands.java
+++ b/src/org/omegat/gui/main/ProjectUICommands.java
@@ -83,6 +83,7 @@
import org.omegat.util.StaticUtils;
import org.omegat.util.StringUtil;
import org.omegat.util.WikiGet;
+import org.omegat.util.gui.DesktopWrapper;
import org.omegat.util.gui.OmegaTFileChooser;
import org.omegat.util.gui.OpenProjectFileChooser;
import org.omegat.util.gui.UIThreadsUtil;
@@ -1315,6 +1316,40 @@ public static void doWikiImport() {
}
}
+ public static void openWritableGlossaryFile(boolean parent) {
+ if (!Core.getProject().isProjectLoaded()) {
+ return;
+ }
+ String path = Core.getProject().getProjectProperties().getWriteableGlossary();
+ if (StringUtil.isEmpty(path)) {
+ return;
+ }
+ File toOpen = new File(path);
+ if (parent) {
+ toOpen = toOpen.getParentFile();
+ }
+ openFile(toOpen);
+ }
+
+ public static void openFile(File path) {
+ try {
+ path = path.getCanonicalFile(); // Normalize file name in case it is
+ // displayed
+ } catch (Exception ex) {
+ // Ignore
+ }
+ if (!path.exists()) {
+ Core.getMainWindow().showStatusMessageRB("LFC_ERROR_FILE_DOESNT_EXIST", path);
+ return;
+ }
+ try {
+ DesktopWrapper.open(path);
+ } catch (Exception ex) {
+ Log.logErrorRB(ex, "RPF_ERROR");
+ Core.getMainWindow().displayErrorRB(ex, "RPF_ERROR");
+ }
+ }
+
private static boolean ensureProjectDir(File dir) {
if (!dir.isDirectory() && !dir.mkdirs()) {
Log.logErrorRB("CT_ERROR_CREATING_PROJECT_DIR", dir);
diff --git a/src/org/omegat/util/OStrings.java b/src/org/omegat/util/OStrings.java
index c802b3eeff..4a4f683f23 100644
--- a/src/org/omegat/util/OStrings.java
+++ b/src/org/omegat/util/OStrings.java
@@ -82,7 +82,7 @@ public static ResourceBundle getResourceBundle() {
return bundle;
}
- public Locale getLocale() {
+ public static Locale getLocale() {
return bundle.getLocale();
}