Xcos: improve the error reporting to be Xcos only. 03/3803/9
Clément DAVID [Thu, 31 Mar 2011 09:09:34 +0000 (11:09 +0200)]
Errors: flow checking
type and size checking
Coserror reports

Fix setvalue.sci to reflect scicos_getvalue after ae58a748

Bug: 5444
Bug: 9336
Change-Id: I26a56c32677535b017435bbfb92e4ca98d480a27

64 files changed:
scilab/CHANGES_5.4.X
scilab/modules/scicos/macros/scicos_auto/scicos_simulate.sci
scilab/modules/scicos/macros/scicos_scicos/bad_connection.sci
scilab/modules/scicos/macros/scicos_scicos/c_pass2.sci
scilab/modules/scicos/macros/scicos_scicos/delete_unconnected.sci
scilab/modules/scicos/macros/scicos_scicos/do_delete1.sci
scilab/modules/scicos/macros/scicos_scicos/get_errorcmd.sci
scilab/modules/scicos/macros/scicos_scicos/hilite_modelica_block.sci
scilab/modules/scicos/macros/scicos_scicos/hilite_mult_objs.sci
scilab/modules/scicos/macros/scicos_scicos/hilite_obj.sci
scilab/modules/scicos/macros/scicos_scicos/hilite_path.sci
scilab/modules/scicos/macros/scicos_scicos/prt_align.sci
scilab/modules/scicos/macros/scicos_scicos/scicos_flat.sci
scilab/modules/scicos/macros/scicos_scicos/setvalue.sci
scilab/modules/scicos/macros/scicos_scicos/unhilite_modelica_block.sci
scilab/modules/scicos/macros/scicos_scicos/unhilite_obj.sci
scilab/modules/xcos/Makefile.am
scilab/modules/xcos/Makefile.in
scilab/modules/xcos/macros/closeDiagramPath.sci [deleted file]
scilab/modules/xcos/macros/errorDiagramPath.sci [deleted file]
scilab/modules/xcos/macros/openDiagramPath.sci [deleted file]
scilab/modules/xcos/macros/xcosClearBlockWarning.sci [deleted file]
scilab/modules/xcos/macros/xcosCodeGeneration.sci
scilab/modules/xcos/macros/xcos_close.sci [deleted file]
scilab/modules/xcos/macros/xcos_compile.sci
scilab/modules/xcos/macros/xcos_open.sci [deleted file]
scilab/modules/xcos/macros/xcos_simulate.sci
scilab/modules/xcos/sci_gateway/c/gw_xcos.c
scilab/modules/xcos/sci_gateway/cpp/sci_warnBlockByUID.cpp
scilab/modules/xcos/sci_gateway/cpp/sci_xcosDiagramClose.cpp [deleted file]
scilab/modules/xcos/sci_gateway/cpp/sci_xcosDiagramOpen.cpp [deleted file]
scilab/modules/xcos/sci_gateway/xcos_gateway.xml
scilab/modules/xcos/src/cpp/xcosUtilities.cpp
scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/BasicBlock.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/graph/XcosDiagram.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/BasicBlockInfo.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/BlockElement.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/DiagramElement.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/InputPortElement.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/LinkElement.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/OutputPortElement.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/link/BasicLink.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/port/BasicPort.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/XcosMessages.java
scilab/modules/xcos/src/jni/Xcos.cpp
scilab/modules/xcos/src/jni/Xcos.giws.xml
scilab/modules/xcos/src/jni/Xcos.hxx
scilab/modules/xcos/tests/nonreg_tests/bug_5444.tst
scilab/modules/xcos/tests/nonreg_tests/bug_5444.xcos
scilab/modules/xcos/tests/unit_tests/error_blocks_with_undefined_input.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_blocks_with_undefined_input_on_sb.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_from_without_goto.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_from_without_goto_on_sb.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_goto_same_tag.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_goto_same_tag_on_sb.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_on_block.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_port_block_on_diagram.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_ports_with_incompatible_size.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_ports_with_incompatible_size_on_sb.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_ports_with_negative_size.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_ports_with_negative_size_on_sb.xcos [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_reporting.tst [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/error_unconnected_sb_input.xcos [new file with mode: 0644]

index 66a4f8a..16252de 100644 (file)
@@ -37,6 +37,8 @@ Xcos:
 
 * xcos_skeleton will not be loaded if you have not installed Xcos.
 
+* Error reporting has been improved to print warnings on blocks into Xcos.
+
 * bug 8421 fixed - CLKFROM and CLKGOTO were not part of the "Signal Routing"
                    palette.
 
index 4c83aa8..020a43c 100644 (file)
@@ -253,7 +253,7 @@ function Info = scicos_simulate(scs_m, Info, updated_vars, flag, Ignb)
   if ierr == 0 then //++ no error
     [scs_m, %cpr, needcompile, ok] = do_eval(scs_m, %cpr,%scicos_context)
     if ~ok then
-      error(['Error during block parameters evaluation , ' + lasterror()])
+      error(msprintf(gettext("%s: Error during block parameters evaluation."), "scicos_simulate"));
     end
     if needcompile <> 4 & size(%cpr) > 0 then
       %state0 = %cpr.state
@@ -273,7 +273,7 @@ function Info = scicos_simulate(scs_m, Info, updated_vars, flag, Ignb)
                                                   %state0, needcompile)
 
   if ~ok then
-    error('Error updating parameters.')
+    error(msprintf(gettext("%s: Error during block parameters update."), "scicos_simulate"));
   end
 
   if or(%state0_n <> %state0) then //initial state has been changed
index eb6d37d..043c20e 100644 (file)
@@ -72,133 +72,60 @@ function bad_connection(path_out,prt_out,nout,outtyp,path_in,prt_in,nin,intyp,ty
     path_in=inports(prt_in)
   end
 
-  //** save the current figure handle
-  gh_wins = gcf();
-
-  if path_in==-1 then
-    //** hilite_obj(scs_m.objs(path_out)); //**
-    hilite_obj(path_out); //** new
-    if typ==0 then
-      messagebox([gettext("Highlighted block has connected ports<br />with incompatible sizes.")], gettext("Connection error"), "warning", "modal")
-
-    else
-      messagebox([gettext("Highlighted block has connected ports<br />with  incompatible types.")], gettext("Connection error"), "warning", "modal")
-    end
-    unhilite_obj(path_out); //** new
+  if type(path_out)==15 then //problem with implicit block
+    messagebox([gettext("Problem with the block generated from modelica blocks.")],"warning", "modal")
     return;
   end
 
-  //[lhs,rhs]=argn(0)
-  if prt_in <> -1 then  //two connected blocks
-    lp=min(size(path_out,'*'),size(path_in,'*'))
-    k=find(path_out(1:lp)<>path_in(1:lp))
-    path=path_out(1:k(1)-1) // common superbloc path
-    path_out=path_out(k(1)) // "from" block number
-    path_in=path_in(k(1))   // "to" block number
-
-    if path==[] then
-      //** hilite_obj(scs_m.objs(path_out)) //** set
-      hilite_obj(path_out); //**
-      if or(path_in<>path_out) then
-          //** hilite_obj(scs_m.objs(path_in))
-          hilite_obj(path_in)
-      end
 
-      if typ==0 then
-        messagebox([gettext("Highlighted block(s) have connected ports<br />with  incompatible sizes.");" "; ..
-          msprintf(gettext("&nbsp;Output port %s size is: %s"), string(prt_out), sci2exp(nout)); ..
-          msprintf(gettext("&nbsp;Input port %s size is: %s"), string(prt_in), sci2exp(nin))], gettext("Connection error"), "warning", "modal");
-      else
-        messagebox([gettext("Highlighted block(s) have connected ports<br />with  incompatible types.");" "; ..
-          msprintf(gettext("&nbsp;Output port %s type is: %s"),string(prt_out), sci2exp(outtyp)); ..
-          msprintf(gettext("&nbsp;Input port %s type is: %s"), string(prt_in), sci2exp(intyp))], gettext("Connection error"), "warning", "modal");
+// warn the output port block
+ if typ==0 then
+    msg = "<html><body>";
+    msg = msg + gettext("Block has connected output port<br />with incompatible size:");
+    msg = msg + "<ul>";
+    msg = msg + "<li>" + msprintf(gettext("Output port %s size is: %s"),string(prt_out), sci2exp(nout)) + "</li>";
+    if prt_in <> -1 then
+      msg = msg + "<li>" + msprintf(gettext("Input port %s size is: %s"),string(prt_in), sci2exp(nin)) + "</li>";
+    end
+    msg = msg + "</ul>";
+    msg = msg + "</body></html>";
+  else
+    msg = "<html><body>";
+    msg = gettext("Block has connected output port<br />with incompatible type.");
+    msg = msg + "<ul>";
+    msg = msg + "<li>" + msprintf(gettext("Output port %s type is: %s"),string(prt_out), sci2exp(outtyp)) + "</li>";
+    if prt_in <> -1 then
+      msg = msg + "<li>" + msprintf(gettext("Input port %s type is: %s"),string(prt_in), sci2exp(intyp)) + "</li>";
+    end
+    msg = msg + "</ul>";
+    msg = msg + "</body></html>";
+  end
+  
+  hilite_path(path_out, msg);
 
-      end
-      unhilite_obj(path_out);
-      if or(path_in<>path_out) then unhilite_obj(path_in),end
-      //** hilite_obj(scs_m.objs(path_out))
-      //** if or(path_in<>path_out) then hilite_obj(scs_m.objs(path_in)),end
+// warn the input port block
+  if prt_in <> -1 then
+    if typ==0 then
+      msg = "<html><body>";
+      msg = msg + gettext("Block has connected input port<br />with incompatible size:");
+      msg = msg + "<ul>";
+      msg = msg + "<li>" + msprintf(gettext("Output port %s size is: %s"),string(prt_out), sci2exp(nout)) + "</li>";
+      msg = msg + "<li>" + msprintf(gettext("Input port %s size is: %s"),string(prt_in), sci2exp(nin)) + "</li>";
+      msg = msg + "</ul>";
+      msg = msg + "</body></html>";
     else
-      mxwin=max(winsid())
-//*****************************************
-      for k=1:size(path,'*')
-       //** hilite_obj(scs_m.objs(path(k))) //**
-       hilite_obj(path(k)) ; //**
-       scs_m=scs_m.objs(path(k)).model.rpar;
-       scs_show(scs_m,mxwin+k)  //** WARNING !
-      end
-      //** hilite_obj(scs_m.objs(path_out)) //**
-      hilite_obj(path_out) ; //**
-      if or(path_in<>path_out) then
-        //** hilite_obj(scs_m.objs(path_in))
-        hilite_obj(path_in)
-      end
-//*****************************************
-      if typ==0 then
-        messagebox([gettext("Highlighted block(s) have connected ports<br />with  incompatible sizes.");" "; ..
-          msprintf(gettext("&nbsp; %s output port size is: %s"), string(prt_out), sci2exp(nout)); ..
-          msprintf(gettext("&nbsp; %s input port size is: %s"), string(prt_in), sci2exp(nin))], gettext("Connection error"), "warning", "modal");
-      else
-        messagebox([gettext("Highlighted block(s) have connected ports<br />with  incompatible types.");" "; ..
-          msprintf(gettext("&nbsp;Output port %s type is: %s"), string(prt_out), sci2exp(outtyp)); ..
-          msprintf(gettext("&nbsp;Input port %s type is: %s"), string(prt_in), sci2exp(intyp))], gettext("Connection error"), "warning", "modal");
-      end
-      for k=size(path,'*'):-1:1
-        //** select the mxwin+k window and get the handle
-        gh_del = scf(mxwin+k);
-        //** delete the window
-        delete(gh_del)
-        //xdel(mxwin+k) //** WARNING !
-      end
-
-      //** restore the active window
-      scf(gh_wins);
-
-      //scs_m=null()
-      //** unhilite_obj(scs_m.objs(path(1))) //** WARNING
-      unhilite_obj(path(1))
+      msg = "<html><body>";
+      msg = msg + gettext("Block has connected input port<br />with incompatible type:");
+      msg = msg + "<ul>";
+      msg = msg + "<li>" + msprintf(gettext("Output port %s type is: %s"),string(prt_out), sci2exp(outtyp)) + "</li>";
+      msg = msg + "<li>" + msprintf(gettext("Input port %s type is: %s"),string(prt_in), sci2exp(intyp)) + "</li>";
+      msg = msg + "</ul>";
+      msg = msg + "</body></html>";
     end
-  else // connected links do not verify block contraints
-    mess=prt_out;
-    if type(path_out)==15 then //problem with implicit block
-      messagebox([gettext("Problem with the block generated from modelica blocks.")],"warning", "modal")
-    else
-      path=path_out(1:$-1) // superbloc path
-      path_out=path_out($) //  block number
-      if path==[] then
-       //** hilite_obj(scs_m.objs(path_out)) ;//** set
-       hilite_obj(path_out) ;//** set
-       messagebox(mess,'modal')
-       //** hilite_obj(scs_m.objs(path_out)) //** clear
-        unhilite_obj(path_out) ;
-      else
-       mxwin=max(winsid())
-       for k=1:size(path,'*')
-         //** hilite_obj(scs_m.objs(path(k))) //**
-         hilite_obj(path(k)) ; //**
-         scs_m=scs_m.objs(path(k)).model.rpar;
-         scs_show(scs_m,mxwin+k) //**
-       end
-       //** hilite_obj(scs_m.objs(path_out)) //**
-       hilite_obj(path_out) ; //**
-       messagebox(mess,'modal')
-       for k=size(path,'*'):-1:1
-          //**WARNING: xdel(mxwin+k) //** delete (mxwin+k) graphic window
-          //** select the mxwin+k window and get the handle
-          gh_del = scf(mxwin+k);
-          //** delete the window
-          delete(gh_del)
-        end
-
-        //** restore the active window
-        scf(gh_wins);
 
-        //scs_m=null()
-        //** unhilite_obj(scs_m.objs(path(1))) //**
-        unhilite_obj(path(1))
-      end
+    if or(path_in<>path_out) then
+      hilite_path(path_in, msg)
     end
   end
-
-  
 endfunction
+
index dccf58e..dc4f3ff 100644 (file)
@@ -2029,6 +2029,27 @@ function [ok,bllst]=adjust_inout(bllst,connectmat)
   end
 endfunction
 
+function id = getBlockIds(path)
+    // Return a block id path from a block index path
+    //
+    // path: the path in the index form
+    // id: th path in the uid form
+    
+    scs_m; // check scs_m access
+    id=[];
+    
+    k = path(:);
+    for i = k
+        b = scs_m.objs(i);
+        if typeof(b) == "Block" &  size(scs_m.objs(i).doc) >= 1 then
+            id($ + 1) = scs_m.objs(i).doc(1);
+        end
+        if typeof(b.model.rpar) == "diagram" then
+           scs_m = b.model.rpar; 
+        end
+    end
+endfunction
+
 //19/01/07, Alan : under_connection show bad link and returns two dimensions now
 function ninnout=under_connection(path_out,prt_out,nout,path_in,prt_in,nin,flagg)
 // alert for badly connected blocks
@@ -2036,139 +2057,76 @@ function ninnout=under_connection(path_out,prt_out,nout,path_in,prt_in,nin,flagg
 // path_in  : Path of the "to block" in scs_m
 //!
 
-  //** save the current figure handle
-  gh_wins = gcf();
-
   if path_in==-1 then
-    hilite_obj(path_out);
-    messagebox(msprintf(_('One of this block''s outputs has a negative size.\n'+..
-            'Please check.')),"modal","error")
-    unhilite_obj(path_out);
+    msg = "<html><body>";
+    msg = msg + gettext("One of this block output has negative size.<br />Please check.");
+    msg = msg + "</body></html>";
+    hilite_path(path_out, msg);
     ninnout=0
     return
   end
 
   if path_in==-2 then
-    hilite_obj(path_out);
-    messagebox(msprintf(_('The input port #%d of this block have a negative size.\n'+..
-            'Please check.'),prt_out),"modal","error")
-    unhilite_obj(path_out);
+    msg = "<html><body>";
+    msg = msg + gettext("Block input has negative size:");
+    msg = msg + "<ul>";
+    msg = msg + "<li>" + msprintf(gettext("Input port %s size is: %s"), string(prt_out), sci2exp(nout)) + "</li>";
+    msg = msg + "</ul>";
+    msg = msg + "</body></html>";
+    hilite_path(path_out, msg);
     ninnout=0
     return
   end
 
-  lp=min(size(path_out,'*'),size(path_in,'*'))
-  k=find(path_out(1:lp)<>path_in(1:lp))
-  path=path_out(1:k(1)-1) // common superbloc path
-  if (k <> []) then
-    path_out=path_out(k(1)) // "from" block number
-    path_in=path_in(k(1))   // "to" block number
-  end
+// different use case (Unable to report on a non opened diagram)
   if isdef('Code_gene_run') then
-    mxwin=max(winsid())
-    path=path+1 // Consider locally compiled superblock as a superblock
-    for k=1:size(path,'*')
-      //hilite_obj(all_scs_m.objs(numk(k)))
-      hilite_obj(numk(k))
-      scs_m=all_scs_m.objs(numk(k)).model.rpar;
-      scs_show(scs_m,mxwin+k)
-    end
-    //hilite_obj(scs_m.objs(path_out))
-    hilite_obj(path_out)
-    //if or(path_in<>path_out) then hilite_obj(scs_m.objs(path_in)),end
-    if or(path_in<>path_out) then hilite_obj(path_in),end
-    mess=msprintf(_('Highlighted block(s) have connected ports \n'+..
-                   'with  sizes that cannot be determined by the context.\n'+..
-                   'What is the size of this link?'))
-
-    if flagg==1 then
-      ninnout=evstr(dialog(mess,'[1,1]'))
-    else 
-      ninnout=evstr(dialog(mess,'1'))
-    end
-             
-    for k=size(path,'*'):-1:1,
-      //** select the mxwin+k window and get the handle
-      gh_del = scf(mxwin+k);
-      //** delete the window
-      delete(gh_del)
-    end
-    //scs_m=null()
-    //unhilite_obj(all_scs_m.objs(numk(1)))
-
-    //** restore the active window
-    scf(gh_wins);
-
-    unhilite_obj(numk(1))
+    messagebox([gettext("Unable to report an error into a SuperBlock"); gettext("Please compile the diagram to report the error.")], "Compilation error", "error", "modal");
+    ninnout=0
+    return
+  end
+  
+  msg = "<html><body>";
+  if flagg==1 then
+    msg = msg + gettext("<em>Please update the diagram to avoid this warning.</em><br />Block output port has a non-determined size:");
+    msg = msg + "<ul>";
+    msg = msg + "<li>" + msprintf(gettext("Output port %s size is: %s"), string(prt_out), sci2exp(nout)) + "</li>";
+    msg = msg + "<li>" + msprintf(gettext("Input port %s size is: %s"), string(prt_in), sci2exp(nin)) + "</li>";
   else
-    if path==[] then
-      kk=path_out
-      if or(path_in<>path_out) then kk=[kk;path_in], end
-      if prt_in<>[] & prt_out<>[] then
-        if prt_in >0 & prt_out >0 then
-          if scs_m.objs(path_out).graphics.pout(prt_out) == ...
-              scs_m.objs(path_in).graphics.pin(prt_in) then 
-                kk=[kk;scs_m.objs(path_out).graphics.pout(prt_out)]
-          end
-        end
-      end
-      hilite_obj(kk)
-      if flagg==1 then
-       ninnout=evstr(dialog(['Highlighted block(s) have connected ports ';
-           'with  sizes that cannot be determined by the context';
-           'what is the size of this link'],'[1,1]'))
-      else
-       ninnout=evstr(dialog(['Highlighted block(s) have connected ports ';
-           'with  types that cannot be determined by the context';
-           'what is the size of this link'],'1'))
-      end
-      unhilite_obj(kk)
+    msg = msg + gettext("<em>Please update the diagram to avoid this warning.</em><br />Block output port has a non-determined type:");
+    msg = msg + "<ul>";
+    msg = msg + "<li>" + msprintf(gettext("Output port %s type."), string(prt_out)) + "</li>";
+    msg = msg + "<li>" + msprintf(gettext("Input port %s type."), string(prt_in)) + "</li>";
+  end
+  msg = msg + "</ul>";
+  msg = msg + "</body></html>";  
+  hilite_path(path_out, msg)
+  
+  if or(path_in<>path_out) then
+    msg = "<html><body>";
+    if flagg==1 then
+      msg = msg + gettext("<em>Please update the diagram to avoid this warning.</em><br />Block input port has a non-determined size:");
+      msg = msg + "<ul>";
+      msg = msg + "<li>" + msprintf(gettext("Output port %s size is: %s"), string(prt_out), sci2exp(nout)) + "</li>";
+      msg = msg + "<li>" + msprintf(gettext("Input port %s size is: %s"), string(prt_in), sci2exp(nin)) + "</li>";
     else
-      mxwin=max(winsid())
-      kk=[];
-      for k=1:size(path,'*')
-       //hilite_obj(scs_m.objs(path(k)))
-        hilite_obj(path(k))
-       scs_m=scs_m.objs(path(k)).model.rpar;
-       scs_show(scs_m,mxwin+k)
-      end
-      //hilite_obj(scs_m.objs(path_out))
-      kk=[path_out]
-      //if or(path_in<>path_out) then hilite_obj(scs_m.objs(path_in)),end
-      if or(path_in<>path_out) then kk=[kk;path_in], end
-      if prt_in<>[] & prt_out<>[] then
-        if prt_in >0 & prt_out >0 then
-          if scs_m.objs(path_out).graphics.pout(prt_out) == ...
-              scs_m.objs(path_in).graphics.pin(prt_in) then 
-                kk=[kk;scs_m.objs(path_out).graphics.pout(prt_out)]
-          end
-        end
-      end
-      hilite_obj(kk)
-      if flagg==1 then
-       ninnout=evstr(dialog(['Highlighted block(s) have connected ports ';
-           'with  sizes that cannot be determined by the context';
-           'what is the size of this link'],'[1,1]'))
-      else
-       ninnout=evstr(dialog(['Highlighted block(s) have connected ports ';
-           'with  types that cannot be determined by the context';
-           'what is the size of this link'],'1'))
-      end
-      
-      //for k=size(path,'*'):-1:1,xdel(mxwin+k),end //TOBEDONE
-      for k=size(path,'*'):-1:1,
-        //** select the mxwin+k window and get the handle
-        gh_del = scf(mxwin+k);
-        //** delete the window
-        delete(gh_del)
-      end
-      //scs_m=null()
-      //** restore the active window
-      scf(gh_wins);
-
-      //unhilite_obj(scs_m.objs(path(1)))
-      unhilite_obj(path(1))
+      msg = msg + gettext("<em>Please update the diagram to avoid this warning.</em><br />Block input port has a non-determined type:");
+      msg = msg + "<ul>";
+      msg = msg + "<li>" + msprintf(gettext("Output port %s type."), string(prt_out)) + "</li>";
+      msg = msg + "<li>" + msprintf(gettext("Input port %s type."), string(prt_in)) + "</li>";
     end
+    msg = msg + "</ul>";
+    msg = msg + "</body></html>";
+    hilite_path(path_in, msg)
+  end
+  
+  mess=msprintf(_('Highlighted block(s) have connected ports \n'+..
+           'with  sizes that cannot be determined by the context.\n'+..
+           'What is the size of this link?'))
+       
+  if flagg==1 then
+    ninnout=evstr(dialog(mess,'[1,1]'))
+  else 
+    ninnout=evstr(dialog(mess,'1'))
   end
 endfunction
 
index 6c5e8b7..6012598 100644 (file)
 
 function scs_m=delete_unconnected(scs_m);
 
-       n = lstsize(scs_m.objs);
+  n = lstsize(scs_m.objs);
 
-       if n==0 then
-               return
-       end ; //** exit point
-       
-       DEL=[];
-       DELL=[]
-       finish=%f
+  if n==0 then
+    return
+  end ; //** exit point
+  
+  DEL=[];
+  DELL=[]
+  finish=%f
 
-       while ~finish
-               finish = %t
-               for k=1:n  //loop on scs_m objects
-                       x = getfield(1,scs_m.objs(k))
-                       if x(1)=='Block' then
-                               if scs_m.objs(k).gui<>'SUM_f'&scs_m.objs(k).gui<>'SOM_f' then
-                                       if find(scs_m.objs(k).gui==['IFTHEL_f','ESELECT_f']) then
-                                               kk=[find(scs_m.objs(k).graphics.pein==0),find(scs_m.objs(k).graphics.pin==0)]
-                                               if kk<> []      // a synchro block is not active, remove it
-                                                       [scs_m,DEL1,DELL1]=do_delete1(scs_m,k,%f)
-                                                       DEL=[DEL DEL1]
-                                                       DELL=[DELL DELL1]
-                                                       finish=%f
-                                               end
-                                       else
-                                               kk=[find(scs_m.objs(k).graphics.pin==0)]
-                                               if kk<>[] then // at least one  input port is not connected delete the block
-                                                       if or(getfield(1,scs_m.objs(k).graphics)=="in_implicit") then
-                                                               if or(scs_m.objs(k).graphics.in_implicit(kk)<>"I") then 
-                                                                       [scs_m,DEL1,DELL1]=do_delete1(scs_m,k,%f)
-                                                                       DEL=[DEL DEL1]
-                                                                       DELL=[DELL DELL1]
-                                                                       finish=%f
-                                                               end
-                                                       else
-                                                               [scs_m,DEL1,DELL1]=do_delete1(scs_m,k,%f)
-                                                               DEL=[DEL DEL1]
-                                                               DELL=[DELL DELL1]
-                                                               finish=%f
-                                                       end
-                                               end
-                                       end
-                               end
-                       end
-               end
-       end
+  while ~finish
+    finish = %t
+    for k=1:n  //loop on scs_m objects
+      x = getfield(1,scs_m.objs(k))
+      if x(1)=='Block' then
+        if scs_m.objs(k).gui<>'SUM_f'&scs_m.objs(k).gui<>'SOM_f' then
+          if find(scs_m.objs(k).gui==['IFTHEL_f','ESELECT_f']) then
+            kk=[find(scs_m.objs(k).graphics.pein==0),find(scs_m.objs(k).graphics.pin==0)]
+            if kk<> [] // a synchro block is not active, remove it
+              [scs_m,DEL1,DELL1]=do_delete1(scs_m,k,%f)
+              DEL=[DEL DEL1]
+              DELL=[DELL DELL1]
+              finish=%f
+            end
+          else
+            kk=[find(scs_m.objs(k).graphics.pin==0)]
+            if kk<>[] then // at least one  input port is not connected delete the block
+              if or(getfield(1,scs_m.objs(k).graphics)=="in_implicit") then
+                if or(scs_m.objs(k).graphics.in_implicit(kk)<>"I") then 
+                  [scs_m,DEL1,DELL1]=do_delete1(scs_m,k,%f)
+                  DEL=[DEL DEL1]
+                  DELL=[DELL DELL1]
+                  finish=%f
+                end
+              else
+                [scs_m,DEL1,DELL1]=do_delete1(scs_m,k,%f)
+                DEL=[DEL DEL1]
+                DELL=[DELL DELL1]
+                finish=%f
+              end
+            end
+          end
+        end
+      end
+    end
+  end
 
-       //suppress rigth-most deleted elements
-       while getfield(1,scs_m.objs($))=='Deleted' then
-               scs_m.objs($)=null();
-               if lstsize(scs_m.objs)==0 then 
-                       break
-               end
-       end
-       // Notify by hiliting and message edition
-       if DEL<>[] then
-               //** save the current scs_m structure
-               scs_save = scs_m;
-               scs_m = scs_m_s;
-               if flgcdgen <> -1 then //no idea !
-                       path=[numk path];
-                       scs_m=all_scs_m;
-               end
-               
-               // Blouno : Remove that check for errors to show up.
-               //if path<>[] then //** super block case
-                       //** entity in the current figure
-                       k=DEL
-                       //** find any indices of k which are not in DELL
-                       ind_k=find(k<>DELL)
-                       if ind_k<>[] then
-                               k=k(ind_k)
-                               msg = ['Highlighted block(s) or link(s) are ignored because of'
-                                       'undefined input(s)'];
-                       else
-                               msg = '';
-                       end
-                       
-                       //errorDiagramPath(path, [path_out, path_in], msg, "", %t);
-                       errorDiagramPath(path, k, msg, "", %f, %t);
-               //end
-               //** restore original scs_m structure
-               scs_m = scs_save;
-       end
+  //suppress rigth-most deleted elements
+  while getfield(1,scs_m.objs($))=='Deleted' then
+    scs_m.objs($)=null();
+    if lstsize(scs_m.objs)==0 then 
+      break
+    end
+  end
+
+  // Notify by hiliting and message
+  if DEL<>[] then
+    // ind_del are deleted and not relinked blocks/links indexes of DEL
+    if DELL <> [] then
+      deleted = DEL(find(DEL<>DELL));
+    else
+      deleted = DEL;
+    end
+    
+    // Store updated scs_m and retrieve the previous one
+    scs_save = scs_m;
+    scs_m = scs_m_s;
+
+    msg = gettext('Block is ignored because of undefined input(s).');
+    for del=deleted
+      hilite_path([path del], msg);
+    end
+    
+    // Restore the updated scs_m
+    scs_m = scs_save;
+  end
 endfunction
+
index 9301f62..d8651d9 100644 (file)
@@ -20,9 +20,6 @@
 //
 
 function [scs_m,DEL,DELL]=do_delete1(scs_m,K,gr)
-  // any old scicos macros, will be removed on 5.4.0
-  warnobsolete(scilabRemovedVersion="5.4.0")
-
 //!
 //
 //**  30 August 2007 :
@@ -33,7 +30,6 @@ function [scs_m,DEL,DELL]=do_delete1(scs_m,K,gr)
 //
 // Perform deletion of scs_m object whose index are given in the vector
 // K and all other relevant objects (link, splits,..)
-// if gr==%t objects are also graphicaly erased.
 //
 // deleted objects:
 //  - are replaced by the value : mlist('Deleted')
@@ -41,8 +37,6 @@ function [scs_m,DEL,DELL]=do_delete1(scs_m,K,gr)
 //
 //**  Perform deletion of [scs_m] object whose index are given in the vector
 //**  [K] and all other relevant objects (link, splits,..) in recursive way
-//**
-//**  If gr==%t objects are also graphicaly erased.
 //
 //**  Deleted objects are replaced by the value : mlist('Deleted')
 //**  ---> not to change the indexing:
@@ -68,13 +62,6 @@ function [scs_m,DEL,DELL]=do_delete1(scs_m,K,gr)
   DELL= [] // table of redefined links
   outin = ['out','in']
 
-  //** Acquire the current clicked window 
-  //gh_curwin = scf(%win) ;
-  gh_axes = gca(); 
-  o_size = size(gh_axes.children) ; //** o_size(1) is the number of compound object
-                                    //** at the beginning of this operation
-                                   //** this variable is very important for the selective
-                                   //** elimination of undesired object(s)
 //**   Delete object until "K" is empty
 //** ----------------------------------------------------------------------------------------------
 while K<>[] do
@@ -171,11 +158,7 @@ while K<>[] do
            DEL = [DEL connected(1)] // supress one link
            DELL=[DELL  connected(1)]
            scs_m.objs(connected(2))=o1 //change link
-           if gr==%t then
-             gr_k = get_gri(connected(2), o_size(1)) ; 
-             gh_object = gh_axes.children(gr_k);
-             gh_object.children.data = [o1.xx , o1.yy];
-            end
+           
            scs_m.objs(to2(1))=mark_prt(scs_m.objs(to2(1)),to2(2),outin(to2(3)+1),ct2(2),..
                                        connected(2))
            scs_m.objs(o1.from(1))=mark_prt(scs_m.objs(o1.from(1)),o1.from(2),..
@@ -223,11 +206,6 @@ while K<>[] do
            DEL=[DEL connected(1)] // supress one link
            DELL=[DELL  connected(1)]
            scs_m.objs(connected(2))=o1 //change link
-           if gr==%t then
-              gr_k = get_gri(connected(2),o_size(1)) ; 
-             gh_object = gh_axes.children(gr_k)     ;
-             gh_object.children.data = [o1.xx , o1.yy];
-            end
 
            scs_m.objs(to1(1))=mark_prt(scs_m.objs(to1(1)),..
                                        to1(2),outin(to1(3)+1),o1.ct(2),connected(2))
@@ -267,26 +245,11 @@ while K<>[] do
 end //** ... end of while ()
 //**---------------------------------- end of main while() loop ---------------------------
 
-//** Show the results if the "gr" flag is TRUE: go in drawlater() mode 
-  if gr==%t then
-    drawlater(); 
-  end
 
 //** Scan all the deleted elements and update the graphics datastrucure 
   for k = DEL
     scs_m.objs(k) = mlist('Deleted'); //** mark the object as "Deleted" 
-    if gr==%t then //** .... and the graphics 
-      gr_k = get_gri(k,o_size(1)) ;
-      gh_object_invisible = gh_axes.children(gr_k);
-      gh_object_invisible.visible = "off";
-    end
-  end
-
-//** Show the results if the "gr" flag is TRUE 
-  if gr==%t then
-    drawnow(); 
   end
-  
 endfunction
 
 
index fcf9bbd..d87f550 100644 (file)
@@ -99,49 +99,8 @@ function cmd=get_errorcmd(path,scs_m_in,title_err,mess_err)
   //** all other type of blocks
   //** ************************
   else
-    obj_path=path(1:$-1)
-    spec_err='block'
-    blk=path($)
-    scs_m_n=scs_m;
-    //** check if we can open a window
-    //** Alan: we can improve that piece of code
-    //**       to also returns the name of the comput. func.
-    for i=1:size(path,'*')
-      if scs_m_n.objs(path(i)).model.sim=='super' then
-         scs_m_n=scs_m_n.objs(path(i)).model.rpar;
-      elseif scs_m_n.objs(path(i)).model.sim=='csuper' then
-        obj_path=path(1:i-1);
-        blk=path(i);
-        //spec_err='csuper block (block '+string(path(i+1))+')'
-        spec_err='csuper block'
-        break;
-      end
-    end
-
-    if spec_err=='csuper block' then
-        //** update spec_err
-        spec_err='The highlighted '+spec_err+' returns the error :';
-        //**
-        scf(curwin)
-        //** call bad_connection
-        bad_connection(path,...
-                      [title_err;spec_err;mess_err],0,1,0,-1,0,1)
-        //** create cmd
-        cmd=['%diagram_path_objective='+sci2exp(obj_path)+';%scicos_navig=1;'
-             'hilite_obj('+string(blk)+');'+...
-             'unhilite_obj('+string(blk)+');']
-    else
-      //** update spec_err
-      spec_err='The highlighted '+spec_err+' returns the error :';
-      //** create cmd
-      cmd=['%diagram_path_objective='+sci2exp(obj_path)+';%scicos_navig=1;'
-           'hilite_obj('+string(blk)+');'+...
-           'messagebox(['''+title_err+''';'+...
-              ''''+spec_err+''';'+...
-              strcat(''''+mess_err+'''',";")+'],''modal'');'+...
-           'unhilite_obj('+string(blk)+');']
-    end
-
+    msg = title_err + ": " + mess_err;
+    hilite_path(path, msg);
   end
 
 endfunction
index 7e79d56..12c1ef1 100644 (file)
@@ -19,6 +19,9 @@
 // See the file ../license.txt
 //
 function hilite_modelica_block(k,corinvm)
+  // any old scicos macros, will be removed on 5.4.0
+  warnobsolete(scilabRemovedVersion="5.4.0")
+
 //Copyright INRIA
 //## purpose : hilite a modelica block in the scicos editor
 //##           (only in opened windows)
index e25780e..f5fafeb 100644 (file)
@@ -19,6 +19,9 @@
 // See the file ../license.txt
 //
 function ok=hilite_mult_objs(path,objs,mess)
+  // any old scicos macros, will be removed on 5.4.0
+  warnobsolete(scilabRemovedVersion="5.4.0")
+  
 // this function hilight a block by two different way:
 //   -First method: the block is given by its position in the diagram. In this case
 //               - path: the super_path
@@ -89,4 +92,4 @@ if scs_m.objs(temp(1)).model.sim=='super' then
 end
 endfunction
  
\ No newline at end of file
index fc99aa1..7e7c0af 100644 (file)
@@ -20,9 +20,9 @@
 //
 
 function hilite_obj(k,win)
-
-    xcosShowBlockWarning(k); //** new
-       return;
+  // any old scicos macros, will be removed on 5.4.0
+  warnobsolete(scilabRemovedVersion="5.4.0")
+  return;
 
 //
 //** WARNING: I changed mechanism AND input values:
index b3bc1c9..1a783cd 100644 (file)
@@ -24,50 +24,35 @@ function hilite_path(path,mess,with_intermediates)
 //message.   If required all the intermediate superblocs are displayed
 //first entry of the path must be a bloc of currently opened diagram  
 
-  global   Scicos_commands
+    if argn(2)<2 then mess=" ",end
 
-  Scicos_commands=['%diagram_path_objective='+sci2exp(path(1:$-1))+';%scicos_navig=1';
-                  'Cmenu=[];show_window();%scicos_navig=[];']
-
-  if argn(2)<3 then with_intermediates=%f,end
-  if argn(2)<2 then mess=' ',end
-  scs_m;
-  mxwin=max(winsid()),opened_windows=[]
-
-  //** save the current figure handle
-  gh_wins = gcf();
-
-  hilite_obj(path(1))
-
-  if with_intermediates then
-    scs_m=scs_m.objs(path(1)).model.rpar;
-    for k=2:size(path,'*')
-      scs_show(scs_m,mxwin+k);opened_windows=[mxwin+k opened_windows]
-      hilite_obj(path(k))
-      scs_m=scs_m.objs(path(k)).model.rpar;
-    end
-  else
-    if size(path,'*')==1 then
-      hilite_obj(path)
+    // retrieve the root diagram
+    if isdef('scs_m_s') then
+        diagram = scs_m_s;
+    elseif isdef('scs_m') then
+        diagram = scs_m;
     else
-      for k=1:size(path,'*')-1;scs_m=scs_m.objs(path(k)).model.rpar;end
-      scs_show(scs_m,mxwin+1);opened_windows=[mxwin+1 opened_windows]
-      hilite_obj(path($))
+        error("scs_m variable does not exist");
+    end
+    
+    uid = []; // empty uid path
+
+    // construct the uid path from the index path
+    for i = 1:length(path)
+        index = path(i);
+        if typeof(diagram.objs(index)) == "Block" then
+            uid($+1) = diagram.objs(index).doc(1) + "";
+
+            if diagram.objs(index).model.sim == 'super' then
+                diagram = diagram.objs(index).model.rpar;
+            else
+                break;
+            end
+        end
     end
-  end
-  messagebox(mess,'modal')
-
-  for k=1:size(opened_windows,'*') //** close opened_windows
-    //** select the opened_windows(k) and get the handle
-    gh_del = scf(opened_windows(k));
-    //** delete the window
-    delete(gh_del)
-  end
-  //scs_m=null()
-
-  //** restore the active window
-  scf(gh_wins);
 
-  //** unhilite entity path(1)
-  unhilite_obj(path(1))
+    if uid <> [] then
+      warnBlockByUID(uid, mess);
+    end
 endfunction
+
index 6c57b3d..661d66c 100644 (file)
@@ -23,6 +23,7 @@
 function [scs_m] = prt_align(scs_m)
   // any old scicos macros, will be removed on 5.4.0
   warnobsolete(scilabRemovedVersion="5.4.0")
+  return
 
 //** 25/07/07: Al@n's patch for rotation of blocks
   
index c9c75b5..08d65fb 100644 (file)
@@ -113,15 +113,7 @@ for k=1:n //loop on all objects
          if (ksup==0)|flgcdgen<>-1  then
            hilite_path([path,k],"There is another local GOTO in this diagram with the same tag ''"+loc_mat($,3)+"''",%t);
          else
-           gh_wins = gcf();
-           mxwin=max(winsid());
-           scs_show(scs_m,mxwin+1);
-           hilite_obj(k);
-           messagebox("There is another local GOTO in this diagram with the same tag ''"+loc_mat($,3)+"''","modal");
-           gh_del = scf(mxwin+1);
-           unhilite_obj(k);
-           delete(gh_del);
-           scf(gh_wins);
+           hilite_path([path,k], "There is another local GOTO in this diagram with the same tag ''"+loc_mat($,3)+"''",%t);
          end
          ok=%f;return
        end
@@ -166,13 +158,13 @@ for k=1:n //loop on all objects
       //may be we can handle this blocks just as blocks_to_remove
       if ksup==0 then 
        scs_m=scs_m_s
-       hilite_path([path,k],'Port blocks must be only used in a Super Block',%f)
+       hilite_path([path,k],gettext('Port blocks must be only used in a Super Block'),%f)
        ok=%f;return
       end
       connected=get_connected(scs_m,k)
       if connected==[] then
        scs_m=scs_m_s
-       hilite_path([path,k],'This Super Block Input port is unconnected',%t)
+       hilite_path([path,k],gettext('This Super block input port is not connected.'),%t)
        ok=%f;return
       end
       if or(o.gui==['IN_f','INIMPL_f']) then
index ee0d787..08c49a8 100644 (file)
@@ -126,8 +126,8 @@ while %t do
   for %kk=1:%nn
     %vv=%vv_list(%kk)
     %ierr=%ierr_vec(%kk)
-    select part(%typ(2*%kk-1),1:3)
-    case 'mat'
+    select part(%typ(2*%kk-1),1:6)
+    case 'mat   '
       if %ierr<>0  then 
        %noooo=-%kk,break,
       end
@@ -143,7 +143,7 @@ while %t do
        if %sz(1)>=0 then if %mmmm<>%sz(1) then %noooo=%kk,break,end,end
        if %sz(2)>=0 then if %nnnnn<>%sz(2) then %noooo=%kk,break,end,end
       end
-    case 'vec'
+    case 'vec   '
       if %ierr<>0  then 
        %noooo=-%kk,break,
       end
@@ -154,7 +154,17 @@ while %t do
       %ssss=string(%sz(1))
       %nnnnn=prod(size(%vv))
       if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
-    case 'pol'
+    case 'intvec'
+      if %ierr<>0  then 
+       %noooo=-%kk,break,
+      end
+      //the type of %vv is accepted if it is constant or integer
+      if and(type(%vv)<>[1 8]) then %nok=-%kk,break,end
+      %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
+      %ssss=string(%sz(1))
+      %nnnnn=prod(size(%vv))
+      if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
+    case 'pol   '
       if %ierr<>0  then 
        %noooo=-%kk,break,
       end
@@ -164,7 +174,7 @@ while %t do
       %ssss=string(%sz(1))
       %nnnnn=prod(size(%vv))
       if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
-    case 'row'
+    case 'row   '
       if %ierr<>0  then 
        %noooo=-%kk,break,
       end
@@ -180,7 +190,7 @@ while %t do
       [%mmmm,%nnnnn]=size(%vv)
       if %mmmm<>1 then %noooo=%kk,break,end,
       if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
-    case 'col'
+    case 'col   '
       if %ierr<>0  then 
        %noooo=-%kk,break,
       end
@@ -196,7 +206,7 @@ while %t do
       [%mmmm,%nnnnn]=size(%vv)
       if %nnnnn<>1 then %noooo=%kk,break,end,
       if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
-    case 'str'
+    case 'str   '
       clear %vv
       %vv=%str(%kk)
       if type(%vv)<>10 then %noooo=-%kk,break,end
@@ -204,7 +214,7 @@ while %t do
       %ssss=string(%sz(1))
       %nnnnn=prod(size(%vv))
       if %sz(1)>=0 then if %nnnnn<>1 then %noooo=%kk,break,end,end
-    case 'lis'
+    case 'lis   '
       if %ierr<>0  then 
        %noooo=-%kk,break,
       end
@@ -213,7 +223,7 @@ while %t do
       %ssss=string(%sz(1))
       %nnnnn=size(%vv)
       if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
-    case 'r  '
+    case 'r     '
       if %ierr<>0  then 
        %noooo=-%kk,break,
       end
@@ -228,23 +238,27 @@ while %t do
        if %sz(1)>=0 then if %mmmm<>%sz(1) then %noooo=%kk,break,end,end
        if %sz(2)>=0 then if %nnnnn<>%sz(2) then %noooo=%kk,break,end,end
       end
-    case 'gen'
+    case 'gen   '
       //accept all
     else
-      error('Incorrect type :'+%typ(2*%kk-1))
+      str = gettext("%s: Type %s is not implemented.\n");
+      mess = msprintf(str, 'setvalue', %typ(2*%kk-1));
+      warnBlockByUID(arg1.doc(1), mess); // arg1 is from the block interface function
+      error(mess);
     end
     execstr('%'+string(%kk)+'=%vv')
     clear %vv
   end
-  if %noooo>0 then 
-    messagebox(['answer given for  '+%lables(%noooo);
-             'has invalid dimension: ';
-             'waiting for dimension  '+%ssss],'modal')
+  if %noooo>0 then
+    str = gettext("%s: invalid dimension for ''%s'', waiting for %s");
+    mess = msprintf(str, 'setvalue', %lables(%noooo), %ssss);
+    warnBlockByUID(arg1.doc(1), mess); // arg1 is from the block interface function
     %ini=%str
     %ok=%f;break
   elseif %noooo<0 then
-    messagebox(['answer given for  '+%lables(-%noooo);
-             'has incorrect type :'+ %typ(-2*%noooo-1)],'modal')
+    str = gettext("%s: incorrect type for ''%s'', getting %s");
+    mess = msprintf(str, 'setvalue', %lables(-%noooo), %typ(-2*%noooo-1));
+    warnBlockByUID(arg1.doc(1), mess); // arg1 is from the block interface function
     %ini=%str
     %ok=%f;break
   else
index 2ef1e80..885c406 100644 (file)
Binary files a/scilab/modules/scicos/macros/scicos_scicos/unhilite_modelica_block.sci and b/scilab/modules/scicos/macros/scicos_scicos/unhilite_modelica_block.sci differ
index ebf8ce2..984396b 100644 (file)
@@ -20,8 +20,9 @@
 //
 
 function unhilite_obj(k,win)
-    xcosClearBlockWarning(k); //** new
-       return;
+  // any old scicos macros, will be removed on 5.4.0
+  warnobsolete(scilabRemovedVersion="5.4.0")
+  return;
 
 //
 //** 21 Set 2006:
index 912bc92..bc77808 100644 (file)
@@ -59,8 +59,6 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_warnBlockByUID.cpp \
        sci_gateway/cpp/sci_closeXcosFromScilab.cpp \
        sci_gateway/cpp/sci_xcosDiagramToHDF5.cpp \
-       sci_gateway/cpp/sci_xcosDiagramOpen.cpp \
-       sci_gateway/cpp/sci_xcosDiagramClose.cpp \
        sci_gateway/cpp/sci_xcosPalLoad.cpp \
        sci_gateway/cpp/sci_xcosPalCategoryAdd.cpp \
        sci_gateway/cpp/sci_xcosPalDelete.cpp \
index 34e3497..cd95a5f 100644 (file)
@@ -144,8 +144,6 @@ am__objects_5 = libscixcos_la-sci_Xcos.lo \
        libscixcos_la-sci_warnBlockByUID.lo \
        libscixcos_la-sci_closeXcosFromScilab.lo \
        libscixcos_la-sci_xcosDiagramToHDF5.lo \
-       libscixcos_la-sci_xcosDiagramOpen.lo \
-       libscixcos_la-sci_xcosDiagramClose.lo \
        libscixcos_la-sci_xcosPalLoad.lo \
        libscixcos_la-sci_xcosPalCategoryAdd.lo \
        libscixcos_la-sci_xcosPalDelete.lo \
@@ -486,8 +484,6 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_warnBlockByUID.cpp \
        sci_gateway/cpp/sci_closeXcosFromScilab.cpp \
        sci_gateway/cpp/sci_xcosDiagramToHDF5.cpp \
-       sci_gateway/cpp/sci_xcosDiagramOpen.cpp \
-       sci_gateway/cpp/sci_xcosDiagramClose.cpp \
        sci_gateway/cpp/sci_xcosPalLoad.cpp \
        sci_gateway/cpp/sci_xcosPalCategoryAdd.cpp \
        sci_gateway/cpp/sci_xcosPalDelete.cpp \
@@ -985,8 +981,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_closeXcosFromScilab.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_warnBlockByUID.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_xcosConfigureXmlFile.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_xcosDiagramClose.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_xcosDiagramOpen.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_xcosDiagramToHDF5.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_xcosPalCategoryAdd.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_xcosPalDelete.Plo@am__quote@
@@ -1122,20 +1116,6 @@ libscixcos_la-sci_xcosDiagramToHDF5.lo: sci_gateway/cpp/sci_xcosDiagramToHDF5.cp
 @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) $(libscixcos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscixcos_la-sci_xcosDiagramToHDF5.lo `test -f 'sci_gateway/cpp/sci_xcosDiagramToHDF5.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_xcosDiagramToHDF5.cpp
 
-libscixcos_la-sci_xcosDiagramOpen.lo: sci_gateway/cpp/sci_xcosDiagramOpen.cpp
-@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscixcos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscixcos_la-sci_xcosDiagramOpen.lo -MD -MP -MF $(DEPDIR)/libscixcos_la-sci_xcosDiagramOpen.Tpo -c -o libscixcos_la-sci_xcosDiagramOpen.lo `test -f 'sci_gateway/cpp/sci_xcosDiagramOpen.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_xcosDiagramOpen.cpp
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscixcos_la-sci_xcosDiagramOpen.Tpo $(DEPDIR)/libscixcos_la-sci_xcosDiagramOpen.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_xcosDiagramOpen.cpp' object='libscixcos_la-sci_xcosDiagramOpen.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) $(libscixcos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscixcos_la-sci_xcosDiagramOpen.lo `test -f 'sci_gateway/cpp/sci_xcosDiagramOpen.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_xcosDiagramOpen.cpp
-
-libscixcos_la-sci_xcosDiagramClose.lo: sci_gateway/cpp/sci_xcosDiagramClose.cpp
-@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscixcos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscixcos_la-sci_xcosDiagramClose.lo -MD -MP -MF $(DEPDIR)/libscixcos_la-sci_xcosDiagramClose.Tpo -c -o libscixcos_la-sci_xcosDiagramClose.lo `test -f 'sci_gateway/cpp/sci_xcosDiagramClose.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_xcosDiagramClose.cpp
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscixcos_la-sci_xcosDiagramClose.Tpo $(DEPDIR)/libscixcos_la-sci_xcosDiagramClose.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_xcosDiagramClose.cpp' object='libscixcos_la-sci_xcosDiagramClose.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) $(libscixcos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscixcos_la-sci_xcosDiagramClose.lo `test -f 'sci_gateway/cpp/sci_xcosDiagramClose.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_xcosDiagramClose.cpp
-
 libscixcos_la-sci_xcosPalLoad.lo: sci_gateway/cpp/sci_xcosPalLoad.cpp
 @am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscixcos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscixcos_la-sci_xcosPalLoad.lo -MD -MP -MF $(DEPDIR)/libscixcos_la-sci_xcosPalLoad.Tpo -c -o libscixcos_la-sci_xcosPalLoad.lo `test -f 'sci_gateway/cpp/sci_xcosPalLoad.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_xcosPalLoad.cpp
 @am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscixcos_la-sci_xcosPalLoad.Tpo $(DEPDIR)/libscixcos_la-sci_xcosPalLoad.Plo
diff --git a/scilab/modules/xcos/macros/closeDiagramPath.sci b/scilab/modules/xcos/macros/closeDiagramPath.sci
deleted file mode 100644 (file)
index c6cba98..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2009-2009 - DIGITEO - Antoine ELIAS
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution.  The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-//
-//
-
-function closeDiagramPath(path, highlighted_blocks, close_opened)
-       //3rd : close path diagrams
-       //close opened diagram
-       
-       if close_opened == %t then
-               for k=1:size(path,'*')
-                       xcos_close(path(k));
-                       scs_m=scs_m.objs(path(k)).model.rpar;
-               end
-
-               //reset scs_m value from calling scope
-               clear scs_m;
-               
-               //remove highlight on block
-               if path == [] then
-                       for i = 1 : size(highlighted_blocks,"*")
-                               xcosClearBlockWarning(highlighted_blocks(i));
-                       end
-               else
-                       xcosClearBlockWarning(path(1))
-               end
-       else
-               //disable warnings in diagram path
-               for k=1:size(path,'*')
-                       xcosClearBlockWarning(path(k))
-                       scs_m=scs_m.objs(path(k)).model.rpar;
-               end
-               
-               //disable warning in the last diagram
-               for i = 1 : size(highlighted_blocks,"*")
-                       xcosClearBlockWarning(highlighted_blocks(i));
-               end
-       end
-       
-       
-endfunction
\ No newline at end of file
diff --git a/scilab/modules/xcos/macros/errorDiagramPath.sci b/scilab/modules/xcos/macros/errorDiagramPath.sci
deleted file mode 100644 (file)
index fcfe58c..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2009-2009 - DIGITEO - Antoine ELIAS
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution.  The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-//
-//
-
-function ret = errorDiagramPath(path, highlighted_blocks, msg, field, show_intermediate, close_opened)
-
-       [lhs, rhs] = argn(0);
-       if rhs < 3 then
-               error("%s: argument error", errorDiagramPath);
-       end
-       
-       if rhs < 4 then
-               field = "";
-       end
-
-       if rhs < 5 then
-               show_intermediate = %t;
-       end
-
-       if rhs < 6 then
-               close_opened = %t;
-       end
-
-       ret = [];
-
-       //3 steps ( open diagrams, show msg, close diagrams )
-       //1st : open path diagram
-       openDiagramPath(path, highlighted_blocks, show_intermediate);
-       
-       //2nd : show message
-       
-       //if msg is empty, no show dialog
-       if msg <> [] & msg <> "" then
-               if field == [] | field == "" then
-                       message(msg);
-               else
-                       ret = evstr(dialog(msg, field));
-               end
-       end
-       
-       closeDiagramPath(path, highlighted_blocks, close_opened);
-endfunction
diff --git a/scilab/modules/xcos/macros/openDiagramPath.sci b/scilab/modules/xcos/macros/openDiagramPath.sci
deleted file mode 100644 (file)
index 8aa573a..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2009-2009 - DIGITEO - Antoine ELIAS
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution.  The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-//
-//
-
-function ret = openDiagramPath(path, highlighted_blocks, msg, field, show_intermediate)
-
-       //1st : open path diagram
-       for i = 1 : size(path, "*")
-               //highlight parent block
-               xcosShowBlockWarning(path(i))
-               //open superblock
-               if  i == size(path, "*") then
-                       xcos_open(path(i), %t);
-               else
-                       xcos_open(path(i), show_intermediate);
-               end
-               //build new scs_m to go deeper
-               scs_m=scs_m.objs(path(i)).model.rpar;
-       end
-       
-       //highlight incriminated blocks
-       for i = 1 : size(highlighted_blocks,"*")
-               xcosShowBlockWarning(highlighted_blocks(i));
-       end
-endfunction
diff --git a/scilab/modules/xcos/macros/xcosClearBlockWarning.sci b/scilab/modules/xcos/macros/xcosClearBlockWarning.sci
deleted file mode 100644 (file)
index 26a6fca..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-//
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution.  The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-//
-//
-
-function xcosClearBlockWarning(k, win)
-  for i = k'
-    if typeof(scs_m.objs(i)) == "Block"
-      warnBlockByUID(scs_m.objs(i).doc(1), "");
-    end
-  end 
-
-endfunction
index d5b4ea9..1f28ae1 100644 (file)
 //
 
 function xcosCodeGeneration(hdf5FileToLoad, hdf5FileToSave)
-
-    //-- BJ : Alias Warning Function
-    prot = funcprot();
-    funcprot(0);
-    hilite_obj = xcosShowBlockWarning;
-    unhilite_obj = xcosClearBlockWarning;
-    funcprot(prot);
-    //-- end
-
     // This will create a scs_m variable.
     status = import_from_hdf5(hdf5FileToLoad);
     if ~status then
diff --git a/scilab/modules/xcos/macros/xcos_close.sci b/scilab/modules/xcos/macros/xcos_close.sci
deleted file mode 100644 (file)
index 5f5e34a..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-//
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2009-2009 - DIGITEO - Antoine ELIAS
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution.  The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-//
-//
-
-function xcos_close(blockId)
-    if size(scs_m.objs(blockId).doc) > 0 then
-        xcosDiagramClose(scs_m.objs(blockId).doc(1));
-    end
-endfunction
index bf39388..ff70c1c 100644 (file)
 
 function  [%cpr,ok] = xcos_compile(scs_m)
 
-//-- BJ : Alias Warning Function
-  prot = funcprot();
-  funcprot(0);
-  hilite_obj = xcosShowBlockWarning;
-  unhilite_obj = xcosClearBlockWarning;
-  funcprot(prot);
-  //-- end
-
 ////////////////////////////////////////////////////////////////
 // Add global environment variable so that scicos is not lost //
 ////////////////////////////////////////////////////////////////
diff --git a/scilab/modules/xcos/macros/xcos_open.sci b/scilab/modules/xcos/macros/xcos_open.sci
deleted file mode 100644 (file)
index 42aa53d..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2009-2010 - DIGITEO - Antoine ELIAS <antoine.elias@scilab.org>
-// Copyright (C) 2010-2010 - DIGITEO - Clément DAVID <clement.david@scilab.org>
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution.  The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-//
-//
-
-function xcos_open(blockId, show)
-// Open a block from scilab
-//
-// Calling Sequence
-//  xcos_open(blockId);
-//  xcos_open(blockId, show);
-//
-// Parameters
-//  blockId: the id of the block
-//  show: if the block settings may be opened
-//
-// Description
-//  To communicate with from scilab to Java, we use an id per block stored in 
-//  the first block.doc field.
-    [lhs, rhs] = argn(0);
-    if rhs == 1 then
-        show = %t;
-    end
-
-    if size(scs_m.objs(blockId).doc) > 0 then
-        xcosDiagramOpen(scs_m.objs(blockId).doc(1), show);
-    end
-endfunction
index a82b381..60ceb17 100644 (file)
@@ -15,33 +15,6 @@ function %cpr = xcos_simulate(scs_m, needcompile)
 //-- BJ : Alias Warning Function
   prot = funcprot();
   funcprot(0);
-//  hilite_obj = xcosShowBlockWarning;
-//  unhilite_obj = xcosClearBlockWarning;
-//  scs_show = xcos_open;
-
-//    function ret = fake_gcf() 
-//        disp("fake_gcf");
-//        ret = [];
-//    endfunction;
-//    gcf = fake_gcf;
-
-//    function ret = fake_scf(id) 
-//        disp("fake_scf");
-//        ret = [];
-//    endfunction;
-//    scf = fake_scf;
-
-//    function ret = fake_gca() 
-//        disp("fake_gca");
-//        ret = [];
-//    endfunction;
-//    gca = fake_gca;
-
-//    function ret = fake_sca(id) 
-//        disp("fake_sca");
-//        ret = [];
-//    endfunction;
-//    sca = fake_sca;
 
 if ~isdef('scicos_menuslib') then
   load('SCI/modules/scicos/macros/scicos_menus/lib')
@@ -130,18 +103,15 @@ end
   end
   //end of for backward compatibility for scifuncpagate context values
   
-  [scs_m,%cpr,needcompile,ok] = do_eval(scs_m, %cpr);
-  
+  [scs_m,%cpr,needcompile,ok] = do_eval(scs_m, %cpr, %scicos_context);
+  if ~ok then
+    error(msprintf(gettext("%s: Error during block parameters evaluation."), "xcos_simulate"));
+  end
   
   //** update parameters or compilation results
   [%cpr,%state0_n,needcompile,alreadyran,ok] = do_update(%cpr,%state0,needcompile)
-  
-  //** if an error has ocurred in do_update
-  //** then we exit from do_run
   if ~ok then
-    %tcur      = []
-    alreadyran = %f ;
-    return
+    error(msprintf(gettext("%s: Error during block parameters update."), "xcos_simulate"));
   end
 
   //** if alreadyran then set the var choice
index 21b4e52..209a0b2 100644 (file)
@@ -28,8 +28,6 @@ static gw_generic_table Tab[] = {
     {sci_warnBlockByUID,                  "warnBlockByUID"},
     {sci_closeXcosFromScilab,             "closeXcos"},
     {sci_xcosDiagramToHDF5,               "xcosDiagramToHDF5"},
-    {sci_xcosDiagramOpen,                 "xcosDiagramOpen"},
-    {sci_xcosDiagramClose,                "xcosDiagramClose"},
     {sci_xcosPalLoad,                     "xcosPalLoad"},
     {sci_xcosPalCategoryAdd,              "xcosPalCategoryAdd"},
     {sci_xcosPalDelete,                   "xcosPalDelete"},
index bfa1dcd..044219b 100644 (file)
@@ -1,6 +1,7 @@
 /*
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2009 - DIGITEO - Vincent COUVERt
+* Copyright (C) 2011 - DIGITEO - Clément DAVID
 *
 * This file must be used under the terms of the CeCILL.
 * This source file is licensed as described in the file COPYING, which
 */
 /*--------------------------------------------------------------------------*/
 #include "Xcos.hxx"
+#include "xcosUtilities.hxx"
 extern "C"
 {
 #include "gw_xcos.h"
 #include "stack-c.h"
 #include "callxcos.h"
-#include "api_common.h"
-#include "api_string.h"
+#include "api_scilab.h"
 #include "localization.h"
 #include "Scierror.h"
 #include "MALLOC.h"
 #include "freeArrayOfString.h"
-#include "getFullFilename.h"
 #include "getScilabJavaVM.h"
 }
 /*--------------------------------------------------------------------------*/
@@ -30,108 +30,42 @@ using namespace org_scilab_modules_xcos;
 /*--------------------------------------------------------------------------*/
 int sci_warnBlockByUID(char *fname,unsigned long fname_len)
 {
-       SciErr sciErr;
-
+       int i;
 
        CheckRhs(2,2);
        CheckLhs(0,1);
 
-       int m1 = 0, n1 = 0;
-       int *piAddressVarOne = NULL;
-       int *piAddressVarTwo = NULL;
-
-       char *pStVarOne = NULL;
-       int lenStVarOne = 0;
-
-       char *pStVarTwo = NULL;
-       int lenStVarTwo = 0;
-
-       /** READ UID **/
-       sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       /* get dimensions */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, NULL, NULL);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       if (m1 * n1 != 1) {
-               Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"),fname,1);
-               return 0;
-       }
-
-       /* get lengths */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, &lenStVarOne, NULL);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       pStVarOne = (char*)MALLOC(sizeof(char*) * (lenStVarOne + 1));
+       char** path = NULL;
+       int pathLength = 0;
 
-       /* get strings */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, &lenStVarOne, &pStVarOne);
-       if(sciErr.iErr)
-       {
-               FREE(pStVarOne);
-               printError(&sciErr, 0);
-               return 0;
-       }
+       char* msg;
 
-       /** READ MESSAGE **/
-       sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
+       /** read UID **/
+    if (readVectorString(pvApiCtx, 1, &path, &pathLength, fname))
+    {
+        return 0;
+    }
 
-       /* get dimensions */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarTwo, &m1, &n1, &lenStVarTwo, NULL);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
+       /* read msg */
+    if (readSingleString(pvApiCtx, 2, &msg, fname)) {
+       for (i=0; i<pathLength; i++) {
+               FREE(path[i]);
+       }
+       FREE(path);
                return 0;
        }
 
-       if (m1 * n1 != 1) {
-               Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"),fname,2);
-               return 0;
-       }
-
-       /* get lengths */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarTwo, &m1, &n1, &lenStVarTwo, NULL);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       pStVarTwo = (char*)MALLOC(sizeof(char*) * (lenStVarTwo + 1));
-
-       /* get strings */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarTwo, &m1, &n1, &lenStVarTwo, &pStVarTwo);
-       if(sciErr.iErr)
-       {
-               FREE(pStVarTwo);
-               printError(&sciErr, 0);
-               return 0;
-       }
-       Xcos::warnCellByUID(getScilabJavaVM(), pStVarOne, pStVarTwo);
+    /* call the implementation */
+       Xcos::warnCellByUID(getScilabJavaVM(), path, pathLength, msg);
 
        LhsVar(1) = 0;
        PutLhsVar();
 
-       FREE(pStVarOne);
-       FREE(pStVarTwo);
+       for (i=0; i<pathLength; i++) {
+               FREE(path[i]);
+       }
+       FREE(path);
+       freeAllocatedSingleString(msg);
        return 0;
 }
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/xcos/sci_gateway/cpp/sci_xcosDiagramClose.cpp b/scilab/modules/xcos/sci_gateway/cpp/sci_xcosDiagramClose.cpp
deleted file mode 100644 (file)
index b350e12..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2009 - DIGITEO - 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 "Xcos.hxx"
-extern "C"
-{
-#include "gw_xcos.h"
-#include "stack-c.h"
-#include "callxcos.h"
-#include "api_common.h"
-#include "api_string.h"
-#include "localization.h"
-#include "Scierror.h"
-#include "MALLOC.h"
-#include "freeArrayOfString.h"
-#include "getFullFilename.h"
-#include "getScilabJavaVM.h"
-}
-/*--------------------------------------------------------------------------*/
-using namespace org_scilab_modules_xcos;
-/*--------------------------------------------------------------------------*/
-int sci_xcosDiagramClose(char *fname,unsigned long fname_len)
-{
-       SciErr sciErr;
-
-
-       CheckRhs(1,1);
-       CheckLhs(0,1);
-
-       int m1 = 0, n1 = 0;
-       int *piAddressVarOne = NULL;
-
-       char *pStVarOne = NULL;
-       int lenStVarOne = 0;
-
-       /** READ UID **/
-       sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       /* get dimensions */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, NULL, NULL);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       if (m1 * n1 != 1) {
-               Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"),fname,1);
-               return 0;
-       }
-
-       /* get lengths */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, &lenStVarOne, NULL);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       pStVarOne = (char*)MALLOC(sizeof(char*) * (lenStVarOne + 1));
-
-       /* get strings */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, &lenStVarOne, &pStVarOne);
-       if(sciErr.iErr)
-       {
-               FREE(pStVarOne);
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       Xcos::xcosDiagramClose(getScilabJavaVM(), pStVarOne);
-
-       LhsVar(1) = 0;
-       PutLhsVar();
-
-       FREE(pStVarOne);
-       return 0;
-}
-/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/xcos/sci_gateway/cpp/sci_xcosDiagramOpen.cpp b/scilab/modules/xcos/sci_gateway/cpp/sci_xcosDiagramOpen.cpp
deleted file mode 100644 (file)
index f48a9c5..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2009 - DIGITEO - 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 "Xcos.hxx"
-extern "C"
-{
-#include "gw_xcos.h"
-#include "stack-c.h"
-#include "callxcos.h"
-#include "api_scilab.h"
-#include "localization.h"
-#include "Scierror.h"
-#include "MALLOC.h"
-#include "freeArrayOfString.h"
-#include "getFullFilename.h"
-#include "getScilabJavaVM.h"
-}
-/*--------------------------------------------------------------------------*/
-using namespace org_scilab_modules_xcos;
-/*--------------------------------------------------------------------------*/
-int sci_xcosDiagramOpen(char *fname,unsigned long fname_len)
-{
-       SciErr sciErr;
-
-       CheckRhs(1,2);
-       CheckLhs(0,1);
-
-       int m1 = 0, n1 = 0;
-       int *piAddressVarOne = NULL;
-
-       char *pStVarOne = NULL;
-       int lenStVarOne = 0;
-
-       int m2 = 0, n2 = 0;
-       int *piAddressVarTwo = NULL;
-
-       int* piBoolVarTwo = NULL;
-       bool bShow = true;
-
-       /** READ UID **/
-       sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       /* get dimensions */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, NULL, NULL);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       if (m1 !=1 || n1 != 1) {
-               Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"),fname,1);
-               return 0;
-       }
-
-       /* get lengths */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, &lenStVarOne, NULL);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       pStVarOne = (char*)MALLOC(sizeof(char*) * (lenStVarOne + 1));
-
-       /* get strings */
-       sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, &lenStVarOne, &pStVarOne);
-       if(sciErr.iErr)
-       {
-               FREE(pStVarOne);
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       if(Rhs == 2)
-       {
-               sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               sciErr = getMatrixOfBoolean(pvApiCtx, piAddressVarTwo, &m2, &n2, &piBoolVarTwo);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               if(m2 != 1 || n2 != 1)
-               {
-                       Scierror(999,_("%s: Wrong size for input argument #%d: A boolean expected.\n"), fname, 2);
-                       return 0;
-               }
-
-               bShow = piBoolVarTwo[0] == 0 ? false : true;
-       }
-
-       Xcos::xcosDiagramOpen(getScilabJavaVM(), pStVarOne, bShow);
-
-       LhsVar(1) = 0;
-       PutLhsVar();
-
-       FREE(pStVarOne);
-       return 0;
-}
-/*--------------------------------------------------------------------------*/
index 45272d9..c94247a 100644 (file)
@@ -1,9 +1,8 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-
 <!DOCTYPE GATEWAY SYSTEM "../../functions/xml/gateway.dtd">
 <GATEWAY name="xcos">
-<!-- =================== -->
-<!--
+  <!-- =================== -->
+  <!--
  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.
  ===================
  Don't touch if you do not know what you are doing
 -->
-<!-- =================== -->
-
-<PRIMITIVE gatewayId="64" primitiveId="1" primitiveName="xcos" />
-<PRIMITIVE gatewayId="64" primitiveId="2" primitiveName="warnBlockByUID" />
-<PRIMITIVE gatewayId="64" primitiveId="3" primitiveName="closeXcos" />
-<PRIMITIVE gatewayId="64" primitiveId="4" primitiveName="xcosDiagramToHDF5" />
-<PRIMITIVE gatewayId="64" primitiveId="5" primitiveName="xcosDiagramOpen" />
-<PRIMITIVE gatewayId="64" primitiveId="6" primitiveName="xcosDiagramClose" />
-<PRIMITIVE gatewayId="64" primitiveId="7" primitiveName="xcosPalLoad" />
-<PRIMITIVE gatewayId="64" primitiveId="8" primitiveName="xcosPalCategoryAdd" />
-<PRIMITIVE gatewayId="64" primitiveId="9" primitiveName="xcosPalDelete" />
-<PRIMITIVE gatewayId="64" primitiveId="10" primitiveName="xcosPalMove" />
-<PRIMITIVE gatewayId="64" primitiveId="11" primitiveName="xcosPalEnable" />
-<PRIMITIVE gatewayId="64" primitiveId="12" primitiveName="xcosPalDisable" />
-<PRIMITIVE gatewayId="64" primitiveId="13" primitiveName="xcosPalGenerateIcon" />
-<PRIMITIVE gatewayId="64" primitiveId="14" primitiveName="xcosConfigureXmlFile" />
+  <!-- =================== -->
+  <PRIMITIVE gatewayId="64" primitiveId="1" primitiveName="xcos"/>
+  <PRIMITIVE gatewayId="64" primitiveId="2" primitiveName="warnBlockByUID"/>
+  <PRIMITIVE gatewayId="64" primitiveId="3" primitiveName="closeXcos"/>
+  <PRIMITIVE gatewayId="64" primitiveId="4" primitiveName="xcosDiagramToHDF5"/>
+  <PRIMITIVE gatewayId="64" primitiveId="5" primitiveName="xcosPalLoad"/>
+  <PRIMITIVE gatewayId="64" primitiveId="6" primitiveName="xcosPalCategoryAdd"/>
+  <PRIMITIVE gatewayId="64" primitiveId="7" primitiveName="xcosPalDelete"/>
+  <PRIMITIVE gatewayId="64" primitiveId="8" primitiveName="xcosPalMove"/>
+  <PRIMITIVE gatewayId="64" primitiveId="9" primitiveName="xcosPalEnable"/>
+  <PRIMITIVE gatewayId="64" primitiveId="10" primitiveName="xcosPalDisable"/>
+  <PRIMITIVE gatewayId="64" primitiveId="11" primitiveName="xcosPalGenerateIcon"/>
+  <PRIMITIVE gatewayId="64" primitiveId="12" primitiveName="xcosConfigureXmlFile"/>
 </GATEWAY>
index cd54f06..a3f6444 100644 (file)
@@ -190,7 +190,7 @@ int readVectorString(void* _pvCtx, int rhsPosition, char*** out, int* vectorLeng
     for (int i = 0; i < rowsArgument * colsArgument; ++i)
     {
         value[i] = (char*) MALLOC(sizeof(char) * (lenArgument[i] + 1)); // +1 for null termination
-        value[lenArgument[i]] = '\0';
+        value[i][lenArgument[i]] = '\0';
     }
 
     sciErr = getMatrixOfString(_pvCtx, argumentPointer, &rowsArgument,
@@ -210,6 +210,7 @@ int readVectorString(void* _pvCtx, int rhsPosition, char*** out, int* vectorLeng
     *out = value;
     *vectorLength = rowsArgument * colsArgument;
     
+    FREE(lenArgument);
     return 0;
 }
 
index f7b6a6b..df4a495 100644 (file)
@@ -18,11 +18,10 @@ import static org.scilab.modules.xcos.utils.FileUtils.delete;
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayDeque;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Vector;
 import java.util.logging.LogManager;
 
@@ -35,10 +34,8 @@ import org.scilab.modules.action_binding.InterpreterManagement;
 import org.scilab.modules.graph.utils.ScilabExported;
 import org.scilab.modules.localization.Messages;
 import org.scilab.modules.xcos.block.BasicBlock;
-import org.scilab.modules.xcos.block.BlockFactory;
 import org.scilab.modules.xcos.block.SuperBlock;
 import org.scilab.modules.xcos.configuration.ConfigurationManager;
-import org.scilab.modules.xcos.graph.SuperBlockDiagram;
 import org.scilab.modules.xcos.graph.XcosDiagram;
 import org.scilab.modules.xcos.palette.PaletteBlockCtrl;
 import org.scilab.modules.xcos.palette.PaletteManager;
@@ -46,7 +43,9 @@ import org.scilab.modules.xcos.palette.model.Category;
 import org.scilab.modules.xcos.palette.model.PaletteBlock;
 import org.scilab.modules.xcos.palette.model.PreLoaded;
 import org.scilab.modules.xcos.utils.FileUtils;
+import org.scilab.modules.xcos.utils.XcosMessages;
 
+import com.mxgraph.model.mxGraphModel;
 import com.mxgraph.view.mxStylesheet;
 
 /**
@@ -87,7 +86,6 @@ public final class Xcos {
        /*
         * Instance data
         */
-       private final Map<String, SuperBlock> openedSuperBlock;
        private final List<XcosDiagram> diagrams;
 
        /*
@@ -121,8 +119,6 @@ public final class Xcos {
                /*
                 * Allocate synchronized communications data
                 */
-               openedSuperBlock = Collections
-                               .synchronizedMap(new HashMap<String, SuperBlock>());
                diagrams = Collections.synchronizedList(new Vector<XcosDiagram>());
 
                /*
@@ -537,20 +533,81 @@ public final class Xcos {
         *            The message to display.
         */
        @ScilabExported(module = "xcos", filename = "Xcos.giws.xml")
-       public static void warnCellByUID(final String uid, final String message) {
-               final List<XcosDiagram> diagrams = getInstance().diagrams;
-
-               final String localId = uid;
-               final String localMessage = message;
-
-               SwingUtilities.invokeLater(new Runnable() {
-                       @Override
-                       public void run() {
-                               for (int i = 0; i < diagrams.size(); ++i) {
-                                       diagrams.get(i).warnCellByUID(localId, localMessage);
+       public static void warnCellByUID(final String[] uid, final String message) {
+               try {
+                       SwingUtilities.invokeAndWait(new Runnable() {
+                               @Override
+                               public void run() {
+                                       final ArrayDeque<String> deque = new ArrayDeque<String>(Arrays.asList(uid));
+                                       
+                                       String id;
+                                       BasicBlock block = null;
+                                       
+                                       // specific case with an empty array
+                                       if (deque.isEmpty()) {
+                                               return;
+                                       }
+                                       
+                                       // first element
+                                       id = deque.pop();
+                                       for (XcosDiagram diagram : getInstance().getDiagrams()) {
+                                               block = (BasicBlock) ((mxGraphModel) diagram.getModel()).getCell(id);
+                                               if (block != null) {
+                                                       break;
+                                               }
+                                       }
+                                       
+                                       
+                                       // loop to get only the last diagram
+                                       while (block instanceof SuperBlock && !deque.isEmpty()) {
+                                               block.getParentDiagram()
+                                                               .warnCellByUID(
+                                                                               block.getId(),
+                                                                               XcosMessages.ERROR_UNABLE_TO_COMPILE_THIS_SUPER_BLOCK);
+                                               
+                                               final SuperBlock superBlock = (SuperBlock) block;
+                                               id = deque.pop();
+                                               
+                                               if (!Xcos.getInstance().getDiagrams().contains(superBlock.getChild())) {
+                                                       block.openBlockSettings(null);
+                                               }
+                                               block = (BasicBlock) ((mxGraphModel) superBlock.getChild().getModel()).getCell(id);
+                                       }
+                                       
+                                       // We are unable to find the block with the right id
+                                       if (block == null) {
+                                               return;
+                                       }
+                                       
+                                       
+                                       // finally perform the action on the last block
+                                       final XcosDiagram parent = block.getParentDiagram();
+                                       parent.warnCellByUID(block.getId(), message);
+                                       
+                                       SwingUtilities.invokeLater(new Runnable() {
+                                               @Override
+                                               public void run() {
+                                                       /*
+                                                        * Focus on an existing diagram
+                                                        */
+                                                       parent.getParentTab().setCurrent();
+                                               }
+                                       });
+                                       
                                }
+                       });
+               } catch (final InterruptedException e) {
+                       LOG.error(e);
+               } catch (final InvocationTargetException e) {
+                       Throwable throwable = e;
+                       String firstMessage = null;
+                       while (throwable != null) {
+                               firstMessage = throwable.getLocalizedMessage();
+                               throwable = throwable.getCause();
                        }
-               });
+                       
+                       throw new RuntimeException(firstMessage, e);
+               }
        }
 
        /**
@@ -612,46 +669,46 @@ public final class Xcos {
         * This method invoke Xcos operation on the EDT thread.
         * 
         * @param uid
-        *            UID diagram to open.
-        * @param showed
-        *            True if you want the diagram to be shown, false otherwise.
+        *            UID path to a block.
         */
        @ScilabExported(module = "xcos", filename = "Xcos.giws.xml")
-       public static void xcosDiagramOpen(final String uid, final boolean showed) {
-               final List<XcosDiagram> diagrams = getInstance().diagrams;
-               final String id = uid;
-               final boolean show = showed;
-
+       public static void xcosDiagramOpen(final String[] uid) {
+               final ArrayDeque<String> deque = new ArrayDeque<String>(Arrays.asList(uid));
+               
                try {
                        SwingUtilities.invokeAndWait(new Runnable() {
                                @Override
                                public void run() {
-                                       BasicBlock block = null;
-                                       for (final XcosDiagram diagram : diagrams) {
-
-                                               // exclude SuperBlock from parsing
-                                               if (diagram instanceof SuperBlockDiagram) {
-                                                       continue;
-                                               }
-
-                                               block = diagram.getChildById(id);
-                                               if (block != null) {
-                                                       final SuperBlock newSP = (SuperBlock) BlockFactory
-                                                                       .createBlock("SUPER_f");
-                                                       newSP.setRealParameters(block.getRealParameters());
-                                                       newSP.setParentDiagram(block.getParentDiagram());
-
-                                                       if (show) {
-                                                               if (newSP.createChildDiagram()) {
-                                                                       new XcosTab(newSP.getChild())
-                                                                                       .setVisible(true);
-                                                                       newSP.getChild().setReadOnly(true);
-                                                               }
-                                                       }
-                                                       getInstance().openedSuperBlock.put(id, newSP);
+                                       String id;
+                                       Object block = null;
+                                       
+                                       // specific case with an empty array
+                                       if (deque.isEmpty()) {
+                                               return;
+                                       }
+                                       
+                                       // first element
+                                       id = deque.pop();
+                                       for (XcosDiagram diagram : getInstance().getDiagrams()) {
+                                               block = ((mxGraphModel) diagram.getModel()).getCell(id);
+                                               if (block instanceof SuperBlock) {
                                                        break;
                                                }
                                        }
+                                       
+                                       // loop to get only the last diagram
+                                       while (block instanceof SuperBlock & !deque.isEmpty()) {
+                                               final SuperBlock superBlock = (SuperBlock)block;
+                                               id = deque.pop();
+                                               
+                                               superBlock.openBlockSettings(null);
+                                               block = ((mxGraphModel) superBlock.getChild().getModel()).getCell(id);
+                                       }
+                                       
+                                       // finally perform the action
+                                       if (block instanceof SuperBlock) {
+                                               ((SuperBlock) block).openBlockSettings(null);
+                                       }
                                }
                        });
                } catch (final InterruptedException e) {
@@ -673,23 +730,46 @@ public final class Xcos {
         * 
         * This method invoke Xcos operation on the EDT thread.
         * 
-        * @param uid
-        *            The diagram id
+        * @param uid[]
+        *            The diagram id path
         */
        @ScilabExported(module = "xcos", filename = "Xcos.giws.xml")
-       public static void xcosDiagramClose(final String uid) {
-               final String id = uid;
-
+       public static void xcosDiagramClose(final String uid[]) {
+               final ArrayDeque<String> deque = new ArrayDeque<String>(Arrays.asList(uid));
+               
                try {
                        SwingUtilities.invokeAndWait(new Runnable() {
                                @Override
                                public void run() {
-
-                                       SuperBlock sp = getInstance().openedSuperBlock.get(id);
-                                       if (sp != null) {
-                                               getInstance().openedSuperBlock.remove(id);
-                                               sp.closeBlockSettings();
-                                               sp = null;
+                                       String id;
+                                       Object block = null;
+                                       
+                                       // specific case with an empty array
+                                       if (deque.isEmpty()) {
+                                               closeSession();
+                                       }
+                                       
+                                       // first element
+                                       id = deque.pop();
+                                       for (XcosDiagram diagram : getInstance().getDiagrams()) {
+                                               block = ((mxGraphModel) diagram.getModel()).getCell(id);
+                                               if (block instanceof SuperBlock) {
+                                                       break;
+                                               }
+                                       }
+                                       
+                                       // loop to get only the last diagram
+                                       while (block instanceof SuperBlock & !deque.isEmpty()) {
+                                               final SuperBlock superBlock = (SuperBlock)block;
+                                               id = deque.pop();
+                                               
+                                               superBlock.openBlockSettings(null);
+                                               block = ((mxGraphModel) superBlock.getChild().getModel()).getCell(id);
+                                       }
+                                       
+                                       // finally perform the action
+                                       if (block instanceof SuperBlock) {
+                                               ((SuperBlock) block).closeBlockSettings();
                                        }
                                }
                        });
@@ -716,6 +796,9 @@ public final class Xcos {
                final Xcos instance = getInstance();
                for (XcosDiagram diag : instance.getDiagrams()) {
                        if (diag.getModel().contains(cell)) {
+                               if (cell instanceof BasicBlock) {
+                                       ((BasicBlock) cell).setParentDiagram(diag);
+                               }
                                return diag;
                        }
                }
index b2ba527..968d989 100644 (file)
@@ -1116,6 +1116,10 @@ public class BasicBlock extends ScilabGraphUniqueObject implements Serializable
            return;
        }
        
+       if (context == null) {
+               throw new IllegalArgumentException();
+       }
+       
        //prevent to open twice
        if (isLocked()) {
            return;
index a0b30e1..9bb12c8 100644 (file)
@@ -1876,16 +1876,8 @@ public class XcosDiagram extends ScilabGraph {
                        }
 
                        if (answer == AnswerOption.YES_OPTION) {
-                               try {
-                                       final FileWriter writer = new FileWriter(diagram);
-                                       writer.write("");
-                                       writer.flush();
-                                       writer.close();
-                                       setSavedFile(diagram);
-                               } catch (final IOException ioexc) {
-                                       LOG.error(ioexc);
-                                       JOptionPane.showMessageDialog(getAsComponent(), ioexc);
-                               }
+                               saveDiagramAs(diagram);
+                               getParentTab().setVisible(true);
                        } else {
                                return null;
                        }
@@ -1908,7 +1900,7 @@ public class XcosDiagram extends ScilabGraph {
        final XcosFileType filetype = XcosFileType.findFileType(fileToLoad);
        boolean result = false;
 
-       if (!fileToLoad.exists()) {
+       if (!fileToLoad.exists() || filetype == null) {
                XcosDialogs.couldNotLoadFile(this);
                return false;
        }
@@ -2076,12 +2068,18 @@ public class XcosDiagram extends ScilabGraph {
                return;
        }
        
-       if (message.isEmpty()) {
-               // put the current tab on top
-               setVisible(true);
+       if (message.isEmpty()) { 
+               if (isVisible()) {
+                       getAsComponent().clearCellOverlays(cell);
+               }
+       } else {
+               if (getParentTab() == null) {
+                       // Open a new tab
+                       new XcosTab(this);
+                       setVisible(true);
+               }
+               getAsComponent().setCellWarning(cell, message, null, true);
        }
-       
-       getAsComponent().setCellWarning(cell, message);
     }
 
     /**
index 678c9ef..eef75b7 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Map;
 
 import org.scilab.modules.types.ScilabDouble;
 import org.scilab.modules.xcos.block.BasicBlock;
+import org.scilab.modules.xcos.link.BasicLink;
 import org.scilab.modules.xcos.port.BasicPort;
 import org.scilab.modules.xcos.port.Orientation;
 
@@ -50,10 +51,10 @@ public final class BasicBlockInfo {
                for (int i = 0; i < ports.size(); ++i) {
                        final BasicPort p = (BasicPort) ports.get(i);
                        
-                       if (p.getEdgeCount() == 0) {
-                               data[i][0] = 0;
+                       if (p.getEdgeCount() == 1) {
+                               data[i][0] = ((BasicLink) p.getEdgeAt(0)).getOrdering();
                        } else {
-                               data[i][0] = p.getConnectedLinkId();
+                               data[i][0] = 0;
                        }
                }
 
index 5fe21bd..89863e2 100644 (file)
@@ -19,13 +19,16 @@ import java.io.DataInputStream;
 import java.io.IOException;
 import java.util.List;
 
+import org.apache.commons.logging.LogFactory;
 import org.scilab.modules.types.ScilabDouble;
 import org.scilab.modules.types.ScilabList;
 import org.scilab.modules.types.ScilabMList;
 import org.scilab.modules.types.ScilabString;
 import org.scilab.modules.types.ScilabType;
+import org.scilab.modules.xcos.Xcos;
 import org.scilab.modules.xcos.block.BasicBlock;
 import org.scilab.modules.xcos.block.BlockFactory;
+import org.scilab.modules.xcos.graph.XcosDiagram;
 import org.scilab.modules.xcos.io.scicos.ScicosFormatException.WrongElementException;
 import org.scilab.modules.xcos.io.scicos.ScicosFormatException.WrongStructureException;
 import org.scilab.modules.xcos.io.scicos.ScicosFormatException.WrongTypeException;
@@ -321,6 +324,23 @@ public class BlockElement extends AbstractElement<BasicBlock> {
        }
        
        /**
+        * {@inheritDoc}} 
+        *
+        * Clear cell warnings before encoding
+        */
+       @Override
+       public ScilabType beforeEncode(BasicBlock from, ScilabType element) {
+               XcosDiagram graph = from.getParentDiagram();
+               if (graph == null) {
+                       from.setParentDiagram(Xcos.findParent(from));
+                       graph = from.getParentDiagram();
+                       LogFactory.getLog(getClass()).error("Parent diagram was null");
+               }
+               graph.getAsComponent().removeCellOverlays(from);
+               return super.beforeEncode(from, element);
+       }
+       
+       /**
         * Encode the instance into the element
         * 
         * @param from the source instance
index 0a11ef6..00d6100 100644 (file)
@@ -407,6 +407,17 @@ public class DiagramElement extends AbstractElement<XcosDiagram> {
        }
        
        /**
+        * {@inheritDoc}} 
+        *
+        * Clear cell warnings before encoding
+        */
+       @Override
+       public ScilabType beforeEncode(XcosDiagram from, ScilabType element) {
+               from.getAsComponent().clearCellOverlays();
+               return super.beforeEncode(from, element);
+       }
+       
+       /**
         * Encode the instance into the element
         * 
         * @param from the source instance
index dd37c5d..7a35652 100644 (file)
@@ -21,6 +21,8 @@ import org.scilab.modules.types.ScilabDouble;
 import org.scilab.modules.types.ScilabMList;
 import org.scilab.modules.types.ScilabString;
 import org.scilab.modules.types.ScilabType;
+import org.scilab.modules.xcos.link.BasicLink;
+import org.scilab.modules.xcos.port.BasicPort;
 import org.scilab.modules.xcos.port.BasicPort.DataType;
 import org.scilab.modules.xcos.port.input.ExplicitInputPort;
 import org.scilab.modules.xcos.port.input.ImplicitInputPort;
@@ -245,21 +247,6 @@ public class InputPortElement extends AbstractElement<InputPort> {
        }
        
        /**
-        * If not connected, set the connected link id to 0.
-        * 
-        * @param from the bloc to encode
-        * @param element the element to encode into
-        * @return the updated element
-        */
-       @Override
-       public ScilabType beforeEncode(InputPort from, ScilabType element) {
-               if (from.getEdgeCount() == 0) {
-                       from.setConnectedLinkId(0);
-               }
-               return super.beforeEncode(from, element);
-       }
-       
-       /**
         * Encode the instance into the element
         * 
         * @param from the source instance
@@ -347,7 +334,12 @@ public class InputPortElement extends AbstractElement<InputPort> {
                // pin
                sciValues = (ScilabDouble) graphics.get(GRAPHICS_PIN_INDEX);
                values = sciValues.getRealPart();
-               values[alreadyDecodedCount][0] = from.getConnectedLinkId();
+               if (from.getEdgeCount() == 1) {
+                       // only set on valid connection
+                       values[alreadyDecodedCount][0] = ((BasicLink) from.getEdgeAt(0)).getOrdering();
+               } else {
+                       values[alreadyDecodedCount][0] = 0.0;
+               }
                
                // in_implicit
                sciStrings = (ScilabString) graphics.get(GRAPHICS_INIMPL_INDEX);
index 9a69355..3a5a66d 100644 (file)
@@ -152,6 +152,13 @@ public class LinkElement extends AbstractElement<BasicLink> {
                                .get(XX_INDEX).getWidth();
 
                /*
+                * Pre-condition (start and end should have been set)
+                */
+               if (start == null || end == null) {
+                       return points;
+               }
+               
+               /*
                 * The first, last and common indexes.
                 */
                final int min = 1;
@@ -214,7 +221,17 @@ public class LinkElement extends AbstractElement<BasicLink> {
                incrementIndexes(indexes, isColumnDominant);
 
                final int startPortIndex = (int) fromReal[indexes[0]][indexes[1]];
-               final int endPortIndex = (int) toReal[indexes[0]][indexes[1]];
+               if (startPortIndex == 0) {
+                       LOG.error("Link has an invalid start port");
+                       LOG.error(data.toString());
+                       return;
+               }
+               int endPortIndex = (int) toReal[indexes[0]][indexes[1]];
+               if (endPortIndex == 0) {
+                       LOG.error("Link has an invalid end port");
+                       LOG.error(data.toString());
+                       return;
+               }
 
                incrementIndexes(indexes, isColumnDominant);
 
index a77e5dc..fca4d69 100644 (file)
@@ -21,6 +21,7 @@ import org.scilab.modules.types.ScilabDouble;
 import org.scilab.modules.types.ScilabMList;
 import org.scilab.modules.types.ScilabString;
 import org.scilab.modules.types.ScilabType;
+import org.scilab.modules.xcos.link.BasicLink;
 import org.scilab.modules.xcos.port.BasicPort.DataType;
 import org.scilab.modules.xcos.port.output.ExplicitOutputPort;
 import org.scilab.modules.xcos.port.output.ImplicitOutputPort;
@@ -244,21 +245,6 @@ public class OutputPortElement extends AbstractElement<OutputPort> {
        }
        
        /**
-        * If not connected, set the connected link id to 0.
-        * 
-        * @param from the bloc to encode
-        * @param element the element to encode into
-        * @return the updated element
-        */
-       @Override
-       public ScilabType beforeEncode(OutputPort from, ScilabType element) {
-               if (from.getEdgeCount() == 0) {
-                       from.setConnectedLinkId(0);
-               }
-               return super.beforeEncode(from, element);
-       }
-       
-       /**
         * Encode the instance into the element
         * 
         * @param from the source instance
@@ -346,7 +332,12 @@ public class OutputPortElement extends AbstractElement<OutputPort> {
                // pout
                sciValues = (ScilabDouble) graphics.get(GRAPHICS_POUT_INDEX);
                values = sciValues.getRealPart();
-               values[alreadyDecodedCount][0] = from.getConnectedLinkId();
+               if (from.getEdgeCount() == 1) {
+                       // only set on valid connection
+                       values[alreadyDecodedCount][0] = ((BasicLink) from.getEdgeAt(0)).getOrdering();
+               } else {
+                       values[alreadyDecodedCount][0] = 0.0;
+               }
                
                // out_implicit
                sciStrings = (ScilabString) graphics.get(GRAPHICS_OUTIMPL_INDEX);
index aa45be1..4f80b60 100644 (file)
@@ -52,6 +52,7 @@ import com.mxgraph.util.mxRectangle;
 public abstract class BasicLink extends ScilabGraphUniqueObject {
        private static final mxGeometry DEFAULT_GEOMETRY = new mxGeometry(0, 0, 80, 80);
        private static final int DETECTION_RECTANGLE_DIMENSION = 10;
+       private transient int ordering;
 
        /**
         * Default constructor
@@ -64,14 +65,20 @@ public abstract class BasicLink extends ScilabGraphUniqueObject {
        setStyle(style);
     }
 
-    /**
-     * Set the order number of this link (will be applied to source and target)
-     * @param ordering The order number
-     */
-    public void setOrdering(int ordering) {
-       ((BasicPort) this.getSource()).setConnectedLinkId(ordering);
-       ((BasicPort) this.getTarget()).setConnectedLinkId(ordering);
-    }
+       /**
+        * @param ordering
+        *            a unique order number per instance
+        */
+       public void setOrdering(int ordering) {
+               this.ordering = ordering;
+       }
+
+       /**
+        * @return the unique order number per instance
+        */
+       public int getOrdering() {
+               return ordering;
+       }
 
     /** @param index the point index to be removed */
     public void removePoint(int index) { 
index 52227d6..be00a5c 100644 (file)
@@ -38,7 +38,6 @@ public abstract class BasicPort extends ScilabGraphUniqueObject {
     private static final int DEFAULT_DATACOLUMNS = -2;
     
     private int ordering;
-    private int connectedLinkId;
     private int dataLines;
     private int dataColumns;
     private DataType dataType = DataType.REAL_MATRIX;
@@ -171,29 +170,20 @@ public abstract class BasicPort extends ScilabGraphUniqueObject {
        return dataType;
     }
 
-    /**
-     * @param portOrdering a unique order number per type
-     */
-    public void setOrdering(int portOrdering) {
-       ordering = portOrdering;
-    }
-
-    /**
-     * @return the unique order number per type
-     */
-    public int getOrdering() {
-       return ordering;
-    }
-    
-    /** @param connectedLinkId the connected link id */
-    public void setConnectedLinkId(int connectedLinkId) {
-       this.connectedLinkId = connectedLinkId;
-    }
+       /**
+        * @param ordering
+        *            a unique order number per instance
+        */
+       public void setOrdering(int ordering) {
+               this.ordering = ordering;
+       }
 
-    /** @return the connected link id */
-    public int getConnectedLinkId() {
-       return connectedLinkId;
-    }
+       /**
+        * @return the unique order number per instance
+        */
+       public int getOrdering() {
+               return ordering;
+       }
 
     /**
      * @return the type of the port (Explicit or Implicit)
index 308d199..244efc3 100644 (file)
@@ -273,7 +273,8 @@ public final class XcosMessages {
     public static final String BLOCK_FROM = Messages.gettext("From %s");
     public static final String BLOCK_GOTO = Messages.gettext("Goto %s");
 
-       /* Error checking */
+    /* Errors */
+       public static final String ERROR_UNABLE_TO_COMPILE_THIS_SUPER_BLOCK = Messages.gettext("Error: unable to compile this SuperBlock");
        public static final String WRONG_PORT_NUMBER =  Messages.gettext("Wrong port number");
     
 // CSON: JavadocVariable
index 450843c..f2b4dc5 100644 (file)
@@ -59,7 +59,7 @@ this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
 
 curEnv->DeleteGlobalRef(this->instance);
 curEnv->DeleteGlobalRef(this->instanceClass);
-}
+curEnv->DeleteGlobalRef(this->stringArrayClass);}
 // Constructors
 Xcos::Xcos(JavaVM * jvm_) {
 jmethodID constructObject = NULL ;
@@ -106,11 +106,11 @@ curEnv->DeleteLocalRef(localInstance);
                 /* Methods ID set to NULL */
 voidxcosID=NULL; 
 voidxcosjstringID=NULL; 
-voidwarnCellByUIDjstringjstringID=NULL; 
+voidwarnCellByUIDjobjectArray_jstringID=NULL; 
 voidcloseXcosFromScilabID=NULL; 
 jintxcosDiagramToHDF5jstringjstringjbooleanID=NULL; 
-voidxcosDiagramOpenjstringjbooleanID=NULL; 
-voidxcosDiagramClosejstringID=NULL; 
+voidxcosDiagramOpenjobjectArray_ID=NULL; 
+voidxcosDiagramClosejobjectArray_ID=NULL; 
 
 
 }
@@ -135,11 +135,11 @@ throw GiwsException::JniObjectCreationException(curEnv, this->className());
         /* Methods ID set to NULL */
         voidxcosID=NULL; 
 voidxcosjstringID=NULL; 
-voidwarnCellByUIDjstringjstringID=NULL; 
+voidwarnCellByUIDjobjectArray_jstringID=NULL; 
 voidcloseXcosFromScilabID=NULL; 
 jintxcosDiagramToHDF5jstringjstringjbooleanID=NULL; 
-voidxcosDiagramOpenjstringjbooleanID=NULL; 
-voidxcosDiagramClosejstringID=NULL; 
+voidxcosDiagramOpenjobjectArray_ID=NULL; 
+voidxcosDiagramClosejobjectArray_ID=NULL; 
 
 
 }
@@ -203,24 +203,39 @@ throw GiwsException::JniCallMethodException(curEnv);
 }
 }
 
-void Xcos::warnCellByUID (JavaVM * jvm_, char * UID, char * message){
+void Xcos::warnCellByUID (JavaVM * jvm_, char ** uids, int uidsSize, char * message){
 
 JNIEnv * curEnv = NULL;
 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
 jclass cls = curEnv->FindClass( className().c_str() );
 
-jmethodID voidwarnCellByUIDjstringjstringID = curEnv->GetStaticMethodID(cls, "warnCellByUID", "(Ljava/lang/String;Ljava/lang/String;)V" ) ;
-if (voidwarnCellByUIDjstringjstringID == NULL) {
+jmethodID voidwarnCellByUIDjobjectArray_jstringID = curEnv->GetStaticMethodID(cls, "warnCellByUID", "([Ljava/lang/String;Ljava/lang/String;)V" ) ;
+if (voidwarnCellByUIDjobjectArray_jstringID == NULL) {
 throw GiwsException::JniMethodNotFoundException(curEnv, "warnCellByUID");
 }
+jclass stringArrayClass = curEnv->FindClass("java/lang/String");
 
-jstring UID_ = curEnv->NewStringUTF( UID );
-if (UID_ == NULL)
+// create java array of strings.
+jobjectArray uids_ = curEnv->NewObjectArray( uidsSize, stringArrayClass, NULL);
+if (uids_ == NULL)
+{
+throw GiwsException::JniBadAllocException(curEnv);
+}
+
+// convert each char * to java strings and fill the java array.
+for ( int i = 0; i < uidsSize; i++)
+{
+jstring TempString = curEnv->NewStringUTF( uids[i] );
+if (TempString == NULL)
 {
 throw GiwsException::JniBadAllocException(curEnv);
 }
 
+curEnv->SetObjectArrayElement( uids_, i, TempString);
 
+// avoid keeping reference on to many strings
+curEnv->DeleteLocalRef(TempString);
+}
 jstring message_ = curEnv->NewStringUTF( message );
 if (message_ == NULL)
 {
@@ -228,8 +243,9 @@ throw GiwsException::JniBadAllocException(curEnv);
 }
 
 
-                         curEnv->CallStaticVoidMethod(cls, voidwarnCellByUIDjstringjstringID ,UID_, message_);
-                        curEnv->DeleteLocalRef(UID_);
+                         curEnv->CallStaticVoidMethod(cls, voidwarnCellByUIDjobjectArray_jstringID ,uids_, message_);
+                        curEnv->DeleteLocalRef(stringArrayClass);
+curEnv->DeleteLocalRef(uids_);
 curEnv->DeleteLocalRef(message_);
 curEnv->DeleteLocalRef(cls);
 if (curEnv->ExceptionCheck()) {
@@ -293,54 +309,84 @@ return res;
 
 }
 
-void Xcos::xcosDiagramOpen (JavaVM * jvm_, char * UID, bool show){
+void Xcos::xcosDiagramOpen (JavaVM * jvm_, char ** UID, int UIDSize){
 
 JNIEnv * curEnv = NULL;
 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
 jclass cls = curEnv->FindClass( className().c_str() );
 
-jmethodID voidxcosDiagramOpenjstringjbooleanID = curEnv->GetStaticMethodID(cls, "xcosDiagramOpen", "(Ljava/lang/String;Z)V" ) ;
-if (voidxcosDiagramOpenjstringjbooleanID == NULL) {
+jmethodID voidxcosDiagramOpenjobjectArray_ID = curEnv->GetStaticMethodID(cls, "xcosDiagramOpen", "([Ljava/lang/String;)V" ) ;
+if (voidxcosDiagramOpenjobjectArray_ID == NULL) {
 throw GiwsException::JniMethodNotFoundException(curEnv, "xcosDiagramOpen");
 }
+jclass stringArrayClass = curEnv->FindClass("java/lang/String");
 
-jstring UID_ = curEnv->NewStringUTF( UID );
+// create java array of strings.
+jobjectArray UID_ = curEnv->NewObjectArray( UIDSize, stringArrayClass, NULL);
 if (UID_ == NULL)
 {
 throw GiwsException::JniBadAllocException(curEnv);
 }
 
+// convert each char * to java strings and fill the java array.
+for ( int i = 0; i < UIDSize; i++)
+{
+jstring TempString = curEnv->NewStringUTF( UID[i] );
+if (TempString == NULL)
+{
+throw GiwsException::JniBadAllocException(curEnv);
+}
 
-jboolean show_ = (static_cast<bool>(show) ? JNI_TRUE : JNI_FALSE);
+curEnv->SetObjectArrayElement( UID_, i, TempString);
 
-                         curEnv->CallStaticVoidMethod(cls, voidxcosDiagramOpenjstringjbooleanID ,UID_, show_);
-                        curEnv->DeleteLocalRef(UID_);
+// avoid keeping reference on to many strings
+curEnv->DeleteLocalRef(TempString);
+}
+                         curEnv->CallStaticVoidMethod(cls, voidxcosDiagramOpenjobjectArray_ID ,UID_);
+                        curEnv->DeleteLocalRef(stringArrayClass);
+curEnv->DeleteLocalRef(UID_);
 curEnv->DeleteLocalRef(cls);
 if (curEnv->ExceptionCheck()) {
 throw GiwsException::JniCallMethodException(curEnv);
 }
 }
 
-void Xcos::xcosDiagramClose (JavaVM * jvm_, char * UID){
+void Xcos::xcosDiagramClose (JavaVM * jvm_, char ** UID, int UIDSize){
 
 JNIEnv * curEnv = NULL;
 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
 jclass cls = curEnv->FindClass( className().c_str() );
 
-jmethodID voidxcosDiagramClosejstringID = curEnv->GetStaticMethodID(cls, "xcosDiagramClose", "(Ljava/lang/String;)V" ) ;
-if (voidxcosDiagramClosejstringID == NULL) {
+jmethodID voidxcosDiagramClosejobjectArray_ID = curEnv->GetStaticMethodID(cls, "xcosDiagramClose", "([Ljava/lang/String;)V" ) ;
+if (voidxcosDiagramClosejobjectArray_ID == NULL) {
 throw GiwsException::JniMethodNotFoundException(curEnv, "xcosDiagramClose");
 }
+jclass stringArrayClass = curEnv->FindClass("java/lang/String");
 
-jstring UID_ = curEnv->NewStringUTF( UID );
+// create java array of strings.
+jobjectArray UID_ = curEnv->NewObjectArray( UIDSize, stringArrayClass, NULL);
 if (UID_ == NULL)
 {
 throw GiwsException::JniBadAllocException(curEnv);
 }
 
+// convert each char * to java strings and fill the java array.
+for ( int i = 0; i < UIDSize; i++)
+{
+jstring TempString = curEnv->NewStringUTF( UID[i] );
+if (TempString == NULL)
+{
+throw GiwsException::JniBadAllocException(curEnv);
+}
 
-                         curEnv->CallStaticVoidMethod(cls, voidxcosDiagramClosejstringID ,UID_);
-                        curEnv->DeleteLocalRef(UID_);
+curEnv->SetObjectArrayElement( UID_, i, TempString);
+
+// avoid keeping reference on to many strings
+curEnv->DeleteLocalRef(TempString);
+}
+                         curEnv->CallStaticVoidMethod(cls, voidxcosDiagramClosejobjectArray_ID ,UID_);
+                        curEnv->DeleteLocalRef(stringArrayClass);
+curEnv->DeleteLocalRef(UID_);
 curEnv->DeleteLocalRef(cls);
 if (curEnv->ExceptionCheck()) {
 throw GiwsException::JniCallMethodException(curEnv);
index 7979b8a..657075a 100644 (file)
@@ -1,25 +1,25 @@
+<?xml version="1.0"?>
 <package name="org.scilab.modules.xcos">
-    <object name="Xcos">
-        <method name="xcos" returnType="void" modifier="static"/>
-        <method name="xcos" returnType="void" modifier="static">
-            <parameter name="fileName" type="String"/>
-        </method>
-        <method name="warnCellByUID" returnType="void" modifier="static">
-            <parameter name="UID" type="String"/>
-            <parameter name="message" type="String"/>
-        </method>
-        <method name="closeXcosFromScilab" returnType="void" modifier="static"/>
-        <method name="xcosDiagramToHDF5" returnType="int" modifier="static">
-            <parameter name="xcosFile" type="String"/>
-            <parameter name="h5File" type="String"/>
-            <parameter name="forceOverwrite" type="boolean"/>
-        </method>
-        <method name="xcosDiagramOpen" returnType="void" modifier="static">
-            <parameter name="UID" type="String"/>
-            <parameter name="show" type="boolean"/>
-        </method>
-        <method name="xcosDiagramClose" returnType="void" modifier="static">
-            <parameter name="UID" type="String"/>
-        </method>
-    </object>
+  <object name="Xcos">
+    <method name="xcos" returnType="void" modifier="static"/>
+    <method name="xcos" returnType="void" modifier="static">
+      <parameter name="fileName" type="String"/>
+    </method>
+    <method name="warnCellByUID" returnType="void" modifier="static">
+      <parameter name="uids" type="String[]"/>
+      <parameter name="message" type="String"/>
+    </method>
+    <method name="closeXcosFromScilab" returnType="void" modifier="static"/>
+    <method name="xcosDiagramToHDF5" returnType="int" modifier="static">
+      <parameter name="xcosFile" type="String"/>
+      <parameter name="h5File" type="String"/>
+      <parameter name="forceOverwrite" type="boolean"/>
+    </method>
+    <method name="xcosDiagramOpen" returnType="void" modifier="static">
+      <parameter name="UID" type="String[]"/>
+    </method>
+    <method name="xcosDiagramClose" returnType="void" modifier="static">
+      <parameter name="UID" type="String[]"/>
+    </method>
+  </object>
 </package>
index dacf4ca..bce53ef 100644 (file)
@@ -66,11 +66,12 @@ JavaVM * jvm;
 protected:
 jmethodID voidxcosID; // cache method id
 jmethodID voidxcosjstringID; // cache method id
-jmethodID voidwarnCellByUIDjstringjstringID; // cache method id
+jmethodID voidwarnCellByUIDjobjectArray_jstringID; // cache method id
+jclass stringArrayClass;
 jmethodID voidcloseXcosFromScilabID; // cache method id
 jmethodID jintxcosDiagramToHDF5jstringjstringjbooleanID; // cache method id
-jmethodID voidxcosDiagramOpenjstringjbooleanID; // cache method id
-jmethodID voidxcosDiagramClosejstringID; // cache method id
+jmethodID voidxcosDiagramOpenjobjectArray_ID; // cache method id
+jmethodID voidxcosDiagramClosejobjectArray_ID; // cache method id
 
 
 
@@ -131,15 +132,15 @@ static void xcos(JavaVM * jvm_);
 
 static void xcos(JavaVM * jvm_, char * fileName);
 
-static void warnCellByUID(JavaVM * jvm_, char * UID, char * message);
+static void warnCellByUID(JavaVM * jvm_, char ** uids, int uidsSize, char * message);
 
 static void closeXcosFromScilab(JavaVM * jvm_);
 
 static int xcosDiagramToHDF5(JavaVM * jvm_, char * xcosFile, char * h5File, bool forceOverwrite);
 
-static void xcosDiagramOpen(JavaVM * jvm_, char * UID, bool show);
+static void xcosDiagramOpen(JavaVM * jvm_, char ** UID, int UIDSize);
 
-static void xcosDiagramClose(JavaVM * jvm_, char * UID);
+static void xcosDiagramClose(JavaVM * jvm_, char ** UID, int UIDSize);
 
 
                         /**
index 9105220..013f6a8 100644 (file)
@@ -1,6 +1,7 @@
-/ =============================================================================
+// =============================================================================
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2009 - DIGITEO - Vincent COUVERT
+// Copyright (C) 2011 - DIGITEO - Clément DAVID
 //
 //  This file is distributed under the same license as the Scilab package.
 // =============================================================================
 // http://bugzilla.scilab.org/show_bug.cgi?id=5444
 //
 // <-- Short Description -->
-// On a superblock diagram, start a simulation is not applicable.
+// Error report on superblock diagram is not supported.
 
-// start xcos(SCI + "/modules/xcos/tests/nonreg_tests/bug_5444.xcos")
+xcos(SCI + "/modules/xcos/tests/nonreg_tests/bug_5444.xcos");
 
 // start simulation
-
 // After the first error message, check that superblock is highlighted and in the new window, MUX and DEMUX blocks are highlighted too.
index a224b15..2254d8d 100644 (file)
Binary files a/scilab/modules/xcos/tests/nonreg_tests/bug_5444.xcos and b/scilab/modules/xcos/tests/nonreg_tests/bug_5444.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_blocks_with_undefined_input.xcos b/scilab/modules/xcos/tests/unit_tests/error_blocks_with_undefined_input.xcos
new file mode 100644 (file)
index 0000000..5e52dad
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_blocks_with_undefined_input.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_blocks_with_undefined_input_on_sb.xcos b/scilab/modules/xcos/tests/unit_tests/error_blocks_with_undefined_input_on_sb.xcos
new file mode 100644 (file)
index 0000000..2dbaaf0
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_blocks_with_undefined_input_on_sb.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_from_without_goto.xcos b/scilab/modules/xcos/tests/unit_tests/error_from_without_goto.xcos
new file mode 100644 (file)
index 0000000..cdfd588
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_from_without_goto.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_from_without_goto_on_sb.xcos b/scilab/modules/xcos/tests/unit_tests/error_from_without_goto_on_sb.xcos
new file mode 100644 (file)
index 0000000..7680e6f
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_from_without_goto_on_sb.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_goto_same_tag.xcos b/scilab/modules/xcos/tests/unit_tests/error_goto_same_tag.xcos
new file mode 100644 (file)
index 0000000..240a777
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_goto_same_tag.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_goto_same_tag_on_sb.xcos b/scilab/modules/xcos/tests/unit_tests/error_goto_same_tag_on_sb.xcos
new file mode 100644 (file)
index 0000000..d6c5dc1
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_goto_same_tag_on_sb.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_on_block.xcos b/scilab/modules/xcos/tests/unit_tests/error_on_block.xcos
new file mode 100644 (file)
index 0000000..199bcb2
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_on_block.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_port_block_on_diagram.xcos b/scilab/modules/xcos/tests/unit_tests/error_port_block_on_diagram.xcos
new file mode 100644 (file)
index 0000000..e100807
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_port_block_on_diagram.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_ports_with_incompatible_size.xcos b/scilab/modules/xcos/tests/unit_tests/error_ports_with_incompatible_size.xcos
new file mode 100644 (file)
index 0000000..f770bc9
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_ports_with_incompatible_size.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_ports_with_incompatible_size_on_sb.xcos b/scilab/modules/xcos/tests/unit_tests/error_ports_with_incompatible_size_on_sb.xcos
new file mode 100644 (file)
index 0000000..fbba52f
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_ports_with_incompatible_size_on_sb.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_ports_with_negative_size.xcos b/scilab/modules/xcos/tests/unit_tests/error_ports_with_negative_size.xcos
new file mode 100644 (file)
index 0000000..fbf4f98
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_ports_with_negative_size.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_ports_with_negative_size_on_sb.xcos b/scilab/modules/xcos/tests/unit_tests/error_ports_with_negative_size_on_sb.xcos
new file mode 100644 (file)
index 0000000..345b178
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_ports_with_negative_size_on_sb.xcos differ
diff --git a/scilab/modules/xcos/tests/unit_tests/error_reporting.tst b/scilab/modules/xcos/tests/unit_tests/error_reporting.tst
new file mode 100644 (file)
index 0000000..c7068b8
--- /dev/null
@@ -0,0 +1,83 @@
+// ============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Clément DAVID
+//
+//  This file is distributed under the same license as the Scilab package.
+// ============================================================================
+//
+// <-- INTERACTIVE TEST -->
+// <-- TEST WITH XCOS -->
+//
+// <-- Short Description -->
+// Check all the possible errors which should be reported on the diagram.
+
+//-----------------------------------------------------------------------------
+// on c_pass1 (flow checking)
+//-----------------------------------------------------------------------------
+
+// Check the report against a removed flow path
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_blocks_with_undefined_input.xcos")
+// compile
+// a comprehensive error should be reported
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_blocks_with_undefined_input_on_sb.xcos")
+// compile
+// a comprehensive error should be reported
+
+// Check the report against a from block without a goto block
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_from_without_goto.xcos")
+// compile
+// a comprehensive error should be reported
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_from_without_goto_on_sb.xcos")
+// compile
+// a comprehensive error should be reported
+
+// Check the report against a two goto blocks with the same tag
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_goto_same_tag.xcos")
+// compile
+// a comprehensive error should be reported
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_goto_same_tag_on_sb.xcos")
+// compile
+// a comprehensive error should be reported
+
+// Check the report against a port block out of a superblock
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_port_block_on_diagram.xcos")
+// compile
+// a comprehensive error should be reported
+
+// Check the report against an unconnected superblock input
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_unconnected_sb_input.xcos")
+// compile
+// a comprehensive error should be reported
+
+//-----------------------------------------------------------------------------
+// on c_pass2 (type and size checking)
+//-----------------------------------------------------------------------------
+
+// Check the report against an unconnected superblock input
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_ports_with_incompatible_size.xcos")
+// compile
+// a comprehensive error should be reported
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_ports_with_incompatible_size_on_sb.xcos")
+// compile
+// a comprehensive error should be reported
+
+// Check the report against an output with negative size (undetermined)
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_ports_with_negative_size.xcos")
+// compile
+// a comprehensive error should be reported
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_ports_with_negative_size_on_sb.xcos")
+// compile
+// a comprehensive error should be reported
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_ports_with_negative_size_on_sb.xcos")
+// generate code for the main superblock
+// a comprehensive error should be reported
+
+//-----------------------------------------------------------------------------
+// on simulation (Coserror)
+//-----------------------------------------------------------------------------
+
+// Check the report against a non existing variable on the FROMWS block
+xcos(SCI + "/modules/xcos/tests/unit_tests/error_on_block.xcos")
+// simulate
+// a comprehensive error should be reported
+
diff --git a/scilab/modules/xcos/tests/unit_tests/error_unconnected_sb_input.xcos b/scilab/modules/xcos/tests/unit_tests/error_unconnected_sb_input.xcos
new file mode 100644 (file)
index 0000000..da9b2ae
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/error_unconnected_sb_input.xcos differ