Add some Progress Bar to show Atoms is working. Fix Bug#11509 19/8519/2
Bruno JOFRET [Fri, 3 Aug 2012 13:29:08 +0000 (15:29 +0200)]
Change-Id: I278b1c808a17245f3e22c6695ce0e42276659fc9

scilab/CHANGES_5.4.X
scilab/modules/atoms/macros/atoms_internals/atomsCloseProgressBar.sci [new file with mode: 0644]
scilab/modules/atoms/macros/atoms_internals/atomsDESCRIPTIONread.sci
scilab/modules/atoms/macros/atoms_internals/atomsDownload.sci
scilab/modules/atoms/macros/atoms_internals/atomsOpenProgressBar.sci [new file with mode: 0644]
scilab/modules/atoms/macros/atoms_internals/atomsUpdateProgressBar.sci [new file with mode: 0644]
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/waitbar/SwingScilabWaitBar.java

index 87a3467..fdd5a4d 100644 (file)
@@ -12,6 +12,8 @@ Bug Fixes
 * Bug #8151 fixed - Under Mac OS X, item "Scilab/Quit Scilab" and "File/Quit" were
                     duplicates.
 
+* Bug #11509 fixed - A progression bar was missing during Atoms operations.
+
 * Bug #11592 fixed - In the documentation, example of bessel failed.
 
 * Bug #11597 fixed - On Mac OS X, the Preferences windows was not accessible
diff --git a/scilab/modules/atoms/macros/atoms_internals/atomsCloseProgressBar.sci b/scilab/modules/atoms/macros/atoms_internals/atomsCloseProgressBar.sci
new file mode 100644 (file)
index 0000000..577f93a
--- /dev/null
@@ -0,0 +1,16 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012-2012 - Scilab Enterprises - Bruno JOFRET
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+//
+//
+function atomsCloseProgressBar(winId)
+    if (getscilabmode() <> "NWNI")
+        winclose(winId);
+    end
+endfunction
index 662a7d4..c8a2151 100644 (file)
@@ -113,8 +113,10 @@ function description_out = atomsDESCRIPTIONread(file_in,additional)
                               file_in));
     end
 
+    winId = atomsOpenProgressBar(_("Updating Atoms modules database..."), %t)
     for i=1:(size(lines_in,"*")+1)
 
+        atomsUpdateProgressBar(winId, i / size(lines_in,"*"));
         // File totally read : register the latest toolbox
         if i == (size(lines_in,"*")+1) then
 
@@ -131,6 +133,7 @@ function description_out = atomsDESCRIPTIONread(file_in,additional)
                 // Register the current toolbox : Check the mandatory fields
                 missingfield = atomsCheckFields( current_toolbox );
                 if ~ isempty(missingfield) then
+                    atomsCloseProgressBar(winId);
                     error(msprintf(gettext("%s: The file ""%s"" is not well formated, the toolbox ""%s - %s"" doesn''t contain the %s field\n"), ..
                         "atomsDESCRIPTIONread",..
                         file_in,current_toolbox("Toolbox"),..
@@ -175,6 +178,7 @@ function description_out = atomsDESCRIPTIONread(file_in,additional)
                     // Register the current toolbox : Check the mandatory fields
                     missingfield = atomsCheckFields( current_toolbox );
                     if ~ isempty(missingfield) then
+                        atomsCloseProgressBar(winId);
                         error(msprintf(gettext("%s: The file ""%s"" is not well formated, the toolbox ""%s - %s"" doesn''t contain the %s field\n"), ..
                             "atomsDESCRIPTIONread",..
                             file_in,current_toolbox("Toolbox"),..
@@ -233,6 +237,7 @@ function description_out = atomsDESCRIPTIONread(file_in,additional)
                 if and(isfield(current_toolbox,["Toolbox";"Version"])) then
                     categories_flat = atomsAddPackage2Cat( categories_flat , [current_toolbox("Toolbox") current_toolbox("Version")],current_value);
                 else
+                    atomsCloseProgressBar(winId);
                     error(msprintf(gettext("%s: name and version are not both defined\n"),"atomsDESCRIPTIONread"));
                 end
             end
@@ -243,7 +248,7 @@ function description_out = atomsDESCRIPTIONread(file_in,additional)
         // Second case : Current field continuation
         if regexp(lines_in(i),"/^\s/","o") == 1 then
             current_value = part(lines_in(i),2:length(lines_in(i)));
-            current_toolbox(current_field) = [ current_toolbox(current_field) ; current_value ];
+            current_toolbox(current_field)($+1) =  current_value;
 
             // Category management
             if current_field == "Category" then
@@ -253,6 +258,7 @@ function description_out = atomsDESCRIPTIONread(file_in,additional)
                 if and(isfield(current_toolbox,["Toolbox";"Version"])) then
                     categories_flat = atomsAddPackage2Cat( categories_flat , [current_toolbox("Toolbox") current_toolbox("Version")],current_value);
                 else
+                    atomsCloseProgressBar(winId);
                     error(msprintf(gettext("%s: name and version are not both defined\n"),"atomsDESCRIPTIONread"));
                 end
             end
@@ -271,6 +277,7 @@ function description_out = atomsDESCRIPTIONread(file_in,additional)
         end
 
         // Else Error
+        atomsCloseProgressBar(winId);
         error(msprintf(gettext("%s: The file ''%s'' is not well formated at line %d\n"),"atomsDESCRIPTIONread",file_in,i));
 
     end
@@ -278,6 +285,7 @@ function description_out = atomsDESCRIPTIONread(file_in,additional)
     description_out("packages")        = packages;
     description_out("categories")      = categories;
     description_out("categories_flat") = categories_flat;
+    atomsCloseProgressBar(winId);
 
 endfunction
 
index 0a65fe4..68add72 100644 (file)
@@ -173,6 +173,8 @@ function atomsDownload(url_in,file_out,md5sum)
       download_cmd = proxy_host_arg+"wget"+proxy_user_arg+timeout_arg+" "+url_in + " -O " + file_out;
     end
 
+    winId = atomsOpenProgressBar(_("Download in progress... Please be patient."), %f);
+
     err = [];
     [rep,stat,err] = unix_g(download_cmd);
 
@@ -208,6 +210,7 @@ function atomsDownload(url_in,file_out,md5sum)
       mprintf(gettext("\t - URL      : ''%s''\n"), url_in);
       mprintf(gettext("\t - Local location : ''%s''\n"), file_out);
       if isdef('err') then
+        atomsCloseProgressBar(winId);
         error(strcat(err, ascii(10)));
       end
     end
@@ -226,6 +229,7 @@ function atomsDownload(url_in,file_out,md5sum)
       mprintf(gettext("%s: The following file hasn''t been copied:\n"),"atomsDownload");
       mprintf(gettext("\t - source    : ''%s''\n"),file_in);
       mprintf(gettext("\t - destination : ''%s''\n"),file_out);
+      atomsCloseProgressBar(winId);
       error(strcat(lasterror(), ascii(10)));
     end
 
@@ -243,9 +247,11 @@ function atomsDownload(url_in,file_out,md5sum)
       mprintf(gettext("\t - file      : ''%s''\n"),file_out);
       mprintf(gettext("\t - MD5SUM expected : ''%s''\n"),md5sum);
       mprintf(gettext("\t - MD5SUM watched  : ''%s''\n"),filemd5);
+      atomsCloseProgressBar(winId);
       error("");
     end
 
   end
 
+  atomsCloseProgressBar(winId);
 endfunction
diff --git a/scilab/modules/atoms/macros/atoms_internals/atomsOpenProgressBar.sci b/scilab/modules/atoms/macros/atoms_internals/atomsOpenProgressBar.sci
new file mode 100644 (file)
index 0000000..64beb53
--- /dev/null
@@ -0,0 +1,23 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012-2012 - Scilab Enterprises - Bruno JOFRET
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+//
+//
+
+function winId = atomsOpenProgressBar(message, withValue)
+    if (getscilabmode() <> "NWNI")
+        if (withValue == %t)
+            winId = waitbar(_("Atoms:")+" "+message);
+        else
+            winId = progressionbar(_("Atoms:")+" "+message);
+        end
+    else
+        winId = -1
+    end
+endfunction
\ No newline at end of file
diff --git a/scilab/modules/atoms/macros/atoms_internals/atomsUpdateProgressBar.sci b/scilab/modules/atoms/macros/atoms_internals/atomsUpdateProgressBar.sci
new file mode 100644 (file)
index 0000000..6b99ca7
--- /dev/null
@@ -0,0 +1,17 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012-2012 - Scilab Enterprises - Bruno JOFRET
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+//
+//
+
+function atomsUpdateProgressBar(winId, value)
+    if (getscilabmode() <> "NWNI" & winId.type == "Waitbar")
+        waitbar(value, winId);
+    end
+endfunction
\ No newline at end of file
index 32307e7..3e88249 100644 (file)
@@ -1,11 +1,11 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2008 - INRIA - Vincent Couvert
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
@@ -41,7 +41,7 @@ public class SwingScilabWaitBar extends JFrame implements SwingViewObject, Simpl
 
     private static final long serialVersionUID = -5208590743368628657L;
 
-    private static final int WIDTH = 300;
+    private static final int WIDTH = 400;
     private static final int HEIGHT = 150;
 
     private String uid;
@@ -63,13 +63,13 @@ public class SwingScilabWaitBar extends JFrame implements SwingViewObject, Simpl
         setIconImage(scilabIcon.getImage());
 
         GridBagLayout gridbag = new GridBagLayout();
-        
+
         Insets insets = new Insets(8, 4, 8, 4);
-        
+
         JPanel pane = new JPanel(gridbag);
         pane.setOpaque(true);
         setContentPane(pane);
-        
+
 
         /* Scilab icon */
         GridBagConstraints iconConstraints = new GridBagConstraints();
@@ -110,15 +110,15 @@ public class SwingScilabWaitBar extends JFrame implements SwingViewObject, Simpl
 
         pane.setVisible(true);
         pane.doLayout();
-        
+
         this.setSize(WIDTH, HEIGHT);
         this.setPreferredSize(new Dimension(WIDTH, HEIGHT));
         this.setMinimumSize(new Dimension(WIDTH, HEIGHT));
-        
+
         if (ScilabConsole.isExistingConsole()) {
             setLocationRelativeTo((Component) ScilabConsole.getConsole().getAsSimpleConsole());
         }
-        
+
         this.setVisible(true);
         this.doLayout();
         this.pack();