Skip to content

Commit

Permalink
release 1.3 with a fix to use the correct preferences file (XML Autho…
Browse files Browse the repository at this point in the history
…r, XML Editor, or XML Developer)
  • Loading branch information
danielnaber committed Feb 23, 2017
1 parent dd50719 commit 9165f49
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ you have problems.
* Entities are not expanded
* Checking long texts might take long. With checks that take longer than roughly
30 seconds, a timeout error will occur.
* Only tested with oXygen 18.0.
* Only tested with oXygen 18.1.


### Building
Expand Down Expand Up @@ -89,6 +89,10 @@ This process doesn't sign the JAR properly, though :-(

### Changelog

* version 1.3 (2017-02-23):
* fixed loading the configuration file: XML Author, XML Editor, and
XML Developer configuration files are now considered, depending on the
currently running application
* version 1.2 (2017-02-20):
* fixed a bug that caused using the configuration file of an old oXygen version
* version 1.1 (2016-06-21):
Expand Down
4 changes: 2 additions & 2 deletions extension.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<xt:extension xmlns:xt="http://www.oxygenxml.com/ns/extension" id="org.languagetool.oxygen.plugin">
<xt:location href="${project.build.finalName}-plugin.jar"/>
<xt:version>1.2.1</xt:version>
<xt:oxy_version>18.0</xt:oxy_version>
<xt:version>1.3.0</xt:version>
<xt:oxy_version>18.1</xt:oxy_version>
<xt:type>plugin</xt:type>
<xt:author>Daniel Naber</xt:author>
<xt:name>LanguageTool Plugin</xt:name>
Expand Down
18 changes: 18 additions & 0 deletions extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@
<xt:license>This plugin is licensed under GNU Lesser General Public License (LGPL), Version 2.1 or later. See http://www.gnu.org/licenses/old-licenses/lgpl-2.1</xt:license>
</xt:extension>
-->
<xt:extension xmlns:xt="http://www.oxygenxml.com/ns/extension" id="org.languagetool.oxygen.plugin">
<xt:location href="https://github.com/danielnaber/oxygen-languagetool-plugin/releases/download/1.3.0/oxygen-languagetool-plugin-1.3-plugin.jar"/>
<xt:version>1.2.0</xt:version>
<xt:oxy_version>18.1+</xt:oxy_version>
<xt:type>plugin</xt:type>
<xt:author>Daniel Naber</xt:author>
<xt:name>LanguageTool Plugin</xt:name>
<xt:description>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>LanguageTool for oXygen Author</title></head>
<body>
<div><p>This plugin makes <a href="https://languagetool.org">LanguageTool</a> usable from the oXygen XML editor.</p></div>
</body>
</html>
</xt:description>
<xt:license>This plugin is licensed under GNU Lesser General Public License (LGPL), Version 2.1 or later. See http://www.gnu.org/licenses/old-licenses/lgpl-2.1</xt:license>
</xt:extension>

<xt:extension xmlns:xt="http://www.oxygenxml.com/ns/extension" id="org.languagetool.oxygen.plugin">
<xt:location href="https://github.com/danielnaber/oxygen-languagetool-plugin/releases/download/1.2.0/oxygen-languagetool-plugin-1.2-plugin.jar"/>
<xt:version>1.2.0</xt:version>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.languagetool</groupId>
<artifactId>oxygen-languagetool-plugin</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.3</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down Expand Up @@ -69,7 +69,7 @@
<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen</artifactId>
<version>16.1.2</version>
<version>18.1.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/org/languagetool/oxygen/OxygenConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import java.awt.*;
import java.io.File;
import java.io.FileInputStream;

Expand All @@ -34,17 +35,29 @@
*/
class OxygenConfiguration {

private static final String PREFS_FILE_TEMPLATE = "oxyAuthorOptionsSa<VERSION>.xml";
private final String prefsFileTemplate;

private final StandalonePluginWorkspace pluginWorkspaceAccess;

OxygenConfiguration(StandalonePluginWorkspace pluginWorkspaceAccess) {
this.pluginWorkspaceAccess = pluginWorkspaceAccess;
Frame parentFrame = (Frame)pluginWorkspaceAccess.getParentFrame();
String title = parentFrame.getTitle();
// see https://www.oxygenxml.com/forum/post41681.html#p41681:
if (title.contains("XML Editor")) {
prefsFileTemplate = "oxyOptionsSa<VERSION>.xml";
} else if (title.contains("XML Author")) {
prefsFileTemplate = "oxyAuthorOptionsSa<VERSION>.xml";
} else if (title.contains("XML Developer")) {
prefsFileTemplate = "oxyDeveloperOptionsSa<VERSION>.xml";
} else {
throw new RuntimeException("Could not detect app, unexpected title: '" + title + "'");
}
}

String getDefaultLanguageCode() {
String preferencesDir = pluginWorkspaceAccess.getPreferencesDirectory();
File preferencesFile = new File(preferencesDir, PREFS_FILE_TEMPLATE.replace("<VERSION>", pluginWorkspaceAccess.getVersion()));
File preferencesFile = new File(preferencesDir, prefsFileTemplate.replace("<VERSION>", pluginWorkspaceAccess.getVersion()));
if (preferencesFile.exists()) {
try {
FileInputStream stream = null;
Expand Down

0 comments on commit 9165f49

Please sign in to comment.