Add progress reporting on GUI
[fanfix.git] / src / be / nikiroo / fanfix / reader / LocalReader.java
index 88ffc5d42d534dbbfbf1fa7d89c8de310ec4d79a..7c50b033444d8c740b4a973dc1512b4354ab3ab1 100644 (file)
@@ -9,7 +9,7 @@ import be.nikiroo.fanfix.Library;
 import be.nikiroo.fanfix.bundles.UiConfig;
 import be.nikiroo.fanfix.data.Story;
 import be.nikiroo.fanfix.output.BasicOutput.OutputType;
-import be.nikiroo.utils.ui.Progress;
+import be.nikiroo.utils.Progress;
 
 class LocalReader extends BasicReader {
        private Library lib;
@@ -59,10 +59,18 @@ class LocalReader extends BasicReader {
         *             in case of I/O error
         */
        public void imprt(String luid, Progress pg) throws IOException {
+               Progress pgGetStory = new Progress();
+               Progress pgSave = new Progress();
+               if (pg != null) {
+                       pg.setMax(2);
+                       pg.addProgress(pgGetStory, 1);
+                       pg.addProgress(pgSave, 1);
+               }
+
                try {
-                       Story story = Instance.getLibrary().getStory(luid, pg);
+                       Story story = Instance.getLibrary().getStory(luid, pgGetStory);
                        if (story != null) {
-                               story = lib.save(story, luid);
+                               story = lib.save(story, luid, pgSave);
                        } else {
                                throw new IOException("Cannot find story in Library: " + luid);
                        }