Java help browser update
Vincent Couvert [Fri, 14 Mar 2008 15:28:43 +0000 (15:28 +0000)]
19 files changed:
scilab/modules/gui/Makefile.am
scilab/modules/gui/Makefile.in
scilab/modules/gui/includes/CallHelpBrowser.h
scilab/modules/gui/includes/gw_gui.h
scilab/modules/gui/sci_gateway/c/gw_gui.c
scilab/modules/gui/sci_gateway/c/sci_help.c [deleted file]
scilab/modules/gui/sci_gateway/c/sci_helpbrowser.c [new file with mode: 0644]
scilab/modules/gui/sci_gateway/gui_gateway.xml
scilab/modules/gui/src/c/gui.vcproj
scilab/modules/gui/src/cpp/CallHelpBrowser.cpp
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/ScilabBridge.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/helpbrowser/SwingScilabHelpBrowser.java
scilab/modules/gui/src/java/org/scilab/modules/gui/helpbrowser/ScilabHelpBrowser.java
scilab/modules/gui/src/java/org/scilab/modules/gui/helpbrowser/ScilabHelpBrowserBridge.java
scilab/modules/gui/src/jni/CallScilabBridge.cpp
scilab/modules/gui/src/jni/CallScilabBridge.giws.xml
scilab/modules/gui/src/jni/CallScilabBridge.hxx
scilab/modules/helptools/macros/help.sci

index 547a0b0..c93082a 100644 (file)
@@ -128,7 +128,7 @@ sci_gateway/c/sci_mpopup.c \
 sci_gateway/c/sci_messagebox.c \
 sci_gateway/c/sci_waitbar.c \
 sci_gateway/c/sci_progressionbar.c \
-sci_gateway/c/sci_help.c
+sci_gateway/c/sci_helpbrowser.c
 
 libscigui_la_CFLAGS=   -Isrc/c/ \
                        -Isrc/c/xsci/ \
index 05c3896..65ea651 100644 (file)
@@ -123,21 +123,22 @@ am__libscigui_la_SOURCES_DIST = src/nogui/nogui.c \
        sci_gateway/c/sci_uicontextmenu.c sci_gateway/c/sci_uimenu.c \
        sci_gateway/c/sci_uiwait.c sci_gateway/c/sci_mpopup.c \
        sci_gateway/c/sci_messagebox.c sci_gateway/c/sci_waitbar.c \
-       sci_gateway/c/sci_progressionbar.c sci_gateway/c/sci_help.c \
-       src/cpp/InitUIMenu.cpp src/jni/CallScilabBridge.cpp \
-       src/jni/Jxclick.cpp src/cpp/DestroyUIControl.cpp \
-       src/cpp/DestroyWaitBar.cpp src/cpp/CallJxclick.cpp \
-       src/jni/Jxgetmouse.cpp src/cpp/CallJxgetmouse.cpp \
-       src/cpp/CallFileChooser.cpp src/cpp/CallFigure.cpp \
-       src/cpp/CallMessageBox.cpp src/cpp/CallWaitBar.cpp \
-       src/cpp/CallHelpBrowser.cpp src/cpp/PushButton.cpp \
-       src/cpp/EditBox.cpp src/cpp/Label.cpp src/cpp/CheckBox.cpp \
-       src/cpp/RadioButton.cpp src/cpp/Slider.cpp \
-       src/cpp/PopupMenu.cpp src/cpp/ContextMenu.cpp \
-       src/cpp/ListBox.cpp src/cpp/Frame.cpp src/cpp/Toolbar.cpp \
-       src/cpp/SetUimenuLabel.cpp src/cpp/GetUimenuLabel.cpp \
-       src/cpp/GetUicontrolStyle.cpp src/cpp/SetUicontrolString.cpp \
-       src/cpp/GetUicontrolString.cpp src/cpp/SetUicontrolParent.cpp \
+       sci_gateway/c/sci_progressionbar.c \
+       sci_gateway/c/sci_helpbrowser.c src/cpp/InitUIMenu.cpp \
+       src/jni/CallScilabBridge.cpp src/jni/Jxclick.cpp \
+       src/cpp/DestroyUIControl.cpp src/cpp/DestroyWaitBar.cpp \
+       src/cpp/CallJxclick.cpp src/jni/Jxgetmouse.cpp \
+       src/cpp/CallJxgetmouse.cpp src/cpp/CallFileChooser.cpp \
+       src/cpp/CallFigure.cpp src/cpp/CallMessageBox.cpp \
+       src/cpp/CallWaitBar.cpp src/cpp/CallHelpBrowser.cpp \
+       src/cpp/PushButton.cpp src/cpp/EditBox.cpp src/cpp/Label.cpp \
+       src/cpp/CheckBox.cpp src/cpp/RadioButton.cpp \
+       src/cpp/Slider.cpp src/cpp/PopupMenu.cpp \
+       src/cpp/ContextMenu.cpp src/cpp/ListBox.cpp src/cpp/Frame.cpp \
+       src/cpp/Toolbar.cpp src/cpp/SetUimenuLabel.cpp \
+       src/cpp/GetUimenuLabel.cpp src/cpp/GetUicontrolStyle.cpp \
+       src/cpp/SetUicontrolString.cpp src/cpp/GetUicontrolString.cpp \
+       src/cpp/SetUicontrolParent.cpp \
        src/cpp/SetUicontrolBackgroundColor.cpp \
        src/cpp/GetUicontrolBackgroundColor.cpp \
        src/cpp/SetUiobjectForegroundColor.cpp \
@@ -211,7 +212,7 @@ am__libscigui_la_SOURCES_DIST = src/nogui/nogui.c \
 @GUI_TRUE@     libscigui_la-sci_messagebox.lo \
 @GUI_TRUE@     libscigui_la-sci_waitbar.lo \
 @GUI_TRUE@     libscigui_la-sci_progressionbar.lo \
-@GUI_TRUE@     libscigui_la-sci_help.lo
+@GUI_TRUE@     libscigui_la-sci_helpbrowser.lo
 @GUI_TRUE@am__objects_3 = libscigui_la-InitUIMenu.lo \
 @GUI_TRUE@     libscigui_la-CallScilabBridge.lo \
 @GUI_TRUE@     libscigui_la-Jxclick.lo \
@@ -678,7 +679,7 @@ JARMASK = *.jar
 @GUI_TRUE@sci_gateway/c/sci_messagebox.c \
 @GUI_TRUE@sci_gateway/c/sci_waitbar.c \
 @GUI_TRUE@sci_gateway/c/sci_progressionbar.c \
-@GUI_TRUE@sci_gateway/c/sci_help.c
+@GUI_TRUE@sci_gateway/c/sci_helpbrowser.c
 
 @GUI_FALSE@libscigui_la_CFLAGS = -Iincludes/ \
 @GUI_FALSE@                    -I$(top_srcdir)/modules/output_stream/includes
@@ -1000,7 +1001,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigui_la-sci_delmenu.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigui_la-sci_getinstalledlookandfeels.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigui_la-sci_getlookandfeel.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigui_la-sci_help.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigui_la-sci_helpbrowser.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigui_la-sci_messagebox.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigui_la-sci_mpopup.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigui_la-sci_progressionbar.Plo@am__quote@
@@ -1339,12 +1340,12 @@ libscigui_la-sci_progressionbar.lo: sci_gateway/c/sci_progressionbar.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigui_la_CPPFLAGS) $(CPPFLAGS) $(libscigui_la_CFLAGS) $(CFLAGS) -c -o libscigui_la-sci_progressionbar.lo `test -f 'sci_gateway/c/sci_progressionbar.c' || echo '$(srcdir)/'`sci_gateway/c/sci_progressionbar.c
 
-libscigui_la-sci_help.lo: sci_gateway/c/sci_help.c
-@am__fastdepCC_TRUE@   $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigui_la_CPPFLAGS) $(CPPFLAGS) $(libscigui_la_CFLAGS) $(CFLAGS) -MT libscigui_la-sci_help.lo -MD -MP -MF $(DEPDIR)/libscigui_la-sci_help.Tpo -c -o libscigui_la-sci_help.lo `test -f 'sci_gateway/c/sci_help.c' || echo '$(srcdir)/'`sci_gateway/c/sci_help.c
-@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/libscigui_la-sci_help.Tpo $(DEPDIR)/libscigui_la-sci_help.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_help.c' object='libscigui_la-sci_help.lo' libtool=yes @AMDEPBACKSLASH@
+libscigui_la-sci_helpbrowser.lo: sci_gateway/c/sci_helpbrowser.c
+@am__fastdepCC_TRUE@   $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigui_la_CPPFLAGS) $(CPPFLAGS) $(libscigui_la_CFLAGS) $(CFLAGS) -MT libscigui_la-sci_helpbrowser.lo -MD -MP -MF $(DEPDIR)/libscigui_la-sci_helpbrowser.Tpo -c -o libscigui_la-sci_helpbrowser.lo `test -f 'sci_gateway/c/sci_helpbrowser.c' || echo '$(srcdir)/'`sci_gateway/c/sci_helpbrowser.c
+@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/libscigui_la-sci_helpbrowser.Tpo $(DEPDIR)/libscigui_la-sci_helpbrowser.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_helpbrowser.c' object='libscigui_la-sci_helpbrowser.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigui_la_CPPFLAGS) $(CPPFLAGS) $(libscigui_la_CFLAGS) $(CFLAGS) -c -o libscigui_la-sci_help.lo `test -f 'sci_gateway/c/sci_help.c' || echo '$(srcdir)/'`sci_gateway/c/sci_help.c
+@am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigui_la_CPPFLAGS) $(CPPFLAGS) $(libscigui_la_CFLAGS) $(CFLAGS) -c -o libscigui_la-sci_helpbrowser.lo `test -f 'sci_gateway/c/sci_helpbrowser.c' || echo '$(srcdir)/'`sci_gateway/c/sci_helpbrowser.c
 
 .cpp.o:
 @am__fastdepCXX_TRUE@  $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
index 8eaaa4a..f41a82c 100644 (file)
 
 /**
  * Launch a Scilab Help Browser
+ *
+ * @param helps help chapters and directories
+ * @param helpsSize number of entries in helps
  */
-void launchHelpBrowser(void);
+void launchHelpBrowser(char **helps, int helpsSize);
 
 /**
  * Search a keyword in Scilab Help Browser
  *
+ * @param helps help chapters and directories
+ * @param helpsSize number of entries in helps
  * @param keyword the keyword to search
  */
-BOOL searchKeyword(char *keyword);
+BOOL searchKeyword(char **helps, int helpsSize, char *keyword);
 
 #endif /* !__CALLHELPBROWSER_H__ */
 
index eebf8a2..a09f09a 100644 (file)
@@ -42,7 +42,7 @@ int sci_uiwait(char *fname,unsigned long l);
 int sci_messagebox(char *fname,unsigned long l);
 int sci_waitbar(char *fname,unsigned long l);
 int sci_progressionbar(char *fname,unsigned long l);
-int sci_help(char *fname,unsigned long l);
+int sci_helpbrowser(char *fname,unsigned long l);
 /*--------------------------------------------------------------------------*/
 #endif /*  __GW_GUI__ */
 /*--------------------------------------------------------------------------*/
index 013134d..2326c7c 100644 (file)
@@ -45,7 +45,7 @@ static gw_generic_table Tab[]=
        {sci_messagebox,"messagebox"},
        {sci_waitbar,"waitbar"},
        {sci_progressionbar,"progressionbar"},
-       {sci_help,"jhelp"}
+       {sci_helpbrowser,"helpbrowser"}
 };
 /*--------------------------------------------------------------------------*/
 int gw_gui(void)
diff --git a/scilab/modules/gui/sci_gateway/c/sci_help.c b/scilab/modules/gui/sci_gateway/c/sci_help.c
deleted file mode 100644 (file)
index 70da3cc..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#include "gw_gui.h"
-#include "machine.h"
-#include "stack-c.h"
-#include "localization.h"
-#include "CallHelpBrowser.h"
-#include "Scierror.h"
-#include "getPropertyAssignedValue.h"
-
-/*--------------------------------------------------------------------------*/
-int sci_help(char *fname,unsigned long fname_len)
-{
-  int nbRow = 0, nbCol = 0, keywordAdr = 0;
-  
-  CheckRhs(0,1);
-  CheckLhs(0,1);
-
-  if (Rhs == 0)
-    {
-      //launchHelpBrowser();
-    }
-  else
-    {
-      if (VarType(1) == sci_strings)
-        {
-          GetRhsVar(1, MATRIX_OF_STRING_DATATYPE, &nbRow, &nbCol, &keywordAdr);
-          if (nbRow*nbCol != 1)
-            {
-              Scierror(999, _("%s: Wrong size for first input argument: Single string expected.\n"), "help");
-              return FALSE;
-            }
-        }
-      else
-        {
-          Scierror(999, _("%s: Wrong type for first input argument: Single string expected.\n"), "help");
-          return FALSE;
-        }
-      
-      //if (!searchKeyword(getStringMatrixFromStack(keywordAdr)[0])) {
-      //  sciprint(_("Could not find help page for function: %s.\n"),getStringMatrixFromStack(keywordAdr)[0]);
-      //}
-    }
-  
-  LhsVar(1) = 0;
-    
-  PutLhsVar();
-
-  return TRUE;
-
-}
-/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/gui/sci_gateway/c/sci_helpbrowser.c b/scilab/modules/gui/sci_gateway/c/sci_helpbrowser.c
new file mode 100644 (file)
index 0000000..a2687d6
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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    
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "gw_gui.h"
+#include "machine.h"
+#include "stack-c.h"
+#include "localization.h"
+#include "CallHelpBrowser.h"
+#include "Scierror.h"
+#include "getPropertyAssignedValue.h"
+
+/*--------------------------------------------------------------------------*/
+int sci_helpbrowser(char *fname,unsigned long fname_len)
+{
+  int nbRow = 0, nbCol = 0, keywordAdr = 0;
+  int nbRowHelp = 0, nbColHelp = 0, helpAdr = 0;
+  
+  CheckRhs(1,2);
+  CheckLhs(0,1);
+
+  if (Rhs == 1)
+    {
+      if (VarType(1) == sci_strings)
+        {
+          GetRhsVar(1, MATRIX_OF_STRING_DATATYPE, &nbRowHelp, &nbColHelp, &helpAdr);
+        }
+      else
+        {
+          Scierror(999, _("%s: Wrong type for first input argument: String matrix expected.\n"), "helpbrowser");
+          return FALSE;
+        }
+
+      launchHelpBrowser(getStringMatrixFromStack(helpAdr), nbRowHelp*nbColHelp);
+    }
+  else
+    {
+      if (VarType(1) == sci_strings)
+        {
+          GetRhsVar(1, MATRIX_OF_STRING_DATATYPE, &nbRowHelp, &nbColHelp, &helpAdr);
+        }
+      else
+        {
+          Scierror(999, _("%s: Wrong type for first input argument: Single matrix expected.\n"), "helpbrowser");
+          return FALSE;
+        }
+
+      if (VarType(2) == sci_strings)
+        {
+          GetRhsVar(2, MATRIX_OF_STRING_DATATYPE, &nbRow, &nbCol, &keywordAdr);
+          if (nbRow*nbCol != 1)
+            {
+              Scierror(999, _("%s: Wrong size for second input argument: Single string expected.\n"), "helpbrowser");
+              return FALSE;
+            }
+        }
+      else
+        {
+          Scierror(999, _("%s: Wrong type for first second argument: Single string expected.\n"), "helpbrowser");
+          return FALSE;
+        }
+      
+      if (!searchKeyword(getStringMatrixFromStack(helpAdr), nbRowHelp*nbColHelp, getStringMatrixFromStack(keywordAdr)[0])) {
+        sciprint(_("Could not find help page for function: %s.\n"),getStringMatrixFromStack(keywordAdr)[0]);
+      }
+    }
+  
+  LhsVar(1) = 0;
+    
+  PutLhsVar();
+
+  return TRUE;
+
+}
+/*--------------------------------------------------------------------------*/
index 2266a26..3f3ce3a 100644 (file)
@@ -55,5 +55,5 @@
 <PRIMITIVE gatewayId="25" primitiveId="22" primitiveName="messagebox" />
 <PRIMITIVE gatewayId="25" primitiveId="23" primitiveName="waitbar" />
 <PRIMITIVE gatewayId="25" primitiveId="24" primitiveName="progressionbar" />
-<PRIMITIVE gatewayId="25" primitiveId="25" primitiveName="jhelp" />
+<PRIMITIVE gatewayId="25" primitiveId="25" primitiveName="helpbrowser" />
 </GATEWAY>
\ No newline at end of file
index e5d7be5..586fdcb 100644 (file)
                                >
                        </File>
                        <File
-                               RelativePath="..\..\sci_gateway\c\sci_help.c"
+                               RelativePath="..\..\sci_gateway\c\sci_helpbrowser.c"
                                >
                        </File>
                        <File
index 9337200..8414eb3 100644 (file)
 
 using namespace org_scilab_modules_gui_bridge;
 
-void launchHelpBrowser()
+void launchHelpBrowser(char **helps, int helpsSize)
 {
-  CallScilabBridge::launchHelpBrowser(getScilabJavaVM());
+  CallScilabBridge::launchHelpBrowser(getScilabJavaVM(), helps, helpsSize);
 }
 
-BOOL searchKeyword(char *keyword)
+BOOL searchKeyword(char **helps, int helpsSize, char *keyword)
 {
-  return CallScilabBridge::searchKeyword(getScilabJavaVM(), keyword);
+  return CallScilabBridge::searchKeyword(getScilabJavaVM(), helps, helpsSize, keyword);
 }
index 17fcf4c..550b207 100644 (file)
@@ -1842,18 +1842,20 @@ public class CallScilabBridge {
        
        /**
         * Launch Scilab help browser if not already created
+        * @param helps help chapters and directories
         */
-       public static void launchHelpBrowser() {
-               ScilabHelpBrowser.createHelpBrowser();
+       public static void launchHelpBrowser(String[] helps) {
+               ScilabHelpBrowser.createHelpBrowser(helps);
        }
        
        /**
         * Search a keyword in Scilab Help Browser
         * @param keyword the keyword to search
+        * @param helps help chapters and directories
         * @return true if the keyword is a function name
         */
-       public static boolean searchKeyword(String keyword) {
-               return ScilabHelpBrowser.createHelpBrowser().searchKeywork(keyword);
+       public static boolean searchKeyword(String[] helps, String keyword) {
+               return ScilabHelpBrowser.createHelpBrowser(helps).searchKeywork(keyword);
        }
 
        /**
index 2059654..eb2b63b 100644 (file)
@@ -4131,10 +4131,11 @@ public class ScilabBridge {
 
        /**
         * Create a new Help Browser
+        * @param helps help chapters and directories
         * @return the created Help Browser
         */
-       public static SimpleHelpBrowser createHelpBrowser() {
-               return ScilabHelpBrowserBridge.createHelpBrowser();
+       public static SimpleHelpBrowser createHelpBrowser(String[] helps) {
+               return ScilabHelpBrowserBridge.createHelpBrowser(helps);
        }
 
        /**
index 80fb79d..80edef6 100644 (file)
@@ -36,13 +36,22 @@ public class SwingScilabHelpBrowser extends JHelp implements SimpleHelpBrowser {
 
     /**
         * Constructor
-        */
-       public SwingScilabHelpBrowser() {
-               super();
-
-        File[] jarFiles = new File[1];
-        jarFiles[0] = new File(System.getenv("SCI") + "/thirdparty/scilab_help.jar");
-        for (int i = 0; i < jarFiles.length; ++i) {
+        * @param helps help chapters and directories
+        */             
+       public SwingScilabHelpBrowser(String[] helps) {
+               super();        
+                       
+               /* First half of helps is directories list */
+               /* Second half of helps is chapters titles */
+               
+           File[] jarFiles = new File[helps.length / 2];
+           for (int k = 0; k < helps.length; k++) {
+                       System.out.println("Loading help from: " + helps[k]);
+                       jarFiles[k] =  new File(helps[k] + "scilab_help.jar");
+               }
+           this.setModel(new DefaultHelpModel(new HelpSet()));
+        
+           for (int i = 0; i < jarFiles.length; ++i) {
             URI jarURI = jarFiles[i].toURI();
 
             StringBuilder buffer = new StringBuilder("jar:");
@@ -65,8 +74,10 @@ public class SwingScilabHelpBrowser extends JHelp implements SimpleHelpBrowser {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
-            this.setModel(new DefaultHelpModel(helpSet));
+            //this.setModel(new DefaultHelpModel(helpSet));
+                       this.getModel().getHelpSet().add(helpSet);
         }
+
        }
        
        /**
index c62e14a..5fe5a6e 100644 (file)
@@ -42,18 +42,20 @@ public class ScilabHelpBrowser extends ScilabDockable implements HelpBrowser {
 
        /**
         * Constructor
+        * @param helps help chapters and directories
         */
-       protected ScilabHelpBrowser() {
-               component = ScilabBridge.createHelpBrowser();
+       protected ScilabHelpBrowser(String[] helps) {
+               component = ScilabBridge.createHelpBrowser(helps);
        }
 
        /**
         * Creates a Scilab Help Browser
+        * @param helps help chapters and directories
         * @return the created Help Browser
         */
-       public static HelpBrowser createHelpBrowser() {
+       public static HelpBrowser createHelpBrowser(String[] helps) {
                if (instance == null) {
-                       instance = new ScilabHelpBrowser();
+                       instance = new ScilabHelpBrowser(helps);
                        helpTab = ScilabTab.createTab("Help Browser");
                        helpTab.addMember(instance);
                        helpTab.setCallback(ScilabCallBack
@@ -86,10 +88,11 @@ public class ScilabHelpBrowser extends ScilabDockable implements HelpBrowser {
         * @return the console
         */
        public static HelpBrowser getHelpBrowser() {
-               if (instance == null) {
-                       instance = new ScilabHelpBrowser();
-               }
-               return instance;
+               throw new UnsupportedOperationException();
+//             if (instance == null) {
+//                     instance = new ScilabHelpBrowser();
+//             }
+//             return instance;
        }
        
        /**
index 9ca2ca7..e5c5d58 100644 (file)
@@ -28,10 +28,11 @@ public class ScilabHelpBrowserBridge {
 
        /**
         * Creates a Scilab HelpBrowser
+        * @param helps help chapters and directories
         * @return the created HelpBrowser
         */
-       public static SimpleHelpBrowser createHelpBrowser() {
-               return new SwingScilabHelpBrowser();
+       public static SimpleHelpBrowser createHelpBrowser(String[] helps) {
+               return new SwingScilabHelpBrowser(helps);
        }
 
        /**
index 3b085ab..f054e91 100644 (file)
@@ -233,8 +233,8 @@ voidsetWaitBarMessagejintjobjectArrayID=NULL;
 voidsetWaitBarValuejintjintID=NULL; 
 voiddestroyWaitBarjintID=NULL; 
 voidsetWaitBarIndeterminateModejintjbooleanID=NULL; 
-voidlaunchHelpBrowserID=NULL; 
-jbooleansearchKeywordjstringID=NULL; 
+voidlaunchHelpBrowserjobjectArrayID=NULL; 
+jbooleansearchKeywordjobjectArrayjstringID=NULL; 
 
 
 }
@@ -391,8 +391,8 @@ voidsetWaitBarMessagejintjobjectArrayID=NULL;
 voidsetWaitBarValuejintjintID=NULL; 
 voiddestroyWaitBarjintID=NULL; 
 voidsetWaitBarIndeterminateModejintjbooleanID=NULL; 
-voidlaunchHelpBrowserID=NULL; 
-jbooleansearchKeywordjstringID=NULL; 
+voidlaunchHelpBrowserjobjectArrayID=NULL; 
+jbooleansearchKeywordjobjectArrayjstringID=NULL; 
 
 
 }
@@ -3820,48 +3820,100 @@ curEnv->ExceptionDescribe() ;
                         
 }
 
-void CallScilabBridge::launchHelpBrowser (JavaVM * jvm_){
+void CallScilabBridge::launchHelpBrowser (JavaVM * jvm_, char ** helps, int helpsSize){
 
 JNIEnv * curEnv = NULL;
 jvm_->AttachCurrentThread((void **) &curEnv, NULL);
 jclass cls = curEnv->FindClass( className().c_str() );
 
-jmethodID voidlaunchHelpBrowserID = curEnv->GetStaticMethodID(cls, "launchHelpBrowser", "()V" ) ;
-if (voidlaunchHelpBrowserID == NULL) {
+jmethodID voidlaunchHelpBrowserjobjectArrayID = curEnv->GetStaticMethodID(cls, "launchHelpBrowser", "([Ljava/lang/String;)V" ) ;
+if (voidlaunchHelpBrowserjobjectArrayID == NULL) {
 std::cerr << "Could not access to the method " << "launchHelpBrowser" << std::endl;
 exit(EXIT_FAILURE);
 }
+jclass stringArrayClass = curEnv->FindClass("Ljava/lang/String;");
+
+// create java array of strings.
+jobjectArray helps_ = curEnv->NewObjectArray( helpsSize, stringArrayClass, NULL);
+if (helps_ == NULL)
+{
+std::cerr << "Could not allocate Java string array, memory full." << std::endl;
+exit(EXIT_FAILURE);
+}
+
+// convert each char * to java strings and fill the java array.
+for ( int i = 0; i < helpsSize; i++)
+{
+jstring TempString = curEnv->NewStringUTF( helps[i] );
+if (TempString == NULL)
+{
+std::cerr << "Could not convert C string to Java UTF string, memory full." << std::endl;
+exit(EXIT_FAILURE);
+}
+
+curEnv->SetObjectArrayElement( helps_, i, TempString);
 
-                         curEnv->CallStaticVoidMethod(cls, voidlaunchHelpBrowserID );
+// avoid keeping reference on to many strings
+curEnv->DeleteLocalRef(TempString);
+}
+                         curEnv->CallStaticVoidMethod(cls, voidlaunchHelpBrowserjobjectArrayID ,helps_);
                         
 if (curEnv->ExceptionOccurred()) {
 curEnv->ExceptionDescribe() ;
 }
 
-                        
+                        curEnv->DeleteLocalRef(stringArrayClass);
+curEnv->DeleteLocalRef(helps_);
+
 }
 
-bool CallScilabBridge::searchKeyword (JavaVM * jvm_, char * keyword){
+bool CallScilabBridge::searchKeyword (JavaVM * jvm_, char ** helps, int helpsSize, char * keyword){
 
 JNIEnv * curEnv = NULL;
 jvm_->AttachCurrentThread((void **) &curEnv, NULL);
 jclass cls = curEnv->FindClass( className().c_str() );
 
-jmethodID jbooleansearchKeywordjstringID = curEnv->GetStaticMethodID(cls, "searchKeyword", "(Ljava/lang/String;)Z" ) ;
-if (jbooleansearchKeywordjstringID == NULL) {
+jmethodID jbooleansearchKeywordjobjectArrayjstringID = curEnv->GetStaticMethodID(cls, "searchKeyword", "([Ljava/lang/String;Ljava/lang/String;)Z" ) ;
+if (jbooleansearchKeywordjobjectArrayjstringID == NULL) {
 std::cerr << "Could not access to the method " << "searchKeyword" << std::endl;
 exit(EXIT_FAILURE);
 }
+jclass stringArrayClass = curEnv->FindClass("Ljava/lang/String;");
+
+// create java array of strings.
+jobjectArray helps_ = curEnv->NewObjectArray( helpsSize, stringArrayClass, NULL);
+if (helps_ == NULL)
+{
+std::cerr << "Could not allocate Java string array, memory full." << std::endl;
+exit(EXIT_FAILURE);
+}
+
+// convert each char * to java strings and fill the java array.
+for ( int i = 0; i < helpsSize; i++)
+{
+jstring TempString = curEnv->NewStringUTF( helps[i] );
+if (TempString == NULL)
+{
+std::cerr << "Could not convert C string to Java UTF string, memory full." << std::endl;
+exit(EXIT_FAILURE);
+}
+
+curEnv->SetObjectArrayElement( helps_, i, TempString);
 
+// avoid keeping reference on to many strings
+curEnv->DeleteLocalRef(TempString);
+}
 jstring keyword_ = curEnv->NewStringUTF( keyword );
 
-                        jboolean res =  (jboolean) curEnv->CallStaticBooleanMethod(cls, jbooleansearchKeywordjstringID ,keyword_);
+                        jboolean res =  (jboolean) curEnv->CallStaticBooleanMethod(cls, jbooleansearchKeywordjobjectArrayjstringID ,helps_, keyword_);
                         
 if (curEnv->ExceptionOccurred()) {
 curEnv->ExceptionDescribe() ;
 }
 
-                        
+                        curEnv->DeleteLocalRef(stringArrayClass);
+curEnv->DeleteLocalRef(helps_);
+
 return (res == JNI_TRUE);
 
 }
index 2493e09..b4cb8bc 100644 (file)
           <parameter type="boolean" name="status"/>
         </method>
 <!-- Help Browser -->
-       <method name="launchHelpBrowser" returnType="void" modifier="static"/>      
+       <method name="launchHelpBrowser" returnType="void" modifier="static">
+          <parameter type="String[]" name="helps"/>
+        </method>      
         <method name="searchKeyword" returnType="boolean" modifier="static">
+          <parameter type="String[]" name="helps"/>
           <parameter type="String" name="keyword"/>
         </method>
   </object>
index bb532a5..8cc0937 100644 (file)
@@ -184,8 +184,8 @@ jmethodID voidsetWaitBarMessagejintjobjectArrayID; // cache method id
 jmethodID voidsetWaitBarValuejintjintID; // cache method id
 jmethodID voiddestroyWaitBarjintID; // cache method id
 jmethodID voidsetWaitBarIndeterminateModejintjbooleanID; // cache method id
-jmethodID voidlaunchHelpBrowserID; // cache method id
-jmethodID jbooleansearchKeywordjstringID; // cache method id
+jmethodID voidlaunchHelpBrowserjobjectArrayID; // cache method id
+jmethodID jbooleansearchKeywordjobjectArrayjstringID; // cache method id
 
 
 /**
@@ -489,9 +489,9 @@ static void destroyWaitBar(JavaVM * jvm_, long objID);
 
 static void setWaitBarIndeterminateMode(JavaVM * jvm_, long objID, bool status);
 
-static void launchHelpBrowser(JavaVM * jvm_);
+static void launchHelpBrowser(JavaVM * jvm_, char ** helps, int helpsSize);
 
-static bool searchKeyword(JavaVM * jvm_, char * keyword);
+static bool searchKeyword(JavaVM * jvm_, char ** helps, int helpsSize, char * keyword);
 
 
                         /**
index 855fd03..45b3e1b 100644 (file)
@@ -25,6 +25,9 @@ function help(key)
                        INDEX=make_help_index()
                        
                        if argn(2)==0 then
+                               //global %helps
+                               //allChapters = %helps;
+                               //helpbrowser(allChapters);
                                browsehelp(INDEX,"index");
                                return
                        end
@@ -40,6 +43,9 @@ function help(key)
                        
                        if path<>[] then
                                browsehelp(path,key)
+                               //global %helps
+                               //allChapters = %helps;
+                               //helpbrowser(allChapters, key);
                        else
                                apropos(key)
                        end