* Bug #12470 fixed - Variable browser is not refreshed after loading an environment. 29/11329/5
Simon Marchetto [Fri, 14 Jun 2013 10:21:37 +0000 (12:21 +0200)]
Fix: call updatebrowsevar() in 'load environment' script

Refactoring: Split fonctionalities in Variable Browser
- opening
- set data
- update
done in Java classes BrowseVar, ScilabVariableBrowser
and in C: new unit BrowseVarManager (replaces UpdateBrowseVar)

macro browsevar() calls openVariableBrowser()
macro updatebrowsevar() calls SetVariableBrowserData()

Change-Id: I982e8d85b60c7dc0859c4b59a35d3eb244b4112f

17 files changed:
scilab/CHANGES_5.5.X
scilab/modules/console/src/c/GetCommandLine.c
scilab/modules/gui/etc/main_menubar.xml
scilab/modules/ui_data/Makefile.am
scilab/modules/ui_data/Makefile.in
scilab/modules/ui_data/includes/BrowseVarManager.h [moved from scilab/modules/ui_data/includes/UpdateBrowseVar.h with 69% similarity]
scilab/modules/ui_data/sci_gateway/cpp/sci_browsevar.cpp
scilab/modules/ui_data/sci_gateway/cpp/sci_updatebrowsevar.cpp
scilab/modules/ui_data/src/c/ui_data.vcxproj
scilab/modules/ui_data/src/c/ui_data.vcxproj.filters
scilab/modules/ui_data/src/cpp/BrowseVarManager.cpp [moved from scilab/modules/ui_data/src/cpp/UpdateBrowseVar.cpp with 90% similarity]
scilab/modules/ui_data/src/java/org/scilab/modules/ui_data/BrowseVar.java
scilab/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/ScilabVariableBrowser.java
scilab/modules/ui_data/src/jni/BrowseVar.cpp
scilab/modules/ui_data/src/jni/BrowseVar.giws.xml
scilab/modules/ui_data/src/jni/BrowseVar.hxx
scilab/modules/ui_data/src/noui_data/noui_data.c

index a7ba394..902d0e4 100644 (file)
@@ -315,6 +315,8 @@ Bug fixes
 * Bug #12463 fixed - Bad specification for rect=[x,y,w,h] argument in french help
                      page of xstringb.
 
+* Bug #12470 fixed - Variable browser is not refreshed after loading an environment.
+
 * Bug #12473 fixed - Problems with "é" in french help page of mkdir.
 
 * Bug #12475 fixed - csvRead() does not support double quoted fields.
index 5a1ae1a..8d9c90b 100644 (file)
@@ -32,7 +32,7 @@
 #include "initConsoleMode.h"
 #include "GetCommandLine.h"
 #include "TermReadAndProcess.h"
-#include "UpdateBrowseVar.h"
+#include "BrowseVarManager.h"
 #include "scicurdir.h"
 #include "FileBrowserChDir.h"
 #include "InitializeJVM.h"
@@ -281,7 +281,7 @@ void C2F(eventloopprompt) (char *buffer, int *buf_size, int *len_line, int *eof)
 
                 int err = 0;
 
-                UpdateBrowseVar(TRUE);
+                UpdateBrowseVar();
                 cwd = scigetcwd(&err);
                 if (cwd)
                 {
index 7cf82c7..7320a18 100644 (file)
@@ -13,7 +13,7 @@
             <callback instruction="               %fileToOpen = uigetfile(&quot;*.sc*&quot;, &quot;&quot;, gettext(&quot;Select a file to open with SciNotes&quot;));               if ~(%fileToOpen == &quot;&quot;) then                 editor(%fileToOpen);               end               clear(&quot;%fileToOpen&quot;);" type="0"/>
         </submenu>
         <submenu label="&amp;Load environment..." accelerator="OSSCKEY L" icon="document-open">
-            <callback instruction="               %fileToLoad = uigetfile([&quot;*.sav&quot;;&quot;*.sod&quot;], &quot;&quot;, gettext(&quot;Select a file to load&quot;));               if ~(%fileToLoad == &quot;&quot;) then                 load(%fileToLoad);                 disp(msprintf(gettext(&quot;Environment loaded.\n&quot;)));               end               clear(&quot;%fileToLoad&quot;);" type="0"/>
+            <callback instruction="               %fileToLoad = uigetfile([&quot;*.sav&quot;;&quot;*.sod&quot;], &quot;&quot;, gettext(&quot;Select a file to load&quot;));               if ~(%fileToLoad == &quot;&quot;) then                 load(%fileToLoad);                 updatebrowsevar();                 disp(msprintf(gettext(&quot;Environment loaded.\n&quot;)));               end               clear(&quot;%fileToLoad&quot;);" type="0"/>
         </submenu>
         <submenu label="&amp;Save environment..." accelerator="OSSCKEY S" icon="document-save">
             <callback instruction="               %fileToSave = uiputfile([&quot;*.sav&quot;;&quot;*.sod&quot;], &quot;&quot;, gettext(&quot;Select a file to write&quot;));               if ~(%fileToSave == &quot;&quot;) then                 if (fileparts(%fileToSave, &quot;extension&quot;) == &quot;&quot;) then                   %fileToSave = %fileToSave + &quot;.sav&quot;;                 end                 save(%fileToSave);                 disp(msprintf(gettext(&quot;Environment saved.\n&quot;)));               end               clear(&quot;%fileToSave&quot;);" type="0"/>
index fb1ac5f..97f55ee 100644 (file)
@@ -35,7 +35,7 @@ UI_DATA_JNI_SOURCES = src/jni/BrowseVar.cpp \
 UI_DATA_C_SOURCES = src/jni/ui_data_wrap.c \
                     src/c/PutScilabVariable.c
 
-UI_DATA_CXX_SOURCES = src/cpp/UpdateBrowseVar.cpp \
+UI_DATA_CXX_SOURCES = src/cpp/BrowseVarManager.cpp \
                      src/cpp/FileBrowserChDir.cpp
 
 GIWS_WRAPPERS = \
index c2f3d0a..155743f 100644 (file)
@@ -149,7 +149,7 @@ am__objects_1 = libsciui_data_algo_la-ui_data_wrap.lo \
 am__objects_2 = libsciui_data_algo_la-BrowseVar.lo \
        libsciui_data_algo_la-EditVar.lo \
        libsciui_data_algo_la-FileBrowser.lo
-am__objects_3 = libsciui_data_algo_la-UpdateBrowseVar.lo \
+am__objects_3 = libsciui_data_algo_la-BrowseVarManager.lo \
        libsciui_data_algo_la-FileBrowserChDir.lo
 am_libsciui_data_algo_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
        $(am__objects_3)
@@ -495,7 +495,7 @@ UI_DATA_JNI_SOURCES = src/jni/BrowseVar.cpp \
 UI_DATA_C_SOURCES = src/jni/ui_data_wrap.c \
                     src/c/PutScilabVariable.c
 
-UI_DATA_CXX_SOURCES = src/cpp/UpdateBrowseVar.cpp \
+UI_DATA_CXX_SOURCES = src/cpp/BrowseVarManager.cpp \
                      src/cpp/FileBrowserChDir.cpp
 
 GIWS_WRAPPERS = \
@@ -743,11 +743,11 @@ distclean-compile:
        -rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciui_data_algo_la-BrowseVar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciui_data_algo_la-BrowseVarManager.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciui_data_algo_la-EditVar.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciui_data_algo_la-FileBrowser.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciui_data_algo_la-FileBrowserChDir.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciui_data_algo_la-PutScilabVariable.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciui_data_algo_la-UpdateBrowseVar.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciui_data_algo_la-ui_data_wrap.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciui_data_disable_la-noui_data.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciui_data_la-gw_ui_data.Plo@am__quote@
@@ -848,12 +848,12 @@ libsciui_data_algo_la-FileBrowser.lo: src/jni/FileBrowser.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciui_data_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libsciui_data_algo_la-FileBrowser.lo `test -f 'src/jni/FileBrowser.cpp' || echo '$(srcdir)/'`src/jni/FileBrowser.cpp
 
-libsciui_data_algo_la-UpdateBrowseVar.lo: src/cpp/UpdateBrowseVar.cpp
-@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciui_data_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libsciui_data_algo_la-UpdateBrowseVar.lo -MD -MP -MF $(DEPDIR)/libsciui_data_algo_la-UpdateBrowseVar.Tpo -c -o libsciui_data_algo_la-UpdateBrowseVar.lo `test -f 'src/cpp/UpdateBrowseVar.cpp' || echo '$(srcdir)/'`src/cpp/UpdateBrowseVar.cpp
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libsciui_data_algo_la-UpdateBrowseVar.Tpo $(DEPDIR)/libsciui_data_algo_la-UpdateBrowseVar.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/UpdateBrowseVar.cpp' object='libsciui_data_algo_la-UpdateBrowseVar.lo' libtool=yes @AMDEPBACKSLASH@
+libsciui_data_algo_la-BrowseVarManager.lo: src/cpp/BrowseVarManager.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciui_data_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libsciui_data_algo_la-BrowseVarManager.lo -MD -MP -MF $(DEPDIR)/libsciui_data_algo_la-BrowseVarManager.Tpo -c -o libsciui_data_algo_la-BrowseVarManager.lo `test -f 'src/cpp/BrowseVarManager.cpp' || echo '$(srcdir)/'`src/cpp/BrowseVarManager.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libsciui_data_algo_la-BrowseVarManager.Tpo $(DEPDIR)/libsciui_data_algo_la-BrowseVarManager.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/BrowseVarManager.cpp' object='libsciui_data_algo_la-BrowseVarManager.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciui_data_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libsciui_data_algo_la-UpdateBrowseVar.lo `test -f 'src/cpp/UpdateBrowseVar.cpp' || echo '$(srcdir)/'`src/cpp/UpdateBrowseVar.cpp
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciui_data_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libsciui_data_algo_la-BrowseVarManager.lo `test -f 'src/cpp/BrowseVarManager.cpp' || echo '$(srcdir)/'`src/cpp/BrowseVarManager.cpp
 
 libsciui_data_algo_la-FileBrowserChDir.lo: src/cpp/FileBrowserChDir.cpp
 @am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciui_data_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libsciui_data_algo_la-FileBrowserChDir.lo -MD -MP -MF $(DEPDIR)/libsciui_data_algo_la-FileBrowserChDir.Tpo -c -o libsciui_data_algo_la-FileBrowserChDir.lo `test -f 'src/cpp/FileBrowserChDir.cpp' || echo '$(srcdir)/'`src/cpp/FileBrowserChDir.cpp
  *
  */
 
-#ifndef __UPDATEBROWSEVAR_H__
-#define __UPDATEBROWSEVAR_H__
+#ifndef __BROWSE_VAR_MANAGER_H__
+#define __BROWSE_VAR_MANAGER_H__
 /*--------------------------------------------------------------------------*/#
 #include "dynlib_ui_data.h"
-#include "BOOL.h"
-/**
-* UpdateBrowseVar function
-* @param update is true to update browsevar and false to open it.
-*/
-UI_DATA_IMPEXP void UpdateBrowseVar(BOOL update);
+
+UI_DATA_IMPEXP void OpenBrowseVar();
+UI_DATA_IMPEXP void UpdateBrowseVar();
+UI_DATA_IMPEXP void SetBrowseVarData();
 
 /*--------------------------------------------------------------------------*/
-#endif /* __UPDATEBROWSEVAR_H__ */
+#endif /* __BROWSE_VAR_MANAGER_H__ */
index b77e592..b19c117 100644 (file)
 
 extern "C"
 {
-#include "UpdateBrowseVar.h"
 #include "gw_ui_data.h"
-#include "BOOL.h"
 #include "api_scilab.h"
+#include "BrowseVarManager.h"
 }
 /*--------------------------------------------------------------------------*/
 int sci_browsevar(char *fname, unsigned long fname_len)
@@ -24,7 +23,7 @@ int sci_browsevar(char *fname, unsigned long fname_len)
     CheckRhs(0, 0);
     CheckLhs(0, 1);
 
-    UpdateBrowseVar(FALSE);
+    OpenBrowseVar();
 
     LhsVar(1) = 0;
     PutLhsVar();
index 6b7c063..189053f 100644 (file)
 
 extern "C"
 {
-#include "UpdateBrowseVar.h"
 #include "gw_ui_data.h"
-#include "BOOL.h"
-#include "stackinfo.h"
 #include "api_scilab.h"
-#include "Scierror.h"
+#include "BrowseVarManager.h"
 }
+
 /*--------------------------------------------------------------------------*/
 int sci_updatebrowsevar(char *fname, unsigned long fname_len)
 {
     CheckRhs(0, 0);
     CheckLhs(0, 1);
 
-    UpdateBrowseVar(TRUE);
+    UpdateBrowseVar();
 
     LhsVar(1) = 0;
     PutLhsVar();
index 811b561..5089c9f 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
     <ClCompile Include="..\..\sci_gateway\cpp\sci_filebrowser.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_updatebrowsevar.cpp" />
     <ClCompile Include="..\cpp\FileBrowserChDir.cpp" />
-    <ClCompile Include="..\cpp\UpdateBrowseVar.cpp" />
+    <ClCompile Include="..\cpp\BrowseVarManager.cpp" />
     <ClCompile Include="..\jni\BrowseVar.cpp" />
     <ClCompile Include="..\jni\FileBrowser.cpp" />
     <ClCompile Include="..\jni\ui_data_wrap.c" />
   <ItemGroup>
     <ClInclude Include="..\..\includes\FileBrowserChDir.h" />
     <ClInclude Include="..\..\includes\ui_data.h" />
-    <ClInclude Include="..\..\includes\UpdateBrowseVar.h" />
+    <ClInclude Include="..\..\includes\BrowseVarManager.h" />
     <ClInclude Include="..\jni\BrowseVar.hxx" />
     <ClInclude Include="..\..\includes\dynlib_ui_data.h" />
     <ClInclude Include="..\jni\EditVar.hxx" />
index 9208ffe..56f4b4f 100644 (file)
@@ -44,9 +44,6 @@
     <ClCompile Include="..\..\sci_gateway\cpp\sci_editvar.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\cpp\UpdateBrowseVar.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\jni\FileBrowser.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -68,6 +65,9 @@
     <ClCompile Include="..\..\sci_gateway\cpp\sci_closeEditvar.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\cpp\BrowseVarManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\jni\BrowseVar.hxx">
@@ -82,9 +82,6 @@
     <ClInclude Include="..\..\includes\gw_ui_data.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\includes\UpdateBrowseVar.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\includes\FileBrowserChDir.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -94,6 +91,9 @@
     <ClInclude Include="..\..\includes\ui_data.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\includes\BrowseVarManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="core_import.def">
@@ -24,7 +24,7 @@ using std::string;
 extern "C"
 {
 #include <string.h>
-#include "UpdateBrowseVar.h"
+#include "BrowseVarManager.h"
 #include "localization.h"
 #include "MALLOC.h"
 #include "BOOL.h"
@@ -44,8 +44,21 @@ static std::set < string > createScilabDefaultVariablesSet();
 static char * getListName(char * variableName);
 static std::string formatMatrix(int nbRows, int nbCols, BOOL isComplex, double *pdblReal, double *pdblImg);
 static char * valueToDisplay(char * variableName, int variableType, int nbRows, int nbCols);
-/*--------------------------------------------------------------------------*/
-void UpdateBrowseVar(BOOL update)
+void OpenBrowseVar()
+{
+    BrowseVar::openVariableBrowser(getScilabJavaVM());
+    SetBrowseVarData();
+}
+
+void UpdateBrowseVar()
+{
+    if (BrowseVar::isVariableBrowserOpened(getScilabJavaVM()))
+    {
+        SetBrowseVarData();
+    }
+}
+
+void SetBrowseVarData()
 {
     SciErr err;
     int iGlobalVariablesUsed = 0;
@@ -54,11 +67,6 @@ void UpdateBrowseVar(BOOL update)
     int iLocalVariablesTotal = 0;
     int i = 0;
 
-    if (update && !BrowseVar::isVariableBrowserOpened(getScilabJavaVM()))
-    {
-        return;
-    }
-
     // First get how many global / local variable we have.
     C2F(getvariablesinfo) (&iLocalVariablesTotal, &iLocalVariablesUsed);
     C2F(getgvariablesinfo) (&iGlobalVariablesTotal, &iGlobalVariablesUsed);
@@ -209,18 +217,17 @@ void UpdateBrowseVar(BOOL update)
     }
 
     // Launch Java Variable Browser through JNI
-    BrowseVar::openVariableBrowser(getScilabJavaVM(),
-                                   BOOLtobool(update),
-                                   pstAllVariableNames, iLocalVariablesUsed + iGlobalVariablesUsed,
-                                   piAllVariableBytes, iLocalVariablesUsed + iGlobalVariablesUsed,
-                                   piAllVariableTypes, iLocalVariablesUsed + iGlobalVariablesUsed,
-                                   piAllVariableIntegerTypes, iLocalVariablesUsed + iGlobalVariablesUsed,
-                                   pstAllVariableListTypes, iLocalVariablesUsed + iGlobalVariablesUsed,
-                                   pstAllVariableSizes, iLocalVariablesUsed + iGlobalVariablesUsed,
-                                   piAllVariableNbRows, iLocalVariablesUsed + iGlobalVariablesUsed,
-                                   piAllVariableNbCols, iLocalVariablesUsed + iGlobalVariablesUsed,
-                                   pstAllVariableVisibility, iLocalVariablesUsed + iGlobalVariablesUsed,
-                                   piAllVariableFromUser, iLocalVariablesUsed + iGlobalVariablesUsed);
+    BrowseVar::setVariableBrowserData(getScilabJavaVM(),
+                                      pstAllVariableNames, iLocalVariablesUsed + iGlobalVariablesUsed,
+                                      piAllVariableBytes, iLocalVariablesUsed + iGlobalVariablesUsed,
+                                      piAllVariableTypes, iLocalVariablesUsed + iGlobalVariablesUsed,
+                                      piAllVariableIntegerTypes, iLocalVariablesUsed + iGlobalVariablesUsed,
+                                      pstAllVariableListTypes, iLocalVariablesUsed + iGlobalVariablesUsed,
+                                      pstAllVariableSizes, iLocalVariablesUsed + iGlobalVariablesUsed,
+                                      piAllVariableNbRows, iLocalVariablesUsed + iGlobalVariablesUsed,
+                                      piAllVariableNbCols, iLocalVariablesUsed + iGlobalVariablesUsed,
+                                      pstAllVariableVisibility, iLocalVariablesUsed + iGlobalVariablesUsed,
+                                      piAllVariableFromUser, iLocalVariablesUsed + iGlobalVariablesUsed);
 
     freeArrayOfString(pstAllVariableNames, iLocalVariablesUsed + iGlobalVariablesUsed);
     freeArrayOfString(pstAllVariableVisibility, iLocalVariablesUsed + iGlobalVariablesUsed);
index 93c94f6..4354192 100644 (file)
@@ -117,14 +117,14 @@ public class BrowseVar {
     }
 
     /**
-     * Open variable Browser
+     * Open Variable Browser
      */
-    public static void openVariableBrowser(boolean update) {
-        ScilabVariableBrowser.getVariableBrowser(update);
+    public static void openVariableBrowser() {
+        ScilabVariableBrowser.openVariableBrowser();
     }
 
     /**
-     * Open variable Browser with information given by Scilab
+     * Set the Variable Browser data given by Scilab
      * @param dataNames : scilab variable name
      * @param dataBytes : scilab variable size in bytes
      * @param dataTypes : scilab variable type (as integer)
@@ -133,7 +133,7 @@ public class BrowseVar {
      * @param dataVisibility : local or global variable
      * @param dataFromUser : Scilab data or user data
      */
-    public static void openVariableBrowser(boolean update, String[] dataNames, int[] dataBytes, int[] dataTypes, int[] dataIntegerTypes, String[] variableListTypes, String[] dataSizes, int[] dataNbRows, int[] dataNbCols, String[] dataVisibility, boolean[] dataFromUser) {
+    public static void setVariableBrowserData(String[] dataNames, int[] dataBytes, int[] dataTypes, int[] dataIntegerTypes, String[] variableListTypes, String[] dataSizes, int[] dataNbRows, int[] dataNbCols, String[] dataVisibility, boolean[] dataFromUser) {
         Object[][] data = new Object[dataNames.length][COLUMNNAMES.length];
         for (int i = 0; i < dataNames.length; ++i) {
             data[i][ICON_COLUMN_INDEX] = getIconFromType(dataTypes[i]);
@@ -155,7 +155,14 @@ public class BrowseVar {
             data[i][NB_ROWS_INDEX] = dataNbRows[i];
             data[i][NB_COLS_INDEX] = dataNbCols[i];
         }
-        ScilabVariableBrowser.getVariableBrowser(update, data);
+        ScilabVariableBrowser.setVariableBrowserData(data);
+    }
+
+    /**
+     * Update Variable Browser
+     */
+    public static void updateVariableBrowserData() {
+        ScilabVariableBrowser.updateVariableBrowser();
     }
 
     /**
index c3b4279..97c8ae7 100644 (file)
@@ -68,35 +68,10 @@ public final class ScilabVariableBrowser implements VariableBrowser {
     }
 
     /**
-     * Retrieve Singleton
-     * @param columnNames : columns title
-     * @param data : data from scilab (type, name, size, ...)
+     * Opens Variable Browser
      * @return the Variable Browser
      */
-    public static VariableBrowser getVariableBrowser(boolean update, final Object[][] data) {
-        final VariableBrowser variableBrowser = getVariableBrowser(update);
-        SwingUtilities.invokeLater(new Runnable() {
-            public void run() {
-                variableBrowser.setData(data);
-            }
-        });
-        return variableBrowser;
-    }
-
-    /**
-     * Get the variable browser singleton
-     * @return the Variable Browser
-     */
-    public static VariableBrowser getVariableBrowser() {
-        return instance;
-    }
-
-    /**
-     * Get the variable browser singleton with specified columns title.
-     * @param columnNames : the columns title
-     * @return the Variable Browser
-     */
-    public static VariableBrowser getVariableBrowser(boolean update) {
+    public static VariableBrowser openVariableBrowser() {
         if (instance == null) {
             boolean success = WindowsConfigurationManager.restoreUUID(SwingScilabVariableBrowser.VARBROWSERUUID);
             if (!success) {
@@ -107,18 +82,37 @@ public final class ScilabVariableBrowser implements VariableBrowser {
                 window.setSize(500, 500);
                 window.setVisible(true);
             }
-        } else {
-            SwingScilabWindow window = (SwingScilabWindow) SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, browserTab);
-            if (!update) {
-                window.setVisible(true);
-                window.toFront();
-            }
         }
-
         return instance;
     }
 
     /**
+     * Set Variable Browser data
+     * @param data : data from scilab (type, name, size, ...)
+     */
+    public static void setVariableBrowserData(final Object[][] data) {
+        if (instance != null) {
+            SwingUtilities.invokeLater(new Runnable() {
+                public void run() {
+                    instance.setData(data);
+                }
+            });
+        }
+        ScilabVariableBrowser.updateVariableBrowser();
+    }
+
+    /**
+     * Update Variable Browser window
+     */
+    public static void updateVariableBrowser() {
+        if (instance != null) {
+            SwingScilabWindow window = (SwingScilabWindow) SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, browserTab);
+            window.setVisible(true);
+            window.toFront();
+        }
+    }
+
+    /**
      * Close Variable Browser
      */
     public static void closeVariableBrowser() {
@@ -128,6 +122,14 @@ public final class ScilabVariableBrowser implements VariableBrowser {
     }
 
     /**
+     * Get the variable browser singleton
+     * @return the Variable Browser
+     */
+    public static VariableBrowser getVariableBrowser() {
+        return instance;
+    }
+
+    /**
      * Close Variable Browser
      */
     public void close() {
index 809193a..2d6f258 100644 (file)
@@ -115,7 +115,9 @@ BrowseVar::BrowseVar(JavaVM * jvm_)
     curEnv->DeleteLocalRef(localInstance);
 
     /* Methods ID set to NULL */
-    voidopenVariableBrowserjbooleanbooleanjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID = NULL;
+    voidopenVariableBrowserID = NULL;
+    voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID = NULL;
+    voidupdateVariableBrowserDataID = NULL;
     jbooleanisVariableBrowserOpenedID = NULL;
     voidcloseVariableBrowserID = NULL;
 
@@ -143,7 +145,9 @@ BrowseVar::BrowseVar(JavaVM * jvm_, jobject JObj)
         throw GiwsException::JniObjectCreationException(curEnv, this->className());
     }
     /* Methods ID set to NULL */
-    voidopenVariableBrowserjbooleanbooleanjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID = NULL;
+    voidopenVariableBrowserID = NULL;
+    voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID = NULL;
+    voidupdateVariableBrowserDataID = NULL;
     jbooleanisVariableBrowserOpenedID = NULL;
     voidcloseVariableBrowserID = NULL;
 
@@ -169,20 +173,39 @@ void BrowseVar::endSynchronize()
 }
 // Method(s)
 
-void BrowseVar::openVariableBrowser (JavaVM * jvm_, bool update, char const* const* variableNames, int variableNamesSize, int const* variableBytes, int variableBytesSize, int const* variableTypes, int variableTypesSize, int const* variableIntegerTypes, int variableIntegerTypesSize, char const* const* variableListTypes, int variableListTypesSize, char const* const* variableSize, int variableSizeSize, int const* variableNbRows, int variableNbRowsSize, int const* variableNbCols, int variableNbColsSize, char const* const* variableVisibility, int variableVisibilitySize, bool const* variableFromUser, int variableFromUserSize)
+void BrowseVar::openVariableBrowser (JavaVM * jvm_)
 {
 
     JNIEnv * curEnv = NULL;
     jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
     jclass cls = curEnv->FindClass( className().c_str() );
 
-    jmethodID voidopenVariableBrowserjbooleanbooleanjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID = curEnv->GetStaticMethodID(cls, "openVariableBrowser", "(Z[Ljava/lang/String;[I[I[I[Ljava/lang/String;[Ljava/lang/String;[I[I[Ljava/lang/String;[Z)V" ) ;
-    if (voidopenVariableBrowserjbooleanbooleanjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID == NULL)
+    jmethodID voidopenVariableBrowserID = curEnv->GetStaticMethodID(cls, "openVariableBrowser", "()V" ) ;
+    if (voidopenVariableBrowserID == NULL)
     {
         throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableBrowser");
     }
 
-    jboolean update_ = (static_cast<bool>(update) ? JNI_TRUE : JNI_FALSE);
+    curEnv->CallStaticVoidMethod(cls, voidopenVariableBrowserID );
+    curEnv->DeleteLocalRef(cls);
+    if (curEnv->ExceptionCheck())
+    {
+        throw GiwsException::JniCallMethodException(curEnv);
+    }
+}
+
+void BrowseVar::setVariableBrowserData (JavaVM * jvm_, char const* const* variableNames, int variableNamesSize, int const* variableBytes, int variableBytesSize, int const* variableTypes, int variableTypesSize, int const* variableIntegerTypes, int variableIntegerTypesSize, char const* const* variableListTypes, int variableListTypesSize, char const* const* variableSize, int variableSizeSize, int const* variableNbRows, int variableNbRowsSize, int const* variableNbCols, int variableNbColsSize, char const* const* variableVisibility, int variableVisibilitySize, bool const* variableFromUser, int variableFromUserSize)
+{
+
+    JNIEnv * curEnv = NULL;
+    jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+    jclass cls = curEnv->FindClass( className().c_str() );
+
+    jmethodID voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID = curEnv->GetStaticMethodID(cls, "setVariableBrowserData", "([Ljava/lang/String;[I[I[I[Ljava/lang/String;[Ljava/lang/String;[I[I[Ljava/lang/String;[Z)V" ) ;
+    if (voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID == NULL)
+    {
+        throw GiwsException::JniMethodNotFoundException(curEnv, "setVariableBrowserData");
+    }
     jclass stringArrayClass = curEnv->FindClass("java/lang/String");
 
     // create java array of strings.
@@ -330,7 +353,7 @@ void BrowseVar::openVariableBrowser (JavaVM * jvm_, bool update, char const* con
     jbooleanArray variableFromUser_ = curEnv->NewBooleanArray( variableFromUserSize ) ;
     curEnv->SetBooleanArrayRegion( variableFromUser_, 0, variableFromUserSize, (jboolean*)variableFromUser ) ;
 
-    curEnv->CallStaticVoidMethod(cls, voidopenVariableBrowserjbooleanbooleanjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID , update_, variableNames_, variableBytes_, variableTypes_, variableIntegerTypes_, variableListTypes_, variableSize_, variableNbRows_, variableNbCols_, variableVisibility_, variableFromUser_);
+    curEnv->CallStaticVoidMethod(cls, voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID , variableNames_, variableBytes_, variableTypes_, variableIntegerTypes_, variableListTypes_, variableSize_, variableNbRows_, variableNbCols_, variableVisibility_, variableFromUser_);
     curEnv->DeleteLocalRef(stringArrayClass);
     curEnv->DeleteLocalRef(variableNames_);
     curEnv->DeleteLocalRef(variableBytes_);
@@ -349,6 +372,27 @@ void BrowseVar::openVariableBrowser (JavaVM * jvm_, bool update, char const* con
     }
 }
 
+void BrowseVar::updateVariableBrowserData (JavaVM * jvm_)
+{
+
+    JNIEnv * curEnv = NULL;
+    jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+    jclass cls = curEnv->FindClass( className().c_str() );
+
+    jmethodID voidupdateVariableBrowserDataID = curEnv->GetStaticMethodID(cls, "updateVariableBrowserData", "()V" ) ;
+    if (voidupdateVariableBrowserDataID == NULL)
+    {
+        throw GiwsException::JniMethodNotFoundException(curEnv, "updateVariableBrowserData");
+    }
+
+    curEnv->CallStaticVoidMethod(cls, voidupdateVariableBrowserDataID );
+    curEnv->DeleteLocalRef(cls);
+    if (curEnv->ExceptionCheck())
+    {
+        throw GiwsException::JniCallMethodException(curEnv);
+    }
+}
+
 bool BrowseVar::isVariableBrowserOpened (JavaVM * jvm_)
 {
 
index 160c308..abe5e5d 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0"?>
 <package name="org.scilab.modules.ui_data">
     <object name="BrowseVar">
-        <method name="openVariableBrowser" returnType="void" modifier="static">
-            <parameter type="boolean" name="update"/>
+        <method name="openVariableBrowser" returnType="void" modifier="static"/>
+        <method name="setVariableBrowserData" returnType="void" modifier="static">
             <parameter type="String[]" name="variableNames"/>
             <parameter type="int[]" name="variableBytes"/>
             <parameter type="int[]" name="variableTypes"/>
@@ -14,6 +14,7 @@
             <parameter type="String[]" name="variableVisibility"/>
             <parameter type="boolean[]" name="variableFromUser"/>
         </method>
+        <methode name="updateVariableBrowserData" returnType="void" modifier="static"/>
         <method name="isVariableBrowserOpened" returnType="boolean" modifier="static"/>
         <method name="closeVariableBrowser" returnType="void" modifier="static"/>
     </object>
index de4fd4e..c656689 100644 (file)
@@ -78,8 +78,10 @@ private:
     JavaVM * jvm;
 
 protected:
-    jmethodID voidopenVariableBrowserjbooleanbooleanjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID; // cache method id
+    jmethodID voidopenVariableBrowserID; // cache method id
+    jmethodID voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID; // cache method id
     jclass stringArrayClass;
+    jmethodID voidupdateVariableBrowserDataID; // cache method id
     jmethodID jbooleanisVariableBrowserOpenedID; // cache method id
     jmethodID voidcloseVariableBrowserID; // cache method id
 
@@ -141,7 +143,11 @@ public:
     void endSynchronize();
 
     // Methods
-    static void openVariableBrowser(JavaVM * jvm_, bool update, char const* const* variableNames, int variableNamesSize, int const* variableBytes, int variableBytesSize, int const* variableTypes, int variableTypesSize, int const* variableIntegerTypes, int variableIntegerTypesSize, char const* const* variableListTypes, int variableListTypesSize, char const* const* variableSize, int variableSizeSize, int const* variableNbRows, int variableNbRowsSize, int const* variableNbCols, int variableNbColsSize, char const* const* variableVisibility, int variableVisibilitySize, bool const* variableFromUser, int variableFromUserSize);
+    static void openVariableBrowser(JavaVM * jvm_);
+
+    static void setVariableBrowserData(JavaVM * jvm_, char const* const* variableNames, int variableNamesSize, int const* variableBytes, int variableBytesSize, int const* variableTypes, int variableTypesSize, int const* variableIntegerTypes, int variableIntegerTypesSize, char const* const* variableListTypes, int variableListTypesSize, char const* const* variableSize, int variableSizeSize, int const* variableNbRows, int variableNbRowsSize, int const* variableNbCols, int variableNbColsSize, char const* const* variableVisibility, int variableVisibilitySize, bool const* variableFromUser, int variableFromUserSize);
+
+    static void updateVariableBrowserData(JavaVM * jvm_);
 
     static bool isVariableBrowserOpened(JavaVM * jvm_);
 
index 17ce212..509e75e 100644 (file)
@@ -13,7 +13,7 @@
 #include "noui_data.h"
 #include "Scierror.h"
 #include "localization.h"
-#include "UpdateBrowseVar.h"
+#include "BrowseVarManager.h"
 #include "FileBrowserChDir.h"
 #include "BOOL.h"
 /*--------------------------------------------------------------------------*/