Bug 11349 fixed: There was an error when path to external editor contained white... 38/7738/2
Calixte DENIZET [Thu, 28 Jun 2012 09:38:18 +0000 (11:38 +0200)]
Change-Id: I19a9f7e667ec9de2f8c5be052c3c169fd1cc71ca

scilab/CHANGES_5.4.X
scilab/modules/commons/src/java/org/scilab/modules/commons/OS.java
scilab/modules/preferences/src/java/org/scilab/modules/preferences/XCommonManager.java
scilab/modules/scinotes/etc/XConfiguration-scinotes.xml
scilab/modules/scinotes/etc/XConfiguration-scinotes.xsl
scilab/modules/scinotes/macros/editor.sci

index 805dc6a..21b95c4 100644 (file)
@@ -18,6 +18,8 @@ Bug Fixes
 * Bug #11360 fixed - In some help pages, f in calling sequence was named mtx in 
                      the parameter section.
 
+* Bug #11349 fixed - There was an error when path to external editor contained
+                     white spaces.
 
 
             Changes between version 5.4.0-alpha-1 and 5.4.0-beta-1 of Scilab
index 9ab9cce..d52e458 100644 (file)
@@ -17,52 +17,63 @@ package org.scilab.modules.commons;
  * Operating Systems utility class
  */
 public enum OS {
-       WINDOWS {
-               /**
-                * {@inheritDoc}
-                */
-               @Override
-               public Object getVersion() {
-                       return Double.valueOf(System.getProperty("os.version"));
-               }
-       },
-       MAC {
-               /**
-                * {@inheritDoc}
-                */
-               @Override
-               public Object getVersion() {
-                       final String[] numbers = System.getProperty("os.version").split(
-                                       "\\.");
+    WINDOWS {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+            public Object getVersion() {
+            return Double.valueOf(System.getProperty("os.version"));
+        }
+    },
+        MAC {
+            /**
+             * {@inheritDoc}
+             */
+            @Override
+                public Object getVersion() {
+                final String[] numbers = System.getProperty("os.version").split(
+                    "\\.");
 
-                       int[] ret = new int[numbers.length];
-                       for (int i = 0; i < numbers.length; i++) {
-                               ret[i] = Integer.parseInt(numbers[i]);
-                       }
-                       return ret;
-               }
-       },
-       UNIX;
+                int[] ret = new int[numbers.length];
+                for (int i = 0; i < numbers.length; i++) {
+                    ret[i] = Integer.parseInt(numbers[i]);
+                }
+                return ret;
+            }
+        },
+            UNIX;
 
-       /**
-        * @return the OS type
-        */
-       public static OS get() {
-               final String name = System.getProperty("os.name").toLowerCase();
+            /**
+             * @return the OS type
+             */
+            public static OS get() {
+                final String name = System.getProperty("os.name").toLowerCase();
 
-               if (name.contains("windows")) {
-                       return OS.WINDOWS;
-               } else if (name.contains("mac")) {
-                       return MAC;
-               } else {
-                       return UNIX;
-               }
-       }
+                if (name.contains("windows")) {
+                    return OS.WINDOWS;
+                } else if (name.contains("mac")) {
+                    return MAC;
+                } else {
+                    return UNIX;
+                }
+            }
 
-       /**
-        * @return the OS version
-        */
-       public Object getVersion() {
-               return null;
-       }
+            /**
+             * @return the OS version
+             */
+            public Object getVersion() {
+                return null;
+            }
+
+            public static String getVersionName() {
+                switch (get()) {
+                case WINDOWS:
+                    return "Windows";
+                case MAC:
+                    return "Mac";
+                default:
+                    return "Linux";
+                }
+            }
 }
index 442aec1..e5968d1 100644 (file)
@@ -62,6 +62,7 @@ import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
 import org.scilab.modules.localization.Messages;
+import org.scilab.modules.commons.OS;
 import org.scilab.modules.commons.ScilabCommons;
 import org.scilab.modules.commons.xml.ScilabDocumentBuilderFactory;
 import org.scilab.modules.commons.xml.ScilabTransformerFactory;
@@ -298,6 +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:import href=\"").append(SCI).append("/modules/preferences/src/xslt/XConfiguration.xsl").append("\"/>\n");
 
             FilenameFilter filter = new FilenameFilter() {
@@ -356,6 +358,7 @@ public abstract class XCommonManager {
         try {
             StreamSource source = new StreamSource(new StringReader(createXSLFile()));
             transformer = factory.newTransformer(source);
+           transformer.setParameter("OS", OS.getVersionName());
         } catch (TransformerConfigurationException e1) {
             System.err.println(ERROR_READ + address);
         } catch (TransformerFactoryConfigurationError e1) {
index b796e67..c8803d4 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <scinotes title="SciNotes">
   <body>
-    <scinotes-preferences restart-reopen="true" add-line-termination="true" number-of-recently-open="5" encoding="utf-8" eol="Unix (LF)" scinotes="true" cmd="" external-cmd="true"/>
+    <scinotes-preferences restart-reopen="true" add-line-termination="true" number-of-recently-open="5" encoding="utf-8" eol="Unix (LF)" scinotes="true" cmd="" macro="" external-cmd="true"/>
   </body>
   <display title="Display">
     <body>
index cea137e..ff6f538 100644 (file)
@@ -31,7 +31,8 @@
           <FileSelector gridx="2" gridy="1" weightx="1" anchor="above_baseline"\r
                         listener="EntryListener"\r
                         href="{@cmd}"\r
-                        dir-selection="false">\r
+                        dir-selection="false"\r
+                        check-entry="false">\r
             <xsl:attribute name="enable">\r
               <xsl:if test="@scinotes='false' and @external-cmd='true'">\r
                 <xsl:text>true</xsl:text>\r
               <xsl:call-template name="context"/>\r
             </entryChanged>\r
           </FileSelector>\r
-          <Radiobutton value="{@external-cmd}" expected-value="false" listener="ActionListener" text="Scilab command: " gridx="1" gridy="2" fill="none" weightx="0" anchor="west" enable="{$enable}">\r
+          <Label gridx="2" gridy="2" text="(Don't forget to quote path containing white spaces)">\r
+            <xsl:attribute name="enable">\r
+              <xsl:if test="@scinotes='false' and @external-cmd='true'">\r
+                <xsl:text>true</xsl:text>\r
+              </xsl:if>\r
+            </xsl:attribute>\r
+          </Label>\r
+          <Panel height="5" gridx="1" gridy="3">\r
+            <VSpace height="5"/>\r
+          </Panel>\r
+          <Radiobutton value="{@external-cmd}" expected-value="false" listener="ActionListener" text="Scilab command: " gridx="1" gridy="4" fill="none" weightx="0" anchor="west" enable="{$enable}">\r
             <actionPerformed choose="external-cmd">\r
               <xsl:call-template name="context"/>\r
             </actionPerformed>\r
           </Radiobutton>\r
-          <Entry gridx="2" gridy="2" weightx="1" anchor="above_baseline"\r
+          <Entry gridx="2" gridy="4" weightx="1" anchor="above_baseline"\r
                  listener="EntryListener"\r
-                 text="{@cmd}">\r
+                 text="{@macro}">\r
             <xsl:attribute name="enable">\r
               <xsl:if test="@scinotes='false' and @external-cmd='false'">\r
                 <xsl:text>true</xsl:text>\r
   <xsl:template match="scinotes-autosave">\r
     <Checkbox checked="{@enable}" selected-value="true" unselected-value="false" listener="ActionListener" text="Enable autosave in Scinotes">\r
       <actionPerformed choose="enable">\r
-       <xsl:call-template name="context"/>\r
+        <xsl:call-template name="context"/>\r
       </actionPerformed>\r
-    </Checkbox>   \r
+    </Checkbox>\r
     <VSpace height="10"/>\r
     <Title text="Save options">\r
       <Grid>\r
-       <Label gridx="1" gridy="1" weightx="0" anchor="west" text="Save every " enable="{@enable}"/>\r
+        <Label gridx="1" gridy="1" weightx="0" anchor="west" text="Save every " enable="{@enable}"/>\r
         <NumericalSpinner gridx="2"\r
                           gridy="1"\r
                           weightx="0"\r
                           increment = "1"\r
                           length = "4"\r
                           listener = "ActionListener"\r
-                         enable = "{@enable}"\r
+                          enable = "{@enable}"\r
                           value = "{@save-every}">\r
           <actionPerformed choose="save-every">\r
             <xsl:call-template name="context"/>\r
           </actionPerformed>\r
         </NumericalSpinner>\r
-       <Label gridx="3" gridy="1" weightx="0" anchor="west" text=" minutes " enable="{@enable}"/>\r
+        <Label gridx="3" gridy="1" weightx="0" anchor="west" text=" minutes " enable="{@enable}"/>\r
         <Panel gridx="4" gridy="1" gridheight="1" fill="both"/>\r
-       </Grid>\r
+      </Grid>\r
     </Title>\r
     <VSpace height="10"/>\r
     <Title text="Close options">\r
       <Checkbox checked="{@automatic-delete}" selected-value="true" unselected-value="false" listener="ActionListener" text="Delete automatically saved files" enable="{@enable}">\r
-       <actionPerformed choose="automatic-delete">\r
-         <xsl:call-template name="context"/>\r
-       </actionPerformed>\r
+        <actionPerformed choose="automatic-delete">\r
+          <xsl:call-template name="context"/>\r
+        </actionPerformed>\r
       </Checkbox>\r
     </Title>\r
     <VSpace height="10"/>\r
     </Title>\r
   </xsl:template>\r
 </xsl:stylesheet>\r
-\r
index 0af1dc6..cfea480 100644 (file)
@@ -26,7 +26,7 @@ function editor(varargin)
         end\r
         unix_w(cmd);\r
     else\r
-        cmd = makeCommand(prefsNode.attributes.cmd, varargin);\r
+        cmd = makeCommand(prefsNode.attributes.macro, varargin);\r
         xmlDelete(doc);\r
         execstr(cmd);\r
     end\r