-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: GlossaryTextArea to use Actions classes
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
- Loading branch information
Showing
5 changed files
with
206 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/************************************************************************** | ||
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 <https://www.gnu.org/licenses/>. | ||
**************************************************************************/ | ||
|
||
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()); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/org/omegat/gui/glossary/actions/InsertSectionAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/************************************************************************** | ||
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 <https://www.gnu.org/licenses/>. | ||
**************************************************************************/ | ||
|
||
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); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/org/omegat/gui/glossary/actions/SettingsNotifications.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/************************************************************************** | ||
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 <https://www.gnu.org/licenses/>. | ||
**************************************************************************/ | ||
|
||
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()); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/org/omegat/gui/glossary/actions/SettingsOpenFileAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/************************************************************************** | ||
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 <https://www.gnu.org/licenses/>. | ||
**************************************************************************/ | ||
|
||
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); | ||
} | ||
} |