From 2cf7982ed56dd894c0ea71340177bf86ba50c9d9 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 25 Feb 2019 10:10:55 +0700 Subject: [PATCH] Parse -Dnet.filebot.theme case-insensitively --- source/net/filebot/ui/ThemeSupport.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/net/filebot/ui/ThemeSupport.java b/source/net/filebot/ui/ThemeSupport.java index eea10523..0cf46105 100644 --- a/source/net/filebot/ui/ThemeSupport.java +++ b/source/net/filebot/ui/ThemeSupport.java @@ -1,5 +1,6 @@ package net.filebot.ui; +import static java.util.Arrays.*; import static javax.swing.BorderFactory.*; import static net.filebot.Logging.*; @@ -22,7 +23,7 @@ import net.filebot.util.ui.notification.SeparatorBorder.Position; public class ThemeSupport { - private static Theme theme = SystemProperty.of("net.filebot.theme", Theme::valueOf, Theme.System).get(); + private static Theme theme = SystemProperty.of("net.filebot.theme", Theme::forName, Theme.System).get(); public static Theme getTheme() { return theme; @@ -137,6 +138,15 @@ public class ThemeSupport { } public abstract void setLookAndFeel() throws Exception; + + public static Theme forName(String name) { + for (Theme t : values()) { + if (t.name().equalsIgnoreCase(name)) { + return t; + } + } + throw new IllegalArgumentException(String.format("%s not in %s", name, asList(values()))); + } } }