Prefs: add a function preferences() 51/7651/5
Calixte DENIZET [Thu, 21 Jun 2012 10:36:39 +0000 (12:36 +0200)]
Change-Id: I394684a8cc4623ab27427f045bc9b96bddde42b5

23 files changed:
scilab/CHANGES_5.4.X
scilab/modules/helptools/etc/MAIN_CHAPTERS
scilab/modules/preferences/Makefile.am
scilab/modules/preferences/Makefile.in
scilab/modules/preferences/help/en_US/addchapter.sce [new file with mode: 0644]
scilab/modules/preferences/help/en_US/preferences.xml [new file with mode: 0644]
scilab/modules/preferences/help/en_US/prefs_SciNotes.xml [new file with mode: 0644]
scilab/modules/preferences/help/images/scinotes/editor.png [new file with mode: 0644]
scilab/modules/preferences/help/images/scinotes/scinotes_general_settings.png [new file with mode: 0644]
scilab/modules/preferences/includes/gw_preferences.h
scilab/modules/preferences/sci_gateway/c/gw_preferences.c
scilab/modules/preferences/sci_gateway/cpp/sci_preferences.cpp [new file with mode: 0644]
scilab/modules/preferences/sci_gateway/preferences_gateway.xml
scilab/modules/preferences/src/c/preferences.vcxproj
scilab/modules/preferences/src/c/preferences.vcxproj.filters
scilab/modules/preferences/src/java/org/scilab/modules/preferences/Component/PreviewCode.java
scilab/modules/preferences/src/java/org/scilab/modules/preferences/ComponentFactory.java
scilab/modules/preferences/src/java/org/scilab/modules/preferences/ScilabPreferences.java
scilab/modules/preferences/src/java/org/scilab/modules/preferences/XCommonManager.java
scilab/modules/preferences/src/java/org/scilab/modules/preferences/XConfigManager.java
scilab/modules/preferences/src/jni/ScilabPreferences.cpp
scilab/modules/preferences/src/jni/ScilabPreferences.giws.xml
scilab/modules/preferences/src/jni/ScilabPreferences.hxx

index 21b95c4..d1dba72 100644 (file)
@@ -8,6 +8,11 @@ Xcos
 * Bug #9496 fixed - Xcos flag 5 (ending) was not called if simulation is
                     stopped from user interface.
 
+Preferences
+===========
+
+* Add a function preferences() to open the Preferences window.
+
 
 Bug Fixes
 =========
index f4f0edc..6a8b31a 100644 (file)
@@ -72,3 +72,4 @@ intersci
 graph
 commons
 types
+preferences
\ No newline at end of file
index 9bfcff5..6ca5677 100644 (file)
@@ -53,7 +53,8 @@ PREFERENCES_C_SOURCES = src/c/getScilabPreference.c
 GATEWAY_C_SOURCES = sci_gateway/c/gw_preferences.c
 
 GATEWAY_CXX_SOURCES = sci_gateway/cpp/sci_addModulePreferences.cpp \
-                      sci_gateway/cpp/sci_removeModulePreferences.cpp
+                      sci_gateway/cpp/sci_removeModulePreferences.cpp \
+                      sci_gateway/cpp/sci_preferences.cpp
 
 libscipreferences_la_CPPFLAGS = $(JAVA_JNI_INCLUDE) \
     -I$(srcdir)/includes/ \
index 771a768..3c1f3c1 100644 (file)
@@ -144,7 +144,8 @@ libscipreferences_cli_la_OBJECTS =  \
 libscipreferences_la_DEPENDENCIES = libscipreferences-algo.la
 am__objects_3 = libscipreferences_la-gw_preferences.lo
 am__objects_4 = libscipreferences_la-sci_addModulePreferences.lo \
-       libscipreferences_la-sci_removeModulePreferences.lo
+       libscipreferences_la-sci_removeModulePreferences.lo \
+       libscipreferences_la-sci_preferences.lo
 am__objects_5 = libscipreferences_la-ScilabPreferences.lo
 am_libscipreferences_la_OBJECTS = $(am__objects_3) $(am__objects_4) \
        $(am__objects_5)
@@ -484,7 +485,8 @@ PREFERENCES_JNI_SOURCES = src/jni/ScilabPreferences.cpp
 PREFERENCES_C_SOURCES = src/c/getScilabPreference.c
 GATEWAY_C_SOURCES = sci_gateway/c/gw_preferences.c
 GATEWAY_CXX_SOURCES = sci_gateway/cpp/sci_addModulePreferences.cpp \
-                      sci_gateway/cpp/sci_removeModulePreferences.cpp
+                      sci_gateway/cpp/sci_removeModulePreferences.cpp \
+                      sci_gateway/cpp/sci_preferences.cpp
 
 libscipreferences_la_CPPFLAGS = $(JAVA_JNI_INCLUDE) \
     -I$(srcdir)/includes/ \
@@ -701,6 +703,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscipreferences_la-ScilabPreferences.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscipreferences_la-gw_preferences.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscipreferences_la-sci_addModulePreferences.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscipreferences_la-sci_preferences.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscipreferences_la-sci_removeModulePreferences.Plo@am__quote@
 
 .c.o:
@@ -780,6 +783,13 @@ libscipreferences_la-sci_removeModulePreferences.lo: sci_gateway/cpp/sci_removeM
 @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) $(libscipreferences_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscipreferences_la-sci_removeModulePreferences.lo `test -f 'sci_gateway/cpp/sci_removeModulePreferences.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_removeModulePreferences.cpp
 
+libscipreferences_la-sci_preferences.lo: sci_gateway/cpp/sci_preferences.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscipreferences_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscipreferences_la-sci_preferences.lo -MD -MP -MF $(DEPDIR)/libscipreferences_la-sci_preferences.Tpo -c -o libscipreferences_la-sci_preferences.lo `test -f 'sci_gateway/cpp/sci_preferences.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_preferences.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscipreferences_la-sci_preferences.Tpo $(DEPDIR)/libscipreferences_la-sci_preferences.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_preferences.cpp' object='libscipreferences_la-sci_preferences.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) $(libscipreferences_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscipreferences_la-sci_preferences.lo `test -f 'sci_gateway/cpp/sci_preferences.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_preferences.cpp
+
 libscipreferences_la-ScilabPreferences.lo: src/jni/ScilabPreferences.cpp
 @am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscipreferences_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscipreferences_la-ScilabPreferences.lo -MD -MP -MF $(DEPDIR)/libscipreferences_la-ScilabPreferences.Tpo -c -o libscipreferences_la-ScilabPreferences.lo `test -f 'src/jni/ScilabPreferences.cpp' || echo '$(srcdir)/'`src/jni/ScilabPreferences.cpp
 @am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscipreferences_la-ScilabPreferences.Tpo $(DEPDIR)/libscipreferences_la-ScilabPreferences.Plo
diff --git a/scilab/modules/preferences/help/en_US/addchapter.sce b/scilab/modules/preferences/help/en_US/addchapter.sce
new file mode 100644 (file)
index 0000000..dbe8a8a
--- /dev/null
@@ -0,0 +1,10 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises
+//
+// 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
+
+add_help_chapter("Preferences",SCI+"/modules/preferences/help/en_US",%T);
\ No newline at end of file
diff --git a/scilab/modules/preferences/help/en_US/preferences.xml b/scilab/modules/preferences/help/en_US/preferences.xml
new file mode 100644 (file)
index 0000000..8d46967
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Sylvestre KOUMAR
+ *
+ * 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
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:id="preferences" xml:lang="en">
+  <refnamediv>
+    <refname>preferences</refname>
+    <refpurpose>Open the Scilab Preferences window</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <title>Calling Sequence</title>
+    <synopsis>
+      preferences()
+    </synopsis>
+  </refsynopsisdiv>
+  <refsection>
+    <title>Description</title>
+    <para>
+      Open Scilab Preferences window. 
+    </para>
+  </refsection>
+  <refsection role="see also">
+    <title>See Also</title>
+    <simplelist type="inline">
+      <member>
+        <link linkend="scinotes">scinotes</link>
+      </member>
+    </simplelist>
+  </refsection>
+</refentry>
diff --git a/scilab/modules/preferences/help/en_US/prefs_SciNotes.xml b/scilab/modules/preferences/help/en_US/prefs_SciNotes.xml
new file mode 100644 (file)
index 0000000..7c66710
--- /dev/null
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+*
+* 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
+*
+-->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:id="prefs_SciNotes" xml:lang="en">
+  <refnamediv>
+    <refname>SciNotes preferences</refname>
+    <refpurpose>SciNotes general preferences</refpurpose>
+  </refnamediv>
+  <refsection id="prefs_SciNotes_Editor">
+    <title>Editor</title>
+    <para>
+      <inlinemediaobject>
+        <imageobject>
+          <imagedata fileref="../images/scinotes/editor.png" width="100" depth="100" scalefit="0" align="center" valign="middle"/>
+        </imageobject>
+      </inlinemediaobject>
+    </para>
+    <para>
+      SciNotes is the default Scilab code editor. It is now possible to use an external editor using a system dependant command or a Scilab macro name.
+    </para>
+    <para>
+      <itemizedlist>
+        <listitem>
+          <para>
+            <emphasis role="bold">Use SciNotes</emphasis>: check this box if you want to use SciNotes in using commands such like editor or edit.
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            <emphasis role="bold">External editor</emphasis>: check this radio button to use an external system editor, e.g. it is possible to enter "/usr/bin/gedit".
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            <emphasis role="bold">Scilab command</emphasis>: check this radio button to use an editor which is callable via a Scilab macro. This macro should take the same kind of argument as the editor command.
+          </para>
+        </listitem>
+      </itemizedlist>
+    </para>
+  </refsection>
+  <refsection id="prefs_SciNotes_General_Settings">
+    <title>SciNotes General settings</title>
+    <para>
+      <inlinemediaobject>
+        <imageobject>
+          <imagedata fileref="../images/scinotes/scinotes_general_settings.png" width="100" depth="100" scalefit="0" align="center" valign="middle"/>
+        </imageobject>
+      </inlinemediaobject>
+    </para>
+    <para>
+      <itemizedlist>
+        <listitem>
+          <para>
+            <emphasis role="bold">Restore previous session on start-up</emphasis>: check this box to be able to restore the previous Scilab session as it was before quiting Scilab.
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            <emphasis role="bold">Add carriage return at the end of the file</emphasis>: check this box to automatically add a CR, if none, at the end of the file.
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            <emphasis role="bold">Number of recently opened files to display</emphasis>: modify this value to fix how many files must appears in the last opened section.
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            <emphasis role="bold">Default file enconding</emphasis>: fix the default encoding to use to save a file. No more encodings are proposed since Scilab handles only these ones at execution.
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            <emphasis role="bold">Default End-Of-Line</emphasis>: fix the default end-of-line chars to use when saving the file.
+          </para>
+        </listitem>
+      </itemizedlist>
+    </para>
+  </refsection>
+  <refsection role="see also">
+    <title>See Also</title>
+    <simplelist type="inline">
+      <member>
+        <link linkend="scinotes">scinotes</link>
+      </member>
+      <member>
+        <link linkend="editor">editor</link>
+      </member>
+      <member>
+        <link linkend="edit">edit</link>
+      </member>
+    </simplelist>
+  </refsection>
+</refentry>
diff --git a/scilab/modules/preferences/help/images/scinotes/editor.png b/scilab/modules/preferences/help/images/scinotes/editor.png
new file mode 100644 (file)
index 0000000..e48c4ad
Binary files /dev/null and b/scilab/modules/preferences/help/images/scinotes/editor.png differ
diff --git a/scilab/modules/preferences/help/images/scinotes/scinotes_general_settings.png b/scilab/modules/preferences/help/images/scinotes/scinotes_general_settings.png
new file mode 100644 (file)
index 0000000..3a52f64
Binary files /dev/null and b/scilab/modules/preferences/help/images/scinotes/scinotes_general_settings.png differ
index 6dfb0c2..76d97e9 100644 (file)
@@ -1,11 +1,11 @@
 /*
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2011 - DIGITEO - Calixte DENIZET
-* 
+*
 * 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
 *
 */
@@ -18,6 +18,7 @@
 PREFERENCES_SCILAB_IMPEXP int gw_preferences(void);
 int sci_addModulePreferences(char * fname, unsigned long l);
 int sci_removeModulePreferences(char * fname, unsigned long l);
+int sci_preferences(char * fname, unsigned long l);
 /*--------------------------------------------------------------------------*/
 #endif /* __GW_PREFERENCES__ */
 /*--------------------------------------------------------------------------*/
index 1c355a3..265d0c2 100644 (file)
 /*--------------------------------------------------------------------------*/
 static BOOL loadedDep = FALSE;
 /*--------------------------------------------------------------------------*/
-static gw_generic_table Tab[]=
+static gw_generic_table Tab[] =
 {
     {sci_addModulePreferences, "addModulePreferences"},
-    {sci_removeModulePreferences, "removeModulePreferences"}
+    {sci_removeModulePreferences, "removeModulePreferences"},
+    {sci_preferences, "preferences"}
 };
 /*--------------------------------------------------------------------------*/
 int gw_preferences(void)
@@ -34,7 +35,7 @@ int gw_preferences(void)
 
     if ( getScilabMode() == SCILAB_NWNI)
     {
-        Scierror(999,_("Scilab '%s' module disabled in -nogui or -nwni mode.\n"), "preferences");
+        Scierror(999, _("Scilab '%s' module disabled in -nogui or -nwni mode.\n"), "preferences");
         return 0;
     }
 
diff --git a/scilab/modules/preferences/sci_gateway/cpp/sci_preferences.cpp b/scilab/modules/preferences/sci_gateway/cpp/sci_preferences.cpp
new file mode 100644 (file)
index 0000000..d3544ae
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - DIGITEO - Calixte DENIZET
+ *
+ * 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 "ScilabPreferences.hxx"
+#include "GiwsException.hxx"
+
+extern "C"
+{
+#include "gw_preferences.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "localization.h"
+#include "getScilabJavaVM.h"
+}
+
+using namespace org_scilab_modules_preferences;
+
+/*--------------------------------------------------------------------------*/
+int sci_preferences(char * fname, unsigned long fname_len)
+{
+    CheckRhs(0, 0);
+    CheckLhs(0, 1);
+
+    try
+    {
+        ScilabPreferences::openPreferences(getScilabJavaVM());
+    }
+    catch (const GiwsException::JniException & e)
+    {
+        Scierror(999, _("An error occurend in opening Preferences window: "), fname, e.getJavaDescription().c_str());
+    }
+
+    LhsVar(1) = 0;
+    PutLhsVar();
+
+    return 0;
+}
index 6a14972..648e396 100644 (file)
@@ -2,8 +2,8 @@
 
 <!DOCTYPE GATEWAY SYSTEM "../../functions/xml/gateway.dtd">
 <GATEWAY name="preferences">
-<!-- =================== -->
-<!--
+  <!-- =================== -->
+  <!--
  Scilab
  Interface description. In this file, we define the list of the function which
  will be available into Scilab and the link to the "native" function.
@@ -21,7 +21,8 @@
  ===================
  Don't touch if you do not know what you are doing
 -->
-<!-- =================== -->
-<PRIMITIVE gatewayId="69" primitiveId="1" primitiveName="addModulePreferences" />
-<PRIMITIVE gatewayId="69" primitiveId="2" primitiveName="removeModulePreferences" />
+  <!-- =================== -->
+  <PRIMITIVE gatewayId="69" primitiveId="1" primitiveName="addModulePreferences" />
+  <PRIMITIVE gatewayId="69" primitiveId="2" primitiveName="removeModulePreferences" />
+  <PRIMITIVE gatewayId="69" primitiveId="3" primitiveName="preferences" />
 </GATEWAY>
index 49f255e..2f3e368 100644 (file)
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\sci_gateway\cpp\sci_addModulePreferences.cpp" />
+    <ClCompile Include="..\..\sci_gateway\cpp\sci_preferences.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_removeModulePreferences.cpp" />
     <ClCompile Include="..\..\sci_gateway\c\gw_preferences.c" />
     <ClCompile Include="..\jni\ScilabPreferences.cpp" />
index a3c2f3d..6968f75 100644 (file)
@@ -54,6 +54,9 @@
     <ClCompile Include="getScilabPreference.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\sci_gateway\cpp\sci_preferences.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\jni\ScilabPreferences.hxx">
index 11e5e41..83d50b6 100644 (file)
@@ -24,6 +24,7 @@ import javax.swing.text.DefaultCaret;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import org.scilab.modules.commons.ScilabCommonsUtils;
 import org.scilab.modules.preferences.XChooser;
 import org.scilab.modules.preferences.XComponent;
 import org.scilab.modules.preferences.XConfigManager;
index e4dc051..dc24670 100644 (file)
@@ -30,6 +30,7 @@ import javax.swing.border.TitledBorder;
 
 import org.w3c.dom.Node;
 
+import org.scilab.modules.commons.ScilabCommonsUtils;
 import org.scilab.modules.preferences.Component.Scroll;
 
 /**
@@ -84,6 +85,10 @@ class ComponentFactory {
 
         Constructor constructor = cache.get(tag);
         if (constructor == null) {
+            if ("PreviewCode".equals(tag)) {
+                ScilabCommonsUtils.loadOnUse("SciNotes");
+            }
+
             Class<Component> componentClass;
             try {
                 componentClass = (Class<Component>) Class.forName(X_PACKAGE + tag);
index db2d2e8..ad0b9af 100644 (file)
@@ -18,10 +18,11 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.swing.SwingUtilities;
+
 import org.scilab.modules.localization.Messages;
 
 /**
- * Class to get the toolboxes informations
  * @author Calixte DENIZET
  */
 public class ScilabPreferences {
@@ -29,6 +30,17 @@ public class ScilabPreferences {
     private static Map<String, ToolboxInfos> tbxs = new HashMap<String, ToolboxInfos>();
 
     /**
+     * Open the preferences window
+     */
+    public static void openPreferences() {
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                XConfigManager.openPreferences();
+            }
+        });
+    }
+
+    /**
      * @param name the toolbox name
      * @param path the toolbox path
      * @param prefFile the toolbox preference file path
index e5968d1..e95f195 100644 (file)
@@ -299,7 +299,7 @@ public abstract class XCommonManager {
 
             StringBuilder buffer = new StringBuilder("<?xml version='1.0' encoding='utf-8'?>\n");
             buffer.append("<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n");
-           buffer.append("<xsl:param name=\"OS\"/>\n");
+            buffer.append("<xsl:param name=\"OS\"/>\n");
             buffer.append("<xsl:import href=\"").append(SCI).append("/modules/preferences/src/xslt/XConfiguration.xsl").append("\"/>\n");
 
             FilenameFilter filter = new FilenameFilter() {
@@ -358,7 +358,7 @@ public abstract class XCommonManager {
         try {
             StreamSource source = new StreamSource(new StringReader(createXSLFile()));
             transformer = factory.newTransformer(source);
-           transformer.setParameter("OS", OS.getVersionName());
+            transformer.setParameter("OS", OS.getVersionName());
         } catch (TransformerConfigurationException e1) {
             System.err.println(ERROR_READ + address);
         } catch (TransformerFactoryConfigurationError e1) {
@@ -721,8 +721,12 @@ public abstract class XCommonManager {
      * @return top-level frame.
      */
     public static Frame getTopLevel() {
-        Container main = (Container) ScilabConsole.getConsole().getAsSimpleConsole();
-        return (Frame) SwingUtilities.getAncestorOfClass(Frame.class, main);
+        if (ScilabConsole.isExistingConsole()) {
+            Container main = (Container) ScilabConsole.getConsole().getAsSimpleConsole();
+            return (Frame) SwingUtilities.getAncestorOfClass(Frame.class, main);
+        }
+
+        return null;
     }
 
     /**
index 8beb468..345fda0 100644 (file)
@@ -87,9 +87,10 @@ public final class XConfigManager extends XCommonManager {
         XWizardManager.active = false;
 
         reloadTransformer(SCILAB_CONFIG_XSL);
+        Frame topWindow = XCommonManager.getTopLevel();
 
         // Set up Swing Side
-        dialog = new JDialog(getTopLevel(), "Scilab Preferences", true);
+        dialog = new JDialog(topWindow, "Scilab Preferences", true);
         topSwing = dialog.getContentPane();
         topSwing.setLayout(new BorderLayout());
         // AWT implies to set layout at construction time.
@@ -127,10 +128,11 @@ public final class XConfigManager extends XCommonManager {
         // Let the show begin!
         if (refreshDisplay()) {
             // Center the dialog on the parent window
-            Frame topWindow = XCommonManager.getTopLevel();
-            int x = topWindow.getX() + (topWindow.getWidth() - dialog.getWidth()) / 2;
-            int y = topWindow.getY() + (topWindow.getHeight() - dialog.getHeight()) / 2;
-            dialog.setLocation(x, y);
+            if (topWindow != null) {
+                int x = topWindow.getX() + (topWindow.getWidth() - dialog.getWidth()) / 2;
+                int y = topWindow.getY() + (topWindow.getHeight() - dialog.getHeight()) / 2;
+                dialog.setLocation(x, y);
+            }
 
             dialog.setVisible(true);
         }
index ee6b79a..b14062b 100644 (file)
@@ -1,6 +1,6 @@
 #include "ScilabPreferences.hxx"
 /* Generated by GIWS (version 2.0.1) with command:
-giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabPreferences.giws.xml 
+giws -e -r -f ScilabPreferences.giws.xml 
 */
 /*
 
@@ -106,6 +106,7 @@ curEnv->DeleteLocalRef(localInstance);
                 /* Methods ID set to NULL */
 voidaddToolboxInfosjstringjava_lang_Stringjstringjava_lang_Stringjstringjava_lang_StringID=NULL;
 voidremoveToolboxInfosjstringjava_lang_StringID=NULL;
+voidopenPreferencesID=NULL;
 
 
 }
@@ -130,6 +131,7 @@ throw GiwsException::JniObjectCreationException(curEnv, this->className());
         /* Methods ID set to NULL */
         voidaddToolboxInfosjstringjava_lang_Stringjstringjava_lang_Stringjstringjava_lang_StringID=NULL;
 voidremoveToolboxInfosjstringjava_lang_StringID=NULL;
+voidopenPreferencesID=NULL;
 
 
 }
@@ -217,4 +219,22 @@ throw GiwsException::JniCallMethodException(curEnv);
 }
 }
 
+void ScilabPreferences::openPreferences (JavaVM * jvm_){
+
+JNIEnv * curEnv = NULL;
+jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID voidopenPreferencesID = curEnv->GetStaticMethodID(cls, "openPreferences", "()V" ) ;
+if (voidopenPreferencesID == NULL) {
+throw GiwsException::JniMethodNotFoundException(curEnv, "openPreferences");
+}
+
+                         curEnv->CallStaticVoidMethod(cls, voidopenPreferencesID );
+                        curEnv->DeleteLocalRef(cls);
+if (curEnv->ExceptionCheck()) {
+throw GiwsException::JniCallMethodException(curEnv);
+}
+}
+
 }
index e9b9f39..29df6d4 100644 (file)
@@ -1,12 +1,13 @@
 <package name="org.scilab.modules.preferences">
-    <object name="ScilabPreferences">
-        <method name="addToolboxInfos" returnType="void" modifier="static">
-           <parameter name="name" type="String"/>
-           <parameter name="path" type="String"/>
-           <parameter name="prefFile" type="String"/>
-        </method>
-       <method name="removeToolboxInfos" returnType="void" modifier="static">
-           <parameter name="path" type="String"/>
-        </method>
-    </object>
+  <object name="ScilabPreferences">
+    <method name="addToolboxInfos" returnType="void" modifier="static">
+      <parameter name="name" type="String"/>
+      <parameter name="path" type="String"/>
+      <parameter name="prefFile" type="String"/>
+    </method>
+    <method name="removeToolboxInfos" returnType="void" modifier="static">
+      <parameter name="path" type="String"/>
+    </method>
+    <method name="openPreferences" returnType="void" modifier="static" />
+  </object>
 </package>
index 6f2036a..44e152b 100644 (file)
@@ -1,5 +1,5 @@
 /* Generated by GIWS (version 2.0.1) with command:
-giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabPreferences.giws.xml 
+giws -e -r -f ScilabPreferences.giws.xml 
 */
 /*
 
@@ -78,6 +78,7 @@ JavaVM * jvm;
 protected:
 jmethodID voidaddToolboxInfosjstringjava_lang_Stringjstringjava_lang_Stringjstringjava_lang_StringID; // cache method id
 jmethodID voidremoveToolboxInfosjstringjava_lang_StringID; // cache method id
+jmethodID voidopenPreferencesID; // cache method id
 
 
 
@@ -141,6 +142,8 @@ static void addToolboxInfos(JavaVM * jvm_, char const* name, char const* path, c
 
 static void removeToolboxInfos(JavaVM * jvm_, char const* path);
 
+static void openPreferences(JavaVM * jvm_);
+
 
                         /**
                         * Get class name to use for static methods