X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FBasicReader.java;h=7b9c98c2a6c1f0239bb460fc2fc8b7938a36a9fb;hb=0d781e306746cf460f1f41338eb437f32cf9db33;hp=74bd5d48f98000606f9d8c72c67a88ea6f80403a;hpb=c1873e5678fabf306915c54f9c1736e03e027d60;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/reader/BasicReader.java b/src/be/nikiroo/fanfix/reader/BasicReader.java index 74bd5d4..7b9c98c 100644 --- a/src/be/nikiroo/fanfix/reader/BasicReader.java +++ b/src/be/nikiroo/fanfix/reader/BasicReader.java @@ -15,6 +15,7 @@ import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.supported.BasicSupport; import be.nikiroo.utils.Progress; import be.nikiroo.utils.ui.UIUtils; +import be.nikiroo.utils.serial.SerialUtils; /** * The class that handles the different {@link Story} readers you can use. @@ -31,6 +32,19 @@ public abstract class BasicReader { GUI, /** A text (UTF-8) reader with menu and text windows */ TUI, + + ; + + public String getTypeName() { + String pkg = "be.nikiroo.fanfix.reader."; + switch (this) { + case CLI: return pkg + "CliReader"; + case TUI: return pkg + "TuiReader"; + case GUI: return pkg + "LocalReader"; + } + + return null; + } } private static ReaderType defaultType = ReaderType.GUI; @@ -167,19 +181,12 @@ public abstract class BasicReader { public static BasicReader getReader() { try { if (defaultType != null) { - switch (defaultType) { - case GUI: - UIUtils.setLookAndFeel(); - return new LocalReader().setType(ReaderType.GUI); - case CLI: - return new CliReader().setType(ReaderType.CLI); - case TUI: - return new TuiReader().setType(ReaderType.TUI); - } + return ((BasicReader)SerialUtils.createObject + (defaultType.getTypeName())).setType(defaultType); } - } catch (IOException e) { + } catch (Exception e) { Instance.syserr(new Exception("Cannot create a reader of type: " - + defaultType, e)); + + defaultType + " (Not compiled in?)", e)); } return null;