From 40def42285cab46db3106170c4ec055a0cfae187 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 26 Apr 2020 14:37:15 +0200 Subject: [PATCH] direct Main with arguments to CLI version --- src/be/nikiroo/fanfix/Instance.java | 16 +++++-- src/be/nikiroo/fanfix_swing/Main.java | 42 +++++-------------- .../fanfix_swing/gui/book/BookPopup.java | 1 + 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/src/be/nikiroo/fanfix/Instance.java b/src/be/nikiroo/fanfix/Instance.java index f48d05b7..d0d1c84a 100644 --- a/src/be/nikiroo/fanfix/Instance.java +++ b/src/be/nikiroo/fanfix/Instance.java @@ -48,8 +48,19 @@ public class Instance { /** * Initialise the instance -- if already initialised, nothing will happen. *

- * Before calling this method, you may call {@link Bundles#setDirectory(String)} - * if wanted. + * Before calling this method, you may call + * {@link Bundles#setDirectory(String)} if wanted. + *

+ * Note that this method will honour some environment variables, the 3 most + * important ones probably being: + *

*/ static public void init() { init(false); @@ -465,7 +476,6 @@ public class Instance { BasicLibrary lib = null; boolean useRemote = config.getBoolean(Config.REMOTE_LIBRARY_ENABLED, false); - if (useRemote) { String host = null; int port = -1; diff --git a/src/be/nikiroo/fanfix_swing/Main.java b/src/be/nikiroo/fanfix_swing/Main.java index cf83537f..91f65fce 100644 --- a/src/be/nikiroo/fanfix_swing/Main.java +++ b/src/be/nikiroo/fanfix_swing/Main.java @@ -12,40 +12,18 @@ import be.nikiroo.utils.ui.UIUtils; public class Main { public static void main(String[] args) { - UIUtils.setLookAndFeel(); - - final String forceLib = null; - // = "$HOME/Books/local"; - - if (forceLib == null) { - Instance.init(); - } else { - Instance.init(new Instance() { - private DataLoader cache; - private BasicLibrary lib; - - @Override - public DataLoader getCache() { - if (cache == null) { - cache = new DataLoader(getConfig() - .getString(Config.NETWORK_USER_AGENT)); - } - - return cache; - } - - @Override - public BasicLibrary getLibrary() { - if (lib == null) { - lib = new LocalLibrary(getFile(forceLib), getConfig()) { - }; - } - - return lib; - } - }); + // Defer to main application if parameters (we are only a UI) + // (though we could handle some of the parameters in the future, + // maybe importing via ImporterFrame? but that would require a + // unique instance of the UI to be usable...) + if (args != null && args.length > 0) { + be.nikiroo.fanfix.Main.main(args); + return; } + UIUtils.setLookAndFeel(); + Instance.init(); + JFrame main = new MainFrame(true, true); main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); main.setVisible(true); diff --git a/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java b/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java index d3f7e51b..4fcaa56b 100644 --- a/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java +++ b/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java @@ -45,6 +45,7 @@ public class BookPopup extends JPopupMenu { // not null public List getSelected(); + // visual only! public void setCached(BookInfo book, boolean cached); public BookInfo getUniqueSelected(); -- 2.27.0