fix macOs language selection

This commit is contained in:
bancika
2020-12-13 14:29:14 +01:00
parent 9dada76406
commit 52750121e3
6 changed files with 44 additions and 10 deletions
@@ -89,8 +89,10 @@ public class LangUtil {
LOG.info("Loading translation for " + language);
dict = new HashMap<String, String>();
try {
String path = ResourceLoader.getFile(LANG_DIR + File.separator + language + ".txt").getAbsolutePath();
LOG.debug("Loading language file: " + path);
try (Stream<String> stream = Files.lines(
Paths.get(LANG_DIR + File.separator + language + ".txt"), StandardCharsets.UTF_8)) {
Paths.get(path), StandardCharsets.UTF_8)) {
stream.forEach(s -> {
if (s.contains("|")) {
String[] parts = s.split("\\|");
@@ -431,13 +431,17 @@ public class Presenter implements IPlugInPort {
Set<Class<?>> componentTypeClasses = null;
try {
componentTypeClasses = Utils.getClasses("org.diylc.components");
try {
List<Class<?>> additionalComponentTypeClasses =
JarScanner.getInstance().scanFolder("library", IDIYComponent.class);
if (additionalComponentTypeClasses != null)
componentTypeClasses.addAll(additionalComponentTypeClasses);
} catch (Exception e) {
LOG.warn("Could not find additional type classes", e);
File libraryFile = new File("library");
if (libraryFile.exists() && libraryFile.isDirectory()) {
LOG.info("Loading additional library JARs");
try {
List<Class<?>> additionalComponentTypeClasses =
JarScanner.getInstance().scanFolder("library", IDIYComponent.class);
if (additionalComponentTypeClasses != null)
componentTypeClasses.addAll(additionalComponentTypeClasses);
} catch (Exception e) {
LOG.warn("Could not find additional type classes", e);
}
}
for (Class<?> clazz : componentTypeClasses) {
@@ -3333,6 +3333,10 @@
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Dragging components from the component tree to the canvas stops working once the component type is selected in the tree</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>macOS: fixed language selection that does not work</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
@@ -30,7 +30,7 @@ public class ResourceLoader {
String bundlePath;
try {
bundlePath = com.apple.eio.FileManager.getPathToApplicationBundle();
LOG.debug("Detected OSX bundle path: " + bundlePath);
//LOG.debug("Detected OSX bundle path: " + bundlePath);
} catch (Exception e) {
bundlePath = null; // on non-OSX platforms
}
@@ -48,4 +48,26 @@ public class ResourceLoader {
return null;
}
}
public static File getFile(String relativePath) {
String bundlePath;
try {
bundlePath = com.apple.eio.FileManager.getPathToApplicationBundle();
//LOG.debug("Detected OSX bundle path: " + bundlePath);
} catch (Exception e) {
bundlePath = null; // on non-OSX platforms
}
try {
String absolutePath;
if (bundlePath == null)
absolutePath = relativePath;
else
absolutePath = bundlePath + File.separator + "Contents" + File.separator + "Resources" + File.separator + relativePath;
File absoluteFile = new File(absolutePath);
return absoluteFile;
} catch (Exception e) {
LOG.error("Error while finding file: " + relativePath, e);
return null;
}
}
}