Skip to content

Commit

Permalink
Merge branch 'master' into topic/miurahr/gui/main/menu-construct-with…
Browse files Browse the repository at this point in the history
…-properties-abstract-action
  • Loading branch information
miurahr authored Mar 21, 2024
2 parents 29e611d + 54abfcd commit 2e2cc04
Show file tree
Hide file tree
Showing 26 changed files with 1,214 additions and 903 deletions.
1 change: 0 additions & 1 deletion config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
<suppress files="EditorTextArea3\.java" checks="MethodLength"/>
<suppress files="AutoCompleter\.java" checks="EmptyStatement"/>
<suppress files="RepositoriesMappingController\.java" checks="MethodLength"/>
<suppress files="ProjectPropertiesDialog\.java" checks="(MethodLength|ParameterNumber)"/>
<suppress files="InstanceEditor\.java" checks="ParameterNumber"/>
<suppress files="EditorController\.java" checks="(File|Method)Length"/>
<suppress files="ProjectUICommands\.java" checks="MethodLength"/>
Expand Down
12 changes: 11 additions & 1 deletion doc_src/en/OmegaT_Preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1704,8 +1704,18 @@ ${filePath}></programlisting></para>
linkend="application.folder">application</link> folder.</para>

<para>Additional plugins can be found on the <ulink
url="https://sourceforge.net/p/omegat/wiki/Plugins/">OmegaT development
url="https://sourceforge.net/p/omegat/wiki/Plugins/">OmegaT wiki
site</ulink>.</para>
<para>Use the <guibutton>Install plugin from disk</guibutton> button to install or upgrade your
plugin. Plugin files are JAR files with a <filename>.jar</filename> extension.
OmegaT also accepts zip archives that contain a JAR plugin file.
Third party plugins are typically distributed as zip archives that contain the plugin file
itself, as well as README and LICENSE files.
</para>
<warning>
<para>The plugin installer only accepts archives containing a JAR plugin.
It does not recognize plugin files renamed with a <filename>.zip</filename> extension.</para>
</warning>
</section>

<section id="dialogs.preferences.updates">
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
slf4j = { strictly = "[2.0.7, 2.1[", prefer = "2.0.7" }
slf4j-format = "0.5.1"
groovy = "4.0.19"
groovy = "4.0.20"
junit = "4.13.2"
commons_lang3 = "3.14.0"
commons_io = "2.15.1"
Expand Down Expand Up @@ -35,7 +35,7 @@ htmlparser = "1.6-20230203"
gnudiff = "1.15"
desktopsupport = "0.6.0"
protocolhandler = "0.1.4"
pdfbox = "3.0.1"
pdfbox = "3.0.2"
maligna = "3.0.1"
trie4j = "0.9.10_1"
dsl4j = "0.7.1"
Expand All @@ -48,7 +48,7 @@ xjc = "2.3.4"
jna = "5.13.0"
jfa = "1.2.0"
tipoftheday = "0.4.4"
flatlaf="3.3"
flatlaf="3.4"

[libraries]
slf4j-api = {group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ private String apertiumCode(Language language) {
String locale = language.getLocaleCode();

if (!StringUtil.isEmpty(language.getCountryCode())) {
if (locale.equalsIgnoreCase("en_us") || locale.equalsIgnoreCase("pt_br")) {
return locale; // We need en_US and pt_BR
} else if (locale.equalsIgnoreCase("oc_ar")) {
return "oc_aran";
if (locale.equalsIgnoreCase("oc_ar")) {
return "oci_aran";
} else if (locale.equalsIgnoreCase("ca_va")) {
return "ca_valencia";
return "cat_valencia";
} else {
return locale;
}
}

Expand Down
5 changes: 4 additions & 1 deletion release/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
OmegaT 6.1.0
----------------------------------------------------------------------
44 Enhancement
67 Bug fixes
68 Bug fixes
5 Localisation updates
----------------------------------------------------------------------
6.1.0 vs 6.0.0
Expand Down Expand Up @@ -136,6 +136,9 @@

Bug fixes:

- Short glossary items are not recognized with Korean source
https://sourceforge.net/p/omegat/bugs/1250/

- Debug log in some classes are broken
https://sourceforge.net/p/omegat/bugs/1249/

Expand Down
19 changes: 13 additions & 6 deletions src/org/omegat/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,7 @@ GUI_DICTIONARY_INSTALLER_AVAILABLE=Available languages:

# org.omegat.gui.dialogs.PluginInstallerDialog
GUI_PLUGIN_INSTALLER_TITLE=Plugin Installer
GUI_PLUGIN_OPEN=Select a plugin file (*.jar, *.zip)
GUI_PLUGIN_OPEN=Select a plugin file (*.jar) or a zip archive (*.zip) that contains a plugin jar file.
GUI_PLUGIN_INSTALLER_INSTALL=Install

# matches text area popup menu
Expand Down Expand Up @@ -2910,13 +2910,20 @@ PREFS_PLUGINS_COL_VERSION=Version
PREFS_PLUGINS_COL_AUTHOR=Author
PREFS_PLUGINS_COL_DESCRIPTION=Description
PREFS_PLUGINS_INSTALL_FROM_DISK=&Install plugin from disk
PREFS_PLUGINS_TITLE_CONFIRM_INSTALLATION=Install plugin file
PREFS_PLUGINS_CONFIRM_UPGRADE=Upgrade/override plugin {0}\n\
current: {1}\n\
new version: {2}
PREFS_PLUGINS_CONFIRM_INSTALL=Install plugin {0} {1}
PREFS_PLUGINS_TITLE_CONFIRM_INSTALLATION=Install Plugin
PREFS_PLUGINS_TITLE_CONFIRM_UPGRADE=Upgrade Plugin
PREFS_PLUGINS_CONFIRM_UPGRADE=Upgrade the {0} plugin?\n\
Current version: {1}\n\
New version: {2}
PREFS_PLUGINS_CONFIRM_OVERWRITE=Version {1} is already installed.\n\
Reinstall the {0} plugin?\n
PREFS_PLUGINS_CONFIRM_INSTALL=Install the {0} {1} plugin?
PREFS_PLUGINS_INSTALLATION_FAILED=Plugin installation failed.
PREFS_PLUGINS_INSTALLATION_SUCCEED=Plugin installation successful. Restart OmegaT to activate it.
PREFS_PLUGINS_UNKNOWN_ARCHIVE=This file is not a plugin archive.
PREFS_PLUGINS_TITLE_NAME=Plugin Name
PREFS_PLUGINS_TITLE_CURRENT_VERSION=Installed
PREFS_PLUGINS_TITLE_TARGET_VERSION=Selected

# PREFERENCES - UPDATES
VERSION_CHECK_UP_TO_DATE=You already have the latest version.
Expand Down
10 changes: 7 additions & 3 deletions src/org/omegat/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,13 @@ private static void applyConfigFile(String path) {
*/
protected static int runGUI() {
ClassLoader cl = ClassLoader.getSystemClassLoader();
MainClassLoader mainClassLoader = (cl instanceof MainClassLoader) ? (MainClassLoader) cl
: new MainClassLoader(cl);
PluginUtils.getThemePluginJars().forEach(mainClassLoader::add);
MainClassLoader mainClassLoader;
if (cl instanceof MainClassLoader) {
mainClassLoader = (MainClassLoader) cl;
} else {
mainClassLoader = new MainClassLoader(cl);
}
PluginUtils.getThemePluginJars().forEach(mainClassLoader::addJarToClasspath);
UIManager.put("ClassLoader", mainClassLoader);

// macOS-specific - they must be set BEFORE any GUI calls
Expand Down
33 changes: 13 additions & 20 deletions src/org/omegat/MainClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,9 @@ public final class MainClassLoader extends URLClassLoader {
registerAsParallelCapable();
}

private String name;

/**
* Java9 compatible class loader constructor.
* @param name name of class loader
* @param parent
*/
public MainClassLoader(String name, ClassLoader parent) {
this(parent);
this.name = name;
}

/*
* Required when this classloader is used as the system classloader
* Java9 compatible class loader constructor.
* @param parent system class loader.
*/
public MainClassLoader(ClassLoader parent) {
this(new URL[0], parent);
Expand All @@ -70,16 +59,20 @@ public MainClassLoader() {
}

/**
* Main class can add jar classpath for plugins in dynamic manner.
* @param url
* Add URL to classpath.
* @param url to added.
*/
synchronized void add(URL url) {
public void addJarToClasspath(URL url) {
addURL(url);
}

synchronized void addJarToClasspath(String jarName)
throws MalformedURLException {
URL url = new File(jarName).toURI().toURL();
/**
* Add Jar file into classpath.
* @param jarFile JAR file to add to classpath.
* @throws MalformedURLException when a malformed File object is passed.
*/
public void addJarToClasspath(File jarFile) throws MalformedURLException {
URL url = jarFile.toURI().toURL();
addURL(url);
}

Expand All @@ -98,6 +91,6 @@ public static MainClassLoader findAncestor(ClassLoader cl) {
*/
@SuppressWarnings("unused")
private void appendToClassPathForInstrumentation(String jarfile) throws IOException {
add(Paths.get(jarfile).toRealPath().toUri().toURL());
addJarToClasspath(Paths.get(jarfile).toRealPath().toFile());
}
}
10 changes: 9 additions & 1 deletion src/org/omegat/core/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import org.omegat.gui.editor.mark.IMarker;
import org.omegat.gui.exttrans.IMachineTranslation;
import org.omegat.gui.exttrans.MachineTranslateTextArea;
import org.omegat.gui.filelist.IProjectFilesList;
import org.omegat.gui.filelist.ProjectFilesListController;
import org.omegat.gui.glossary.GlossaryManager;
import org.omegat.gui.glossary.GlossaryTextArea;
import org.omegat.gui.glossary.IGlossaries;
Expand Down Expand Up @@ -103,6 +105,7 @@ private Core() {
private static IIssues issuesWindow;
private static IMatcher matcher;
private static FilterMaster filterMaster;
private static IProjectFilesList projWin;

protected static IAutoSave saveThread;
private static final ReentrantLock EXCLUSIVE_RUN_LOCK = new ReentrantLock();
Expand Down Expand Up @@ -172,6 +175,10 @@ public static void setFilterMaster(FilterMaster newFilterMaster) {
EntryKey.setIgnoreFileContext(newFilterMaster.getConfig().isIgnoreFileContext());
}

public static IProjectFilesList getProjectFilesList() {
return projWin;
}

public static MachineTranslateTextArea getMachineTranslatePane() {
return machineTranslatePane;
}
Expand Down Expand Up @@ -255,7 +262,7 @@ public static void initializeGUI(final Map<String, String> params) throws Except
// 4. Initialize other components. They add themselves to the main window.
editor = new EditorController(me);
tagValidation = new TagValidationTool();
issuesWindow = new IssuesPanelController(me);
issuesWindow = new IssuesPanelController(me.getApplicationFrame());
matcher = new MatchesTextArea(me);
GlossaryTextArea glossaryArea = new GlossaryTextArea(me);
glossary = glossaryArea;
Expand All @@ -266,6 +273,7 @@ public static void initializeGUI(final Map<String, String> params) throws Except
dictionaries = new DictionariesTextArea(me);
multiple = new MultipleTransPane(me);
new SegmentPropertiesArea(me);
projWin = new ProjectFilesListController();

SaveThread th = new SaveThread();
saveThread = th;
Expand Down
15 changes: 8 additions & 7 deletions src/org/omegat/filters2/master/PluginUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,10 @@ public static void loadPlugins(final Map<String, String> params) {
try (InputStream in = mu.openStream()) {
Manifest m = new Manifest(in);
if ("org.omegat.Main".equals(m.getMainAttributes().getValue("Main-Class"))) {
// found main manifest - not in development mode
// found a main manifest - not in development mode
foundMain = true;
loadFromManifest(m, pluginsClassLoader, null);
} else {
loadFromManifest(m, pluginsClassLoader, mu);
}
loadFromManifest(m, pluginsClassLoader, mu);
if ("theme".equals(m.getMainAttributes().getValue("Plugin-Category"))) {
String target = mu.toString();
for (URL url : urlList) {
Expand All @@ -211,9 +209,7 @@ public static void loadPlugins(final Map<String, String> params) {
} catch (ClassNotFoundException e) {
Log.log(e);
} catch (UnsupportedClassVersionError e) {
JarURLConnection connection = (JarURLConnection) mu.openConnection();
URL url = connection.getJarFileURL();
Log.logWarningRB("PLUGIN_JAVA_VERSION_ERROR", url);
Log.logWarningRB("PLUGIN_JAVA_VERSION_ERROR", getJarFileUrlFromResourceUrl(mu));
}
}
} catch (IOException ex) {
Expand Down Expand Up @@ -633,4 +629,9 @@ private static boolean loadClassOld(String sType, String key, ClassLoader classL
public static Collection<PluginInformation> getPluginInformations() {
return Collections.unmodifiableSet(PLUGIN_INFORMATIONS);
}

public static URL getJarFileUrlFromResourceUrl(URL url) throws IOException {
JarURLConnection connection = (JarURLConnection) url.openConnection();
return connection.getJarFileURL();
}
}
Loading

0 comments on commit 2e2cc04

Please sign in to comment.