diff --git a/source/net/filebot/Main.java b/source/net/filebot/Main.java index 20cdd568..edcdede6 100644 --- a/source/net/filebot/Main.java +++ b/source/net/filebot/Main.java @@ -1,11 +1,9 @@ package net.filebot; import static java.awt.GraphicsEnvironment.*; -import static java.util.Arrays.*; import static java.util.stream.Collectors.*; import static net.filebot.Logging.*; import static net.filebot.Settings.*; -import static net.filebot.util.ExceptionUtilities.*; import static net.filebot.util.FileUtilities.*; import static net.filebot.util.XPathUtilities.*; import static net.filebot.util.ui.SwingUI.*; @@ -36,10 +34,8 @@ import org.w3c.dom.Document; import net.filebot.cli.ArgumentBean; import net.filebot.cli.ArgumentProcessor; -import net.filebot.cli.CmdlineException; import net.filebot.format.ExpressionFormat; import net.filebot.platform.mac.MacAppUtilities; -import net.filebot.platform.windows.WinAppUtilities; import net.filebot.ui.FileBotMenuBar; import net.filebot.ui.GettingStartedStage; import net.filebot.ui.MainFrame; @@ -134,7 +130,7 @@ public class Main { System.exit(1); } catch (Throwable e) { // unexpected error => dump stack - debug.log(Level.SEVERE, "Error during startup: " + getRootCause(e), e); + debug.severe(cause("Error during startup", e)); System.exit(1); } } @@ -181,16 +177,7 @@ public class Main { } // start multi panel or single panel frame - PanelBuilder[] panels = PanelBuilder.defaultSequence(); - - if (args.mode != null) { - panels = stream(panels).filter(p -> p.getName().matches(args.mode)).toArray(PanelBuilder[]::new); // only selected panels - - if (panels.length == 0) { - throw new CmdlineException("Illegal mode: " + args.mode); - } - } - + PanelBuilder[] panels = args.getPanelBuilders(); JFrame frame = panels.length > 1 ? new MainFrame(panels) : new SinglePanelFrame(panels[0]); try { @@ -221,9 +208,6 @@ public class Main { frame.setIconImages(ResourceManager.getApplicationIcons()); } else if (isWindowsApp()) { // Windows specific configuration - if (!isAppStore()) { - WinAppUtilities.setAppUserModelID(Settings.getApplicationUserModelID()); // support Windows 7 taskbar behaviours (not necessary for Windows 10 apps) - } frame.setIconImages(ResourceManager.getApplicationIcons()); } else { // generic Linux/FreeBSD/Solaris configuration diff --git a/source/net/filebot/cli/ArgumentBean.java b/source/net/filebot/cli/ArgumentBean.java index 2df906fa..98e18b78 100644 --- a/source/net/filebot/cli/ArgumentBean.java +++ b/source/net/filebot/cli/ArgumentBean.java @@ -1,5 +1,6 @@ package net.filebot.cli; +import static java.util.Arrays.*; import static java.util.Collections.*; import static net.filebot.Logging.*; import static net.filebot.hash.VerificationUtilities.*; @@ -18,6 +19,7 @@ import java.util.Map; import java.util.Optional; import java.util.function.Supplier; import java.util.logging.Level; +import java.util.regex.Pattern; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.CmdLineException; @@ -38,6 +40,7 @@ import net.filebot.format.ExpressionFormat; import net.filebot.hash.HashType; import net.filebot.subtitle.SubtitleFormat; import net.filebot.subtitle.SubtitleNaming; +import net.filebot.ui.PanelBuilder; import net.filebot.web.Datasource; import net.filebot.web.EpisodeListProvider; import net.filebot.web.SortOrder; @@ -304,6 +307,19 @@ public class ArgumentBean { return Level.parse(log.toUpperCase()); } + public PanelBuilder[] getPanelBuilders() { + // default multi panel mode + if (mode == null) { + return PanelBuilder.defaultSequence(); + } + + // only selected panels + return optional(mode).map(m -> { + Pattern pattern = Pattern.compile(mode, Pattern.CASE_INSENSITIVE); + return stream(PanelBuilder.defaultSequence()).filter(p -> pattern.matcher(p.getName()).matches()).toArray(PanelBuilder[]::new); + }).orElseThrow(error("Illegal mode", mode)); + } + private final String[] args; public ArgumentBean(String... args) throws CmdLineException {