Merge remote-tracking branch 'origin/master' into graphic 93/5393/1
Vincent COUVERT [Mon, 14 Nov 2011 11:50:21 +0000 (12:50 +0100)]
Conflicts:
scilab/Version.incl
scilab/configure
scilab/modules/core/src/java/org/scilab/modules/core/Scilab.java
scilab/modules/gui/src/java/org/scilab/modules/gui/messagebox/ScilabModalDialog.java
scilab/modules/gui/src/java/org/scilab/modules/gui/utils/BarUpdater.java
scilab/modules/jvm/src/c/InitializeJVM.c
scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/XcosTab.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/ViewViewportAction.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/palette/listener/PaletteBlockMouseListener.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/palette/listener/PaletteManagerMouseListener.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/palette/view/PaletteManagerView.java

Change-Id: I79089779efcecaf28b71bd74c811ba112e62338a

24 files changed:
1  2 
scilab/CHANGES_5.4.X
scilab/Makefile.in
scilab/build.incl.xml
scilab/configure
scilab/configure.ac
scilab/modules/core/src/java/org/scilab/modules/core/Scilab.java
scilab/modules/graph/src/java/org/scilab/modules/graph/ScilabGraph.java
scilab/modules/graph/src/java/org/scilab/modules/graph/actions/base/DefaultAction.java
scilab/modules/gui/src/java/org/scilab/modules/gui/helpbrowser/ScilabHelpBrowser.java
scilab/modules/gui/src/java/org/scilab/modules/gui/messagebox/ScilabModalDialog.java
scilab/modules/gui/src/java/org/scilab/modules/gui/utils/BarUpdater.java
scilab/modules/scicos_blocks/Makefile.am
scilab/modules/scicos_blocks/Makefile.in
scilab/modules/string/Makefile.in
scilab/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/SwingScilabVariableEditor.java
scilab/modules/xcos/Makefile.in
scilab/modules/xcos/src/java/org/scilab/modules/xcos/XcosTab.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/ViewViewportAction.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/palette/listener/PaletteBlockMouseListener.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/palette/listener/PaletteManagerMouseListener.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/palette/view/PaletteManagerView.java
scilab/modules/xml/Makefile.in

@@@ -1,18 -1,31 +1,42 @@@
              Changes between version 5.3.3 and 5.4.0 of Scilab
              =================================================
  
 +Graphic capabilities
 +====================
 +
 +* Entire refactoring of Scilab graphic capabilities.
 +
 +
 +GUI:
 +====
 +
 +* New uicontrols added: TODO
 +
  
+ Scilab Desktop:
+ ===============
+ * Thanks to this new feature, Scilab confirms its usuability and its strong
+ user-oriented approach. Scilab Desktop is the new concept behind Scilab
+ window management taking advantage of advanced Flexdock features.
+ Out of the box, Scilab is now able to save all windows layouts including the
+ help browser, the variable browser, the command history, Scinotes and Xcos.
+ Through this major improvement, position and size of all the windows will
+ be preserved from a session to an other.
+ In this context, a file browser component has been developped and fully
+ integrated in Scilab Desktop and all other components have been improved
+ to provide the best user experience for Scilab's users.
+ Scilab Desktop provides various predefined layouts:
+  - Simple      The standard Scilab console
+                => Scilab 5.3.3 (and previous versions) defaults.
+  - Integrated  The variable browser, the history browser and the file browser
+                the console are opened by default and combined around Scilab's
+                Console to provide an ergonomic working environment
+                => Scilab 5.4.0 defaults
  XML features:
  =============
  
Simple merge
Simple merge
@@@ -10297,7 -10516,7 +10517,7 @@@ $as_echo "$ac_java_classpath" >&6; 
  $as_echo_n "checking to see if the java compiler works... " >&6; }
  
      cat << \EOF > conftest.java
- // #line 10300 "configure"
 -// #line 10519 "configure"
++// #line 10520 "configure"
  
  
  public class conftest {
@@@ -10363,7 -10582,7 +10583,7 @@@ $as_echo_n "checking type of jvm... " >
      if test "x$ac_java_jvm_name" = "x" ; then
  
      cat << \EOF > conftest.java
- // #line 10366 "configure"
 -// #line 10585 "configure"
++// #line 10586 "configure"
  import gnu.java.io.EncodingManager;
  
  public class conftest {
@@@ -10426,7 -10645,7 +10646,7 @@@ $as_echo_n "checking java API version..
      # The class java.nio.charset.Charset is new to 1.4
  
      cat << \EOF > conftest.java
- // #line 10429 "configure"
 -// #line 10648 "configure"
++// #line 10649 "configure"
  import java.nio.charset.Charset;
  
  public class conftest {
      # The class java.lang.StringBuilder is new to 1.5
  
      cat << \EOF > conftest.java
- // #line 10473 "configure"
 -// #line 10692 "configure"
++// #line 10693 "configure"
  import java.lang.StringBuilder;
  
  public class conftest {
      # The class java.util.ArrayDeque is new to 1.6
  
      cat << \EOF > conftest.java
- // #line 10517 "configure"
 -// #line 10736 "configure"
++// #line 10737 "configure"
  import java.util.ArrayDeque;
  
  public class conftest {
      # The class java.nio.file.Path is new to 1.7
  
      cat << \EOF > conftest.java
- // #line 10561 "configure"
 -// #line 10780 "configure"
++// #line 10781 "configure"
  import java.nio.file.Path;
  
  public class conftest {
@@@ -11927,7 -12146,7 +12147,7 @@@ $as_echo_n "checking jgraphx... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 11930 "configure"
 -// #line 12149 "configure"
++// #line 12150 "configure"
  import com.mxgraph.model.mxCell;
  
  public class conftest {
@@@ -12021,7 -12240,7 +12241,7 @@@ $as_echo_n "checking minimal version (1
     if test "x" == "x"; then
  
      cat << \EOF > conftest.java
- // #line 12024 "configure"
 -// #line 12243 "configure"
++// #line 12244 "configure"
  import com.mxgraph.view.mxGraph;
  
  public class conftest {
     else
  
      cat << \EOF > conftest.java
- // #line 12075 "configure"
 -// #line 12294 "configure"
++// #line 12295 "configure"
  import com.mxgraph.view.mxGraph;
  
  public class conftest {
@@@ -12149,7 -12368,7 +12369,7 @@@ $as_echo_n "checking jhdf5... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 12152 "configure"
 -// #line 12371 "configure"
++// #line 12372 "configure"
  import ncsa.hdf.hdf5lib.HDF5Constants;
  
  public class conftest {
@@@ -12302,7 -12521,7 +12522,7 @@@ $as_echo_n "checking minimal version (1
     if test "x" == "x"; then
  
      cat << \EOF > conftest.java
- // #line 12305 "configure"
 -// #line 12524 "configure"
++// #line 12525 "configure"
  import ncsa.hdf.hdf5lib.H5;
  
  public class conftest {
     else
  
      cat << \EOF > conftest.java
- // #line 12360 "configure"
 -// #line 12579 "configure"
++// #line 12580 "configure"
  import ncsa.hdf.hdf5lib.H5;
  
  public class conftest {
  
                  fi
  
 -                # Docking system
 +
 +                              # scirenderer
 +
 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking scirenderer" >&5
 +$as_echo_n "checking scirenderer... " >&6; }
 +    PACKAGE_JAR_FILE=
 +    found_jar=no
 +    saved_ac_java_classpath=$ac_java_classpath
 +    DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(ls -d /usr/share/java/* 2>/dev/null) $(ls -d /usr/lib64/* 2>/dev/null) $(ls -d /usr/lib/* 2>/dev/null)  $(ls -d /usr/share/*/lib 2>/dev/null)"
 +    for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR "$_user_libdir"; do
 +      for jar in "$jardir/scirenderer.jar" "$jardir/libscirenderer.jar" "$jardir/libscirenderer-java.jar" "$jardir/scirenderer*.jar"; do
 +#    jar=`echo $jar|sed -e 's/ /\\ /'`
 +#    echo "protected $jar"
 +#    jar_resolved=`ls $jar 2>/dev/null`
 +#    echo "looking for $jar_resolved"
 +# TODO check the behaviour when spaces
 +    jars_resolved=`ls $jar 2>/dev/null`
 +    for jar_resolved in $jars_resolved; do # If several jars matches
 +        if test -e "$jar_resolved"; then
 +          export ac_java_classpath="$jar_resolved:$ac_java_classpath"
 +
 +    cat << \EOF > conftest.java
- // #line 12445 "configure"
++// #line 12665 "configure"
 +import org.scilab.forge.scirenderer.PackageInfo;
 +
 +public class conftest {
 +    public static void main(String[] argv) {
 +
 +    }
 +}
 +EOF
 +
 +    CLASSPATH=$ac_java_classpath
 +    export CLASSPATH
 +    cmd="$JAVAC ${JAVAC_FLAGS} conftest.java"
 +    if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then
 +       if test ""no"" = "no"; then
 +           echo "yes" >&5
 +
 +            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
 +$as_echo "$jar_resolved" >&6; }
 +            found_jar=yes
 +            PACKAGE_JAR_FILE=$jar_resolved
 +            break
 +
 +       else
 +              cmd="$JAVA conftest"
 +              if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
 +               echo "yes" >&5
 +
 +            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
 +$as_echo "$jar_resolved" >&6; }
 +            found_jar=yes
 +            PACKAGE_JAR_FILE=$jar_resolved
 +            break
 +
 +            else
 +                echo "configure: failed program was:" >&5
 +                cat conftest.java >&5
 +                if test -s conftest.java.output; then
 +                   STDOUT=`cat conftest.java.output`
 +                fi
 +                echo "configure: CLASSPATH was $CLASSPATH" >&5
 +
 +            ac_java_classpath=$saved_ac_java_classpath
 +
 +
 +                            fi
 +        fi
 +        if test -f conftest.java.output; then
 +           rm conftest.java.output
 +        fi
 +    else
 +        echo "configure: failed program was:" >&5
 +        cat conftest.java >&5
 +        echo "configure: CLASSPATH was $CLASSPATH" >&5
 +
 +            ac_java_classpath=$saved_ac_java_classpath
 +
 +
 +            fi
 +
 +        fi
 +      done
 +      # If ls returns several results and the first one is OK, stop the search
 +      if test "$found_jar" = "yes"; then
 +        break
 +      fi
 +      done
 +      # If found, no need to search in other directory
 +      if test "$found_jar" = "yes"; then
 +        break
 +      fi
 +    done
 +    if test "$found_jar" = "no"; then
 +      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 +$as_echo "no" >&6; }
 +      if test "" = "yes"; then
 +         { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find or use the Java package/jar scirenderer used by Scilab Renderer (looking for package org.scilab.forge.scirenderer.PackageInfo)" >&5
 +$as_echo "$as_me: WARNING: Could not find or use the Java package/jar scirenderer used by Scilab Renderer (looking for package org.scilab.forge.scirenderer.PackageInfo)" >&2;}
 +      else
 +          as_fn_error $? "Could not find or use the Java package/jar scirenderer used by Scilab Renderer (looking for package org.scilab.forge.scirenderer.PackageInfo)" "$LINENO" 5
 +      fi
 +    fi
 +
 +                              SCIRENDERER=$PACKAGE_JAR_FILE
 +
 +
 +
 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking minimal version (0.2.3) of scirenderer" >&5
 +$as_echo_n "checking minimal version (0.2.3) of scirenderer... " >&6; }
 +   saved_ac_java_classpath=$ac_java_classpath
 +   export ac_java_classpath="$SCIRENDERER:$ac_java_classpath"
 +   if test "x=" == "x"; then
 +
 +    cat << \EOF > conftest.java
- // #line 12539 "configure"
++// #line 12759 "configure"
 +import org.scilab.forge.scirenderer.PackageInfo;
 +
 +public class conftest {
 +    public static void main(String[] argv) {
 +        String minVersion="0.2.3";
 +
 +                            System.out.println(PackageInfo.VERSION);
 +                                  if (minVersion.compareTo(PackageInfo.VERSION) > 0) {
 +                                   System.exit(-1);
 +                                }
 +
 +    }
 +}
 +EOF
 +
 +    CLASSPATH=$ac_java_classpath
 +    export CLASSPATH
 +    cmd="$JAVAC ${JAVAC_FLAGS} conftest.java"
 +    if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then
 +       if test ""yes"" = "no"; then
 +           echo "yes" >&5
 +              echo "yes"
 +       else
 +              cmd="$JAVA conftest"
 +              if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
 +               echo "yes" >&5
 +                  echo "yes"
 +            else
 +                echo "configure: failed program was:" >&5
 +                cat conftest.java >&5
 +                if test -s conftest.java.output; then
 +                   STDOUT=`cat conftest.java.output`
 +                fi
 +                echo "configure: CLASSPATH was $CLASSPATH" >&5
 +                  as_fn_error $? "Wrong version of scirenderer. Expected at least 0.2.3. Found $STDOUT" "$LINENO" 5
 +                            fi
 +        fi
 +        if test -f conftest.java.output; then
 +           rm conftest.java.output
 +        fi
 +    else
 +        echo "configure: failed program was:" >&5
 +        cat conftest.java >&5
 +        echo "configure: CLASSPATH was $CLASSPATH" >&5
 +          as_fn_error $? "Wrong version of scirenderer. Expected at least 0.2.3. Found $STDOUT" "$LINENO" 5
 +            fi
 +
 +   else
 +
 +    cat << \EOF > conftest.java
- // #line 12590 "configure"
++// #line 12810 "configure"
 +import org.scilab.forge.scirenderer.PackageInfo;
 +
 +public class conftest {
 +    public static void main(String[] argv) {
 +        String minVersion="0.2.3";
 +
 +                            System.out.println(PackageInfo.VERSION);
 +                                  if (minVersion.compareTo(PackageInfo.VERSION) != 0) {
 +                                   System.exit(-1);
 +                                }
 +
 +    }
 +}
 +EOF
 +
 +    CLASSPATH=$ac_java_classpath
 +    export CLASSPATH
 +    cmd="$JAVAC ${JAVAC_FLAGS} conftest.java"
 +    if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then
 +       if test ""yes"" = "no"; then
 +           echo "yes" >&5
 +              echo "yes"
 +       else
 +              cmd="$JAVA conftest"
 +              if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
 +               echo "yes" >&5
 +                  echo "yes"
 +            else
 +                echo "configure: failed program was:" >&5
 +                cat conftest.java >&5
 +                if test -s conftest.java.output; then
 +                   STDOUT=`cat conftest.java.output`
 +                fi
 +                echo "configure: CLASSPATH was $CLASSPATH" >&5
 +                  as_fn_error $? "Wrong version of scirenderer. Expected exact version 0.2.3. Found $STDOUT" "$LINENO" 5
 +                            fi
 +        fi
 +        if test -f conftest.java.output; then
 +           rm conftest.java.output
 +        fi
 +    else
 +        echo "configure: failed program was:" >&5
 +        cat conftest.java >&5
 +        echo "configure: CLASSPATH was $CLASSPATH" >&5
 +          as_fn_error $? "Wrong version of scirenderer. Expected exact version 0.2.3. Found $STDOUT" "$LINENO" 5
 +            fi
 +
 +    fi
 +   ac_java_classpath=$saved_ac_java_classpath
 +
 +
 +               # Docking system
  
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking flexdock" >&5
  $as_echo_n "checking flexdock... " >&6; }
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 12663 "configure"
++// #line 12883 "configure"
  import org.flexdock.docking.DockingManager;
  
  public class conftest {
@@@ -12754,7 -12754,7 +12974,7 @@@ $as_echo_n "checking minimal version (0
     if test "x" == "x"; then
  
      cat << \EOF > conftest.java
--// #line 12757 "configure"
++// #line 12977 "configure"
  import org.flexdock.util.Utilities;
  
  public class conftest {
     else
  
      cat << \EOF > conftest.java
--// #line 12808 "configure"
++// #line 13028 "configure"
  import org.flexdock.util.Utilities;
  
  public class conftest {
@@@ -12878,7 -12878,7 +13098,7 @@@ $as_echo_n "checking looks... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 12881 "configure"
++// #line 13101 "configure"
  import com.jgoodies.looks.common.MenuItemRenderer;
  
  public class conftest {
@@@ -12985,7 -12985,7 +13205,7 @@@ $as_echo_n "checking jgoodies-looks... 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 12988 "configure"
++// #line 13208 "configure"
  import com.jgoodies.looks.common.MenuItemRenderer;
  
  public class conftest {
@@@ -13093,7 -13093,7 +13313,7 @@@ $as_echo_n "checking skinlf... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 13096 "configure"
++// #line 13316 "configure"
  import com.l2fprod.util.AccessUtils;
  
  public class conftest {
@@@ -13200,7 -13200,7 +13420,7 @@@ $as_echo_n "checking jogl... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 13203 "configure"
++// #line 13423 "configure"
  import javax.media.opengl.glu.GLUnurbs;
  
  public class conftest {
@@@ -13414,7 -13414,7 +13634,7 @@@ $as_echo_n "checking gluegen-rt... " >&
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 13417 "configure"
++// #line 13637 "configure"
  import com.sun.gluegen.runtime.CPU;
  
  public class conftest {
@@@ -13577,7 -13577,7 +13797,7 @@@ $as_echo_n "checking jhall... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 13580 "configure"
++// #line 13800 "configure"
  import javax.help.JHelp;
  
  public class conftest {
@@@ -13684,7 -13684,7 +13904,7 @@@ $as_echo_n "checking javahelp2... " >&6
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 13687 "configure"
++// #line 13907 "configure"
  import javax.help.JHelp;
  
  public class conftest {
@@@ -13792,7 -13792,7 +14012,7 @@@ $as_echo_n "checking jrosetta-API... " 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 13795 "configure"
++// #line 14015 "configure"
  import com.artenum.rosetta.interfaces.core.ConsoleConfiguration;
  
  public class conftest {
@@@ -13897,7 -13897,7 +14117,7 @@@ $as_echo_n "checking jrosetta-api... " 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 13900 "configure"
++// #line 14120 "configure"
  import com.artenum.rosetta.interfaces.core.ConsoleConfiguration;
  
  public class conftest {
@@@ -14005,7 -14005,7 +14225,7 @@@ $as_echo_n "checking jrosetta-engine..
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 14008 "configure"
++// #line 14228 "configure"
  import com.artenum.rosetta.core.action.AbstractConsoleAction;
  
  public class conftest {
@@@ -14098,7 -14098,7 +14318,7 @@@ $as_echo_n "checking minimal version (1
     if test "x" == "x"; then
  
      cat << \EOF > conftest.java
--// #line 14101 "configure"
++// #line 14321 "configure"
  import com.artenum.rosetta.util.ConfigurationBuilder;
  
  public class conftest {
     else
  
      cat << \EOF > conftest.java
--// #line 14152 "configure"
++// #line 14372 "configure"
  import com.artenum.rosetta.util.ConfigurationBuilder;
  
  public class conftest {
@@@ -14224,7 -14224,7 +14444,7 @@@ $as_echo_n "checking jeuclid-core... " 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 14227 "configure"
++// #line 14447 "configure"
  import net.sourceforge.jeuclid.LayoutContext;
  
  public class conftest {
@@@ -14333,7 -14333,7 +14553,7 @@@ $as_echo_n "checking fop... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 14336 "configure"
++// #line 14556 "configure"
  import org.apache.fop.pdf.PDFInfo;
  
  public class conftest {
@@@ -14440,7 -14440,7 +14660,7 @@@ $as_echo_n "checking batik-all... " >&6
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 14443 "configure"
++// #line 14663 "configure"
  import org.apache.batik.parser.Parser;
  
  public class conftest {
@@@ -14547,7 -14547,7 +14767,7 @@@ $as_echo_n "checking batik... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 14550 "configure"
++// #line 14770 "configure"
  import org.apache.batik.parser.Parser;
  
  public class conftest {
@@@ -14641,7 -14641,7 +14861,7 @@@ $as_echo_n "checking minimal version (1
     if test "x" == "x"; then
  
      cat << \EOF > conftest.java
--// #line 14644 "configure"
++// #line 14864 "configure"
  import org.apache.batik.Version;
  
  public class conftest {
     else
  
      cat << \EOF > conftest.java
--// #line 14695 "configure"
++// #line 14915 "configure"
  import org.apache.batik.Version;
  
  public class conftest {
@@@ -14765,7 -14765,7 +14985,7 @@@ $as_echo_n "checking commons-io... " >&
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 14768 "configure"
++// #line 14988 "configure"
  import org.apache.commons.io.output.CountingOutputStream;
  
  public class conftest {
@@@ -14872,7 -14872,7 +15092,7 @@@ $as_echo_n "checking xmlgraphics-common
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 14875 "configure"
++// #line 15095 "configure"
  import org.apache.xmlgraphics.util.Service;
  
  public class conftest {
@@@ -14979,7 -14979,7 +15199,7 @@@ $as_echo_n "checking avalon-framework..
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 14982 "configure"
++// #line 15202 "configure"
  import org.apache.avalon.framework.configuration.ConfigurationException;
  
  public class conftest {
@@@ -15086,7 -15086,7 +15306,7 @@@ $as_echo_n "checking xml-apis-ext... " 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 15089 "configure"
++// #line 15309 "configure"
  import org.w3c.dom.svg.SVGDocument;
  
  public class conftest {
@@@ -15193,7 -15193,7 +15413,7 @@@ $as_echo_n "checking xml-commons-apis-e
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 15196 "configure"
++// #line 15416 "configure"
  import org.w3c.dom.svg.SVGDocument;
  
  public class conftest {
@@@ -15304,7 -15304,7 +15524,7 @@@ $as_echo_n "checking commons-logging..
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 15307 "configure"
++// #line 15527 "configure"
  import org.apache.commons.logging.LogFactory;
  
  public class conftest {
@@@ -15411,7 -15411,7 +15631,7 @@@ $as_echo_n "checking jlatexmath... " >&
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 15414 "configure"
++// #line 15634 "configure"
  import org.scilab.forge.jlatexmath.TeXFormula;
  
  public class conftest {
@@@ -15505,7 -15505,7 +15725,7 @@@ $as_echo_n "checking minimal version (0
     if test "x" == "x"; then
  
      cat << \EOF > conftest.java
--// #line 15508 "configure"
++// #line 15728 "configure"
  import org.scilab.forge.jlatexmath.TeXFormula;
  
  public class conftest {
     else
  
      cat << \EOF > conftest.java
--// #line 15559 "configure"
++// #line 15779 "configure"
  import org.scilab.forge.jlatexmath.TeXFormula;
  
  public class conftest {
@@@ -15635,7 -15635,7 +15855,7 @@@ $as_echo_n "checking checkstyle... " >&
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 15638 "configure"
++// #line 15858 "configure"
  import com.puppycrawl.tools.checkstyle.CheckStyleTask;
  
  public class conftest {
@@@ -15742,7 -15742,7 +15962,7 @@@ $as_echo_n "checking commons-beanutils.
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 15745 "configure"
++// #line 15965 "configure"
  import org.apache.commons.beanutils.Converter;
  
  public class conftest {
@@@ -15849,7 -15849,7 +16069,7 @@@ $as_echo_n "checking antlr... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 15852 "configure"
++// #line 16072 "configure"
  import antlr.TokenStreamException;
  
  public class conftest {
@@@ -15956,7 -15956,7 +16176,7 @@@ $as_echo_n "checking testng... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 15959 "configure"
++// #line 16179 "configure"
  import org.testng.TestNG;
  
  public class conftest {
@@@ -16063,7 -16063,7 +16283,7 @@@ $as_echo_n "checking qdox... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 16066 "configure"
++// #line 16286 "configure"
  import com.thoughtworks.qdox.tools.QDoxTester;
  
  public class conftest {
@@@ -16170,7 -16170,7 +16390,7 @@@ $as_echo_n "checking bsh... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 16173 "configure"
++// #line 16393 "configure"
  import bsh.Console;
  
  public class conftest {
@@@ -16277,7 -16277,7 +16497,7 @@@ $as_echo_n "checking junit... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 16280 "configure"
++// #line 16500 "configure"
  import junit.framework.Assert;
  
  public class conftest {
@@@ -23836,7 -23836,7 +24056,7 @@@ CPPFLAGS="$CPPFLAGS -I$CHK_TCL_INCLUDE_
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if tcl is version $CHK_TCL_MAJOR.$CHK_TCL_MINOR or later" >&5
  $as_echo_n "checking if tcl is version $CHK_TCL_MAJOR.$CHK_TCL_MINOR or later... " >&6; }
  cat > conftest.$ac_ext <<EOF
--#line 23839 "configure"
++#line 24059 "configure"
  #include "confdefs.h"
  
  #include "$CHK_TCL_INCLUDE_PATH/$CHK_TCL_INC_NAME"
@@@ -24146,7 -24146,7 +24366,7 @@@ CPPFLAGS="$CPPFLAGS $TCL_INC_PATH -I$CH
  $as_echo_n "checking if tk is version $CHK_TK_MAJOR.$CHK_TK_MINOR or later... " >&6; }
  
  cat > conftest.$ac_ext <<EOF
--#line 24149 "configure"
++#line 24369 "configure"
  #include "confdefs.h"
  
  #include "$CHK_TK_INCLUDE_PATH/$CHK_TK_INC_NAME"
@@@ -24727,7 -24727,7 +24947,7 @@@ $as_echo_n "checking saxon... " >&6; 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 24730 "configure"
++// #line 24950 "configure"
  import com.icl.saxon.Loader;
  
  public class conftest {
@@@ -24834,7 -24834,7 +25054,7 @@@ $as_echo_n "checking jlatexmath-fop... 
            export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
--// #line 24837 "configure"
++// #line 25057 "configure"
  import org.scilab.forge.jlatexmath.fop.JLaTeXMathObj;
  
  public class conftest {
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 31144 "configure"
++#line 31364 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 31250 "configure"
++#line 31470 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
Simple merge
@@@ -49,126 -42,172 +51,176 @@@ public final class ScilabModalDialog 
      }
  
      public enum AnswerOption {
 -        OK_OPTION, CANCEL_OPTION, YES_OPTION, NO_OPTION, SAVE_EXECUTE_OPTION
 +        OK_OPTION,
 +        CANCEL_OPTION,
 +        YES_OPTION,
 +        NO_OPTION,
 +        SAVE_EXECUTE_OPTION
      }
      /**
 -     * private constructor, only static functions
 +     * private constructor, only static functions 
       */
      private ScilabModalDialog() {
      }
  
      /**
-      * @param messages : messages to display
-      * @param parent : tab to be used to set the location of the messagebox
-      * default icon "scilab"
-      * default button "OK"
+      * @param messages
+      *            : messages to display
+      * @param parent
+      *            : tab to be used to set the location of the messagebox
+      * @param title
+      *            : title of the message box default icon "scilab" default
+      *            button "OK"
       * @return index of the selected button
       */
 -    public static AnswerOption show(Tab parent, String[] messages) {
 +    public static AnswerOption show(SimpleTab parent, String[] messages) {
-         return show(parent, messages, Messages.gettext("Scilab Message"), IconType.SCILAB_ICON, ButtonType.OK);
+         return show(parent, messages, Messages.gettext("Scilab Message"),
+                 IconType.SCILAB_ICON, ButtonType.OK);
      }
  
      /**
-      * @param message : message to display
-      * @param parent : tab to be used to set the location of the messagebox
-      * default icon "scilab"
-      * default button "OK"
+      * @param message
+      *            : message to display
+      * @param parent
+      *            : tab to be used to set the location of the messagebox
+      * @param title
+      *            : title of the message box default icon "scilab" default
+      *            button "OK"
       * @return index of the selected button
       */
 -    public static AnswerOption show(Tab parent, String message) {
 +    public static AnswerOption show(SimpleTab parent, String message) {
-         return show(parent, new String[]{message}, Messages.gettext("Scilab Message"), IconType.SCILAB_ICON, ButtonType.OK);
+         return show(parent, new String[] { message },
+                 Messages.gettext("Scilab Message"), IconType.SCILAB_ICON,
+                 ButtonType.OK);
      }
  
      /**
-      * @param messages : messages to display
-      * @param parent : tab to be used to set the location of the messagebox
-      * @param title : title of the message box
-      * default icon "Warning"
-      * default button "OK"
+      * @param messages
+      *            : messages to display
+      * @param parent
+      *            : tab to be used to set the location of the messagebox
+      * @param title
+      *            : title of the message box default icon "Warning" default
+      *            button "OK"
       * @return index of the selected button
       */
 -    public static AnswerOption show(Tab parent, String[] messages, String title) {
 +    public static AnswerOption show(SimpleTab parent, String[] messages, String title) {
-         return show(parent, messages, title, IconType.SCILAB_ICON, ButtonType.OK);
+         return show(parent, messages, title, IconType.SCILAB_ICON,
+                 ButtonType.OK);
      }
  
      /**
-      * @param message : message to display
-      * @param parent : tab to be used to set the location of the messagebox
-      * @param title : title of the message box
-      * default icon "Warning"
-      * default button "OK"
+      * @param message
+      *            : message to display
+      * @param parent
+      *            : tab to be used to set the location of the messagebox
+      * @param title
+      *            : title of the message box default icon "Warning" default
+      *            button "OK"
       * @return index of the selected button
       */
 -    public static AnswerOption show(Tab parent, String message, String title) {
 +    public static AnswerOption show(SimpleTab parent, String message, String title) {
-         return show(parent, new String[]{message}, title, IconType.SCILAB_ICON, ButtonType.OK);
+         return show(parent, new String[] { message }, title,
+                 IconType.SCILAB_ICON, ButtonType.OK);
      }
  
      /**
-      * @param messages : messages to display
-      * @param parent : tab to be used to set the location of the messagebox
-      * @param title : title of the message box
-      * @param iconType : message box icon ( see IconType )
+      * @param messages
+      *            : messages to display
+      * @param parent
+      *            : tab to be used to set the location of the messagebox
+      * @param title
+      *            : title of the message box
+      * @param iconType
+      *            : message box icon ( see IconType )
       * @return index of the selected button
       */
-     public static AnswerOption show(SimpleTab parent, String[] messages, String title, ScilabModalDialog.IconType iconType) {
 -    public static AnswerOption show(Tab parent, String[] messages,
++    public static AnswerOption show(SimpleTab parent, String[] messages,
+             String title, ScilabModalDialog.IconType iconType) {
          return show(parent, messages, title, iconType, ButtonType.OK);
      }
  
      /**
-      * @param message : message to display
-      * @param parent : tab to be used to set the location of the messagebox
-      * @param title : title of the message box
-      * @param iconType : message box icon ( see IconType )
+      * @param message
+      *            : message to display
+      * @param parent
+      *            : tab to be used to set the location of the messagebox
+      * @param title
+      *            : title of the message box
+      * @param iconType
+      *            : message box icon ( see IconType )
       * @return index of the selected button
       */
-     public static AnswerOption show(SimpleTab parent, String message, String title, ScilabModalDialog.IconType iconType) {
-         return show(parent, new String[]{message}, title, iconType, ButtonType.OK);
 -    public static AnswerOption show(Tab parent, String message, String title,
++    public static AnswerOption show(SimpleTab parent, String message, String title,
+             ScilabModalDialog.IconType iconType) {
+         return show(parent, new String[] { message }, title, iconType,
+                 ButtonType.OK);
      }
  
      /**
-      * @param message : message to display
-      * @param parent : tab to be used to set the location of the messagebox
-      * @param title : title of the message box
-      * @param iconType : message box icon ( see IconType )
-      * @param buttonType : message box type ( see ButtonType )
+      * @param message
+      *            : message to display
+      * @param parent
+      *            : tab to be used to set the location of the messagebox
+      * @param title
+      *            : title of the message box
+      * @param iconType
+      *            : message box icon ( see IconType )
+      * @param buttonType
+      *            : message box type ( see ButtonType )
       * @return index of the selected button
       */
-     public static AnswerOption show(SimpleTab parent, String message, String title, 
-             ScilabModalDialog.IconType iconType, ScilabModalDialog.ButtonType buttonType) {
-         return show(parent, new String[]{message}, title, iconType, buttonType);
 -    public static AnswerOption show(Tab parent, String message, String title,
++    public static AnswerOption show(SimpleTab parent, String message, String title,
+             ScilabModalDialog.IconType iconType,
+             ScilabModalDialog.ButtonType buttonType) {
+         return show(parent, new String[] { message }, title, iconType,
+                 buttonType);
      }
  
      /**
-      * @param messages : messages to display
-      * @param parent : tab to be used to set the location of the messagebox
-      * @param title : title of the message box
-      * @param iconType : message box icon ( see IconType )
-      * @param buttonType : message box type ( see ButtonType )
+      * @param messages
+      *            : messages to display
+      * @param parent
+      *            : tab to be used to set the location of the messagebox
+      * @param title
+      *            : title of the message box
+      * @param iconType
+      *            : message box icon ( see IconType )
+      * @param buttonType
+      *            : message box type ( see ButtonType )
       * @return index of the selected button
       */
-     public static AnswerOption show(SimpleTab parent, String[] messages, String title,
-             ScilabModalDialog.IconType iconType, ScilabModalDialog.ButtonType buttonType) {
-         return show((Component) parent, messages, title, iconType, buttonType);
 -    public static AnswerOption show(Tab parent, String[] messages,
++    public static AnswerOption show(SimpleTab parent, String[] messages,
+             String title, ScilabModalDialog.IconType iconType,
+             ScilabModalDialog.ButtonType buttonType) {
+         final Component c;
+         if (parent == null) {
+             c = null;
+         } else {
 -            c = (Component) parent.getAsSimpleTab();
++            c = (Component) parent;
+         }
+         return show(c, messages, title, iconType, buttonType);
      }
  
      /**
-      * @param messages : messages to display
-      * @param parent : component to be used to set the location of the messagebox
-      * @param title : title of the message box
-      * @param iconType : message box icon ( see IconType )
-      * @param buttonType : message box type ( see ButtonType )
+      * @param messages
+      *            : messages to display
+      * @param parent
+      *            : component to be used to set the location of the messagebox
+      * @param title
+      *            : title of the message box
+      * @param iconType
+      *            : message box icon ( see IconType )
+      * @param buttonType
+      *            : message box type ( see ButtonType )
       * @return index of the selected button
       */
-     public static AnswerOption show(Component parent, String[] messages, String title,
-             ScilabModalDialog.IconType iconType, ScilabModalDialog.ButtonType buttonType) {
+     public static AnswerOption show(Component parent, String[] messages,
+             String title, ScilabModalDialog.IconType iconType,
+             ScilabModalDialog.ButtonType buttonType) {
  
 -        MessageBox messageBox = ScilabMessageBox.createMessageBox();
 +        SwingScilabMessageBox messageBox = new SwingScilabMessageBox();
          messageBox.setTitle(title);
          messageBox.setMessage(messages);
  
  
          messageBox.setIcon(iconName);
  
-         messageBox.setParentForLocation(parent);
 -        if (parent == null)
 -            ((SwingScilabMessageBox) messageBox.getAsSimpleMessageBox())
 -                    .setParentForLocation(parent);
 -
++        if (parent == null) {
++            ((SwingScilabMessageBox) messageBox).setParentForLocation(parent);
++        }
++        
          messageBox.displayAndWait();
-         int choice = (messageBox.getSelectedButton() - 1); //zero indexed
+         int choice = (messageBox.getSelectedButton() - 1); // zero indexed
  
          AnswerOption answer = AnswerOption.OK_OPTION;
  
@@@ -1,8 -1,7 +1,8 @@@
  /*
   * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
   * Copyright (C) 2007 - INRIA - Bruno JOFRET
-  * Copyright (C) 2010 - DIGITEO - ClĂ©ment DAVID
+  * Copyright (C) 2010 - DIGITEO - Clement DAVID
 + * Copyright (C) 2011 - 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
Simple merge
Simple merge
@@@ -38,10 -37,7 +37,8 @@@ import org.scilab.modules.graph.actions
  import org.scilab.modules.graph.actions.base.DefaultAction;
  import org.scilab.modules.graph.event.ArrowKeyListener;
  import org.scilab.modules.gui.bridge.menu.SwingScilabMenu;
- import org.scilab.modules.gui.bridge.menubar.SwingScilabMenuBar;
- import org.scilab.modules.gui.bridge.pushbutton.SwingScilabPushButton;
  import org.scilab.modules.gui.bridge.tab.SwingScilabTab;
 +import org.scilab.modules.gui.bridge.window.SwingScilabWindow;
  import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem;
  import org.scilab.modules.gui.menu.Menu;
  import org.scilab.modules.gui.menu.ScilabMenu;
@@@ -52,8 -48,13 +49,9 @@@ import org.scilab.modules.gui.pushbutto
  import org.scilab.modules.gui.textbox.ScilabTextBox;
  import org.scilab.modules.gui.toolbar.ScilabToolBar;
  import org.scilab.modules.gui.toolbar.ToolBar;
+ import org.scilab.modules.gui.utils.BarUpdater;
  import org.scilab.modules.gui.utils.Position;
  import org.scilab.modules.gui.utils.Size;
 -import org.scilab.modules.gui.window.ScilabWindow;
 -import org.scilab.modules.gui.window.Window;
  import org.scilab.modules.xcos.actions.AboutXcosAction;
  import org.scilab.modules.xcos.actions.CloseAction;
  import org.scilab.modules.xcos.actions.CloseViewportAction;
@@@ -116,470 -117,471 +114,473 @@@ import com.mxgraph.swing.mxGraphOutline
   * 
   * This class implement specific operation of an Xcos Tab.
   */
- //CSOFF: ClassFanOutComplexity
- //CSOFF: ClassDataAbstractionCoupling
+ // CSOFF: ClassFanOutComplexity
+ // CSOFF: ClassDataAbstractionCoupling
 -public class XcosTab extends ScilabTab {
 +public class XcosTab extends SwingScilabTab {
  
-       static {
-               DefaultAction.addIconPath(new File(ScilabConstants.SCI,
-                               "/modules/xcos/images/icons/"));
-       }
-       /*
-        * Instance fields
-        */
-       private MenuBar menuBar;
-       private Menu fileMenu;
-       private Menu recentsMenu;
-       private Menu edit;
-       private Menu view;
-       private Menu simulate;
-       private Menu format;
-       private Menu alignMenu;
-       private Menu linkStyle;
-       private Menu tools;
-       private Menu help;
-       private PushButton openAction;
-       private PushButton saveAction;
-       private PushButton saveAsAction;
-       private PushButton printAction;
-       private PushButton newDiagramAction;
-       private PushButton deleteAction;
-       private PushButton undoAction;
-       private PushButton redoAction;
-       private PushButton fitDiagramToViewAction;
-       private PushButton startAction;
-       private PushButton stopAction;
-       private PushButton zoomInAction;
-       private PushButton zoomOutAction;
-       private PushButton xcosDemonstrationAction;
-       private PushButton xcosDocumentationAction;
-       /**
-        * Default constructor
-        * 
-        * @param diagram
-        *            The associated diagram
-        */
-       public XcosTab(final XcosDiagram diagram) {
-               super(XcosMessages.XCOS);
-               /** tab association */
-               diagram.setParentTab(this);
-               initComponents(diagram);
-               setWindowIcon(new ImageIcon(
-                                               System.getenv("SCI")
-                                                               + "/modules/gui/images/icons/32x32/apps/utilities-system-monitor.png")
-                                               .getImage());
-               // No SimpleTab.addMember(ScilabComponent ...) so perform a raw
-               // association.
-               setContentPane(diagram
-                               .getAsComponent());
-               // Get the palette window position and align on it.
-               if (PaletteManager.isVisible()) {
-                       final SwingScilabWindow palWin = SwingScilabWindow.allScilabWindows
-                                       .get(PaletteManager.getInstance().getView().getParentWindowId());
-                       final Position palPosition = palWin.getPosition();
-                       final Size palSize = palWin.getDims();
-                       final Position mainPosition = new Position(palPosition.getX()
-                                       + palSize.getWidth(), palPosition.getY());
-                       
-                       final SwingScilabWindow xcosWin = SwingScilabWindow.allScilabWindows
-                                       .get(getParentWindowId());
-                       
-                       xcosWin.setPosition(mainPosition);
-               }
-               /*
-                * VIEW PORT
-                */
-               XcosTab.createViewPort(diagram);
-               setCallback(new CloseAction(diagram));
-               diagram.getAsComponent().addKeyListener(new ArrowKeyListener());
-               diagram.updateTabTitle();
-       }
-       /**
-        * Instantiate all the subcomponents of this Tab.
-        * 
-        * @param diagram
-        *            the diagram
-        */
-       private void initComponents(final XcosDiagram diagram) {
-               final SwingScilabWindow window = new SwingScilabWindow();
-               final ConfigurationManager manager = ConfigurationManager.getInstance();
-               final PositionType p = manager.getSettings().getWindows().getDiagram();
-               window.setBounds(p.getX(), p.getY(), p.getWidth(), p.getHeight());
-               /* Create the menu bar */
-               menuBar = createMenuBar(diagram);
-               setMenuBar(menuBar);
-               /* Create the toolbar */
-               final ToolBar toolBar = createToolBar(diagram);
-               setToolBar(toolBar);
-               /* Create the infoBar */
-               setInfoBar(ScilabTextBox.createTextBox());
-               window.addTab(this);
-       }
-       /**
-        * Create the windows menu bar
-        * 
-        * @param diagram
-        *            the diagram
-        * @return the Xcos diagram menu bar
-        */
-       // CSOFF: JavaNCSS
-       private MenuBar createMenuBar(final XcosDiagram diagram) {
-               menuBar = ScilabMenuBar.createMenuBar();
-               /** FILE MENU */
-               fileMenu = ScilabMenu.createMenu();
-               fileMenu.setText(XcosMessages.FILE);
-               fileMenu.setMnemonic('F');
-               fileMenu.add(NewDiagramAction.createMenu(diagram));
-               fileMenu.add(OpenAction.createMenu(diagram));
-               fileMenu.addSeparator();
-               fileMenu.add(SaveAction.createMenu(diagram));
-               fileMenu.add(SaveAsAction.createMenu(diagram));
-               fileMenu.add(ExportAction.createMenu(diagram));
-               recentsMenu = createRecentMenu();
-               fileMenu.add(recentsMenu);
-               fileMenu.add(PrintAction.createMenu(diagram));
-               fileMenu.addSeparator();
-               fileMenu.add(CloseAction.createMenu(diagram));
-               fileMenu.addSeparator();
-               fileMenu.add(QuitAction.createMenu(diagram));
-               menuBar.add(fileMenu);
-               /** Edit menu */
-               edit = ScilabMenu.createMenu();
-               edit.setText(XcosMessages.EDIT);
-               edit.setMnemonic('E');
-               menuBar.add(edit);
-               edit.add(UndoAction.undoMenu(diagram));
-               edit.add(RedoAction.redoMenu(diagram));
-               edit.addSeparator();
-               edit.add(CutAction.cutMenu(diagram));
-               edit.add(CopyAction.copyMenu(diagram));
-               edit.add(PasteAction.pasteMenu(diagram));
-               edit.add(DeleteAction.createMenu(diagram));
-               edit.addSeparator();
-               edit.add(SelectAllAction.createMenu(diagram));
-               edit.add(InvertSelectionAction.createMenu(diagram));
-               edit.addSeparator();
-               edit.add(BlockParametersAction.createMenu(diagram));
-               edit.addSeparator();
-               edit.add(RegionToSuperblockAction.createMenu(diagram));
-               /** View menu */
-               view = ScilabMenu.createMenu();
-               view.setText(XcosMessages.VIEW);
-               view.setMnemonic('V');
-               menuBar.add(view);
-               view.add(ZoomInAction.zoominMenu(diagram));
-               view.add(ZoomOutAction.zoomoutMenu(diagram));
-               view.add(FitDiagramToViewAction.createMenu(diagram));
-               view.add(NormalViewAction.createMenu(diagram));
-               view.addSeparator();
-               view.add(ViewPaletteBrowserAction.createCheckBoxMenu(diagram));
-               view.add(ViewDiagramBrowserAction.createMenu(diagram));
-               final CheckBoxMenuItem menu = ViewViewportAction
-                               .createCheckBoxMenu(diagram);
-               view.add(menu);
-               (diagram).setViewPortMenuItem(menu);
-               view.add(ViewDetailsAction.createMenu(diagram));
-               /** Simulation menu */
-               simulate = ScilabMenu.createMenu();
-               simulate.setText(XcosMessages.SIMULATION);
-               simulate.setMnemonic('S');
-               menuBar.add(simulate);
-               final MenuItem startMenu = StartAction.createMenu(diagram);
-               final MenuItem stopMenu = StopAction.createMenu(diagram);
-               simulate.add(SetupAction.createMenu(diagram));
-               simulate.add(DebugLevelAction.createMenu(diagram));
-               simulate.add(SetContextAction.createMenu(diagram));
-               simulate.add(CompileAction.createMenu(diagram));
-               simulate.add(InitModelicaAction.createMenu(diagram));
-               simulate.add(startMenu);
-               simulate.add(stopMenu);
-               /** Format menu */
-               format = ScilabMenu.createMenu();
-               format.setText(XcosMessages.FORMAT);
-               format.setMnemonic('O');
-               menuBar.add(format);
-               format.add(RotateAction.createMenu(diagram));
-               format.add(FlipAction.createMenu(diagram));
-               format.add(MirrorAction.createMenu(diagram));
-               format.add(ShowHideShadowAction.createMenu(diagram));
-               format.addSeparator();
-               alignMenu = ScilabMenu.createMenu();
-               alignMenu.setText(XcosMessages.ALIGN_BLOCKS);
-               alignMenu.add(AlignBlockActionLeft.createMenu(diagram));
-               alignMenu.add(AlignBlockActionCenter.createMenu(diagram));
-               alignMenu.add(AlignBlockActionRight.createMenu(diagram));
-               alignMenu.addSeparator();
-               alignMenu.add(AlignBlockActionTop.createMenu(diagram));
-               alignMenu.add(AlignBlockActionMiddle.createMenu(diagram));
-               alignMenu.add(AlignBlockActionBottom.createMenu(diagram));
-               format.add(alignMenu);
-               format.addSeparator();
-               format.add(BorderColorAction.createMenu(diagram));
-               format.add(FilledColorAction.createMenu(diagram));
-               format.addSeparator();
-               linkStyle = ScilabMenu.createMenu();
-               linkStyle.setText(XcosMessages.LINK_STYLE);
-               linkStyle.add(StyleHorizontalAction.createMenu(diagram));
-               linkStyle.add(StyleStraightAction.createMenu(diagram));
-               linkStyle.add(StyleVerticalAction.createMenu(diagram));
-               format.add(linkStyle);
-               format.addSeparator();
-               format.add(DiagramBackgroundAction.createMenu(diagram));
-               final CheckBoxMenuItem gridMenu = ViewGridAction
-                               .createCheckBoxMenu(diagram);
-               format.add(gridMenu);
-               /** Tools menu */
-               tools = ScilabMenu.createMenu();
-               tools.setText(XcosMessages.TOOLS);
-               tools.setMnemonic('T');
-               menuBar.add(tools);
-               tools.add(CodeGenerationAction.createMenu(diagram));
-               /** Help menu */
-               help = ScilabMenu.createMenu();
-               help.setText(XcosMessages.HELP);
-               help.setMnemonic('?');
-               menuBar.add(help);
-               help.add(XcosDocumentationAction.createMenu(diagram));
-               help.add(BlockDocumentationAction.createMenu(diagram));
-               help.addSeparator();
-               help.add(XcosDemonstrationsAction.createMenu(diagram));
-               help.addSeparator();
-               help.add(AboutXcosAction.createMenu(diagram));
-               return menuBar;
-       }
-       // CSON: JavaNCSS
-       
-       /**
-        * Create the recent menu from the previously opened files
-        * @return the recent menu
-        */
-       private Menu createRecentMenu() {
-               final Menu recent;
-               recent = ScilabMenu.createMenu();
-               recent.setText(XcosMessages.RECENT_FILES);
-               final ConfigurationManager manager = ConfigurationManager.getInstance();
-               final List<DocumentType> recentFiles = manager.getSettings()
-                               .getRecentFiles().getDocument();
-               for (int i = 0; i < recentFiles.size(); i++) {
-                       URL url;
-                       try {
-                               url = new URL(recentFiles.get(i).getUrl());
-                       } catch (final MalformedURLException e) {
-                               LogFactory.getLog(XcosTab.class).error(e);
-                               break;
-                       }
-                       recent.add(RecentFileAction.createMenu(url));
-               }
-               ConfigurationManager.getInstance().addPropertyChangeListener(
-                               ConfigurationConstants.RECENT_FILES_CHANGED,
-                               new PropertyChangeListener() {
-                                       @Override
-                                       public void propertyChange(final PropertyChangeEvent evt) {
-                                               assert evt.getPropertyName().equals(
-                                                               ConfigurationConstants.RECENT_FILES_CHANGED);
-                                               /*
-                                                * We only handle menu creation there. Return when this
-                                                * is not the case.
-                                                */
-                                               if (evt.getOldValue() != null) {
-                                                       return;
-                                               }
-                                               URL url;
-                                               try {
-                                                       url = new URL(((DocumentType) evt.getNewValue())
-                                                                       .getUrl());
-                                               } catch (final MalformedURLException e) {
-                                                       LogFactory.getLog(XcosTab.class).error(e);
-                                                       return;
-                                               }
-                                               ((SwingScilabMenu) recent.getAsSimpleMenu()).add(
-                                                               (SwingScilabMenu) RecentFileAction.createMenu(
-                                                                               url).getAsSimpleMenu(), 0);
-                                       }
-                               });
-               return recent;
-       }
-       /**
-        * Create the Tab toolbar
-        * 
-        * @param diagram
-        *            the associated diagram
-        * @return tool bar
-        */
-       private ToolBar createToolBar(final XcosDiagram diagram) {
-               final ToolBar toolBar = ScilabToolBar.createToolBar();
-               newDiagramAction = NewDiagramAction.createButton(diagram);
-               toolBar.add(newDiagramAction);
-               openAction = OpenAction.createButton(diagram);
-               toolBar.add(openAction);
-               toolBar.addSeparator();
-               saveAction = SaveAction.createButton(diagram);
-               toolBar.add(saveAction);
-               saveAsAction = SaveAsAction.createButton(diagram);
-               toolBar.add(saveAsAction);
-               toolBar.addSeparator();
-               printAction = PrintAction.createButton(diagram);
-               toolBar.add(printAction);
-               toolBar.addSeparator();
-               deleteAction = DeleteAction.createButton(diagram);
-               toolBar.add(deleteAction);
-               toolBar.addSeparator();
-               // UNDO / REDO
-               undoAction = UndoAction.undoButton(diagram);
-               redoAction = RedoAction.redoButton(diagram);
-               toolBar.add(undoAction);
-               toolBar.add(redoAction);
-               toolBar.addSeparator();
-               fitDiagramToViewAction = FitDiagramToViewAction.createButton(diagram);
-               toolBar.add(fitDiagramToViewAction);
-               toolBar.addSeparator();
-               // START / STOP
-               startAction = StartAction.createButton(diagram);
-               stopAction = StopAction.createButton(diagram);
-               toolBar.add(startAction);
-               toolBar.add(stopAction);
-               toolBar.addSeparator();
-               // ZOOMIN / ZOOMOUT
-               zoomInAction = ZoomInAction.zoominButton(diagram);
-               toolBar.add(zoomInAction);
-               zoomOutAction = ZoomOutAction.zoomoutButton(diagram);
-               toolBar.add(zoomOutAction);
-               toolBar.addSeparator();
-               xcosDemonstrationAction = XcosDemonstrationsAction
-                               .createButton(diagram);
-               toolBar.add(xcosDemonstrationAction);
-               xcosDocumentationAction = XcosDocumentationAction.createButton(diagram);
-               toolBar.add(xcosDocumentationAction);
-               return toolBar;
-       }
-       /**
-        * @param xcosDiagramm
-        *            diagram
-        */
-       private static void createViewPort(final ScilabGraph xcosDiagramm) {
-               final SwingScilabWindow outline = new SwingScilabWindow();
-               final SwingScilabTab outlineTab = new SwingScilabTab(XcosMessages.VIEWPORT);
+     static {
+         DefaultAction.addIconPath(new File(ScilabConstants.SCI,
+                 "/modules/xcos/images/icons/"));
+     }
+     /*
+      * Instance fields
+      */
+     private MenuBar menuBar;
+     private Menu fileMenu;
+     private Menu recentsMenu;
+     private Menu edit;
+     private Menu view;
+     private Menu simulate;
+     private Menu format;
+     private Menu alignMenu;
+     private Menu linkStyle;
+     private Menu tools;
+     private Menu help;
+     private PushButton openAction;
+     private PushButton saveAction;
+     private PushButton saveAsAction;
+     private PushButton printAction;
+     private PushButton newDiagramAction;
+     private PushButton deleteAction;
+     private PushButton undoAction;
+     private PushButton redoAction;
+     private PushButton fitDiagramToViewAction;
+     private PushButton startAction;
+     private PushButton stopAction;
+     private PushButton zoomInAction;
+     private PushButton zoomOutAction;
+     private PushButton xcosDemonstrationAction;
+     private PushButton xcosDocumentationAction;
+     /**
+      * Default constructor
+      * 
+      * @param diagram
+      *            The associated diagram
+      */
+     public XcosTab(final XcosDiagram diagram) {
+         super(XcosMessages.XCOS);
+         /** tab association */
+         diagram.setParentTab(this);
+         initComponents(diagram);
 -        ((SwingScilabTab) getAsSimpleTab())
 -                .setWindowIcon(new ImageIcon(
 -                        System.getenv("SCI")
 -                                + "/modules/gui/images/icons/32x32/apps/utilities-system-monitor.png")
 -                        .getImage());
++        setWindowIcon(new ImageIcon(
++                System.getenv("SCI")
++                + "/modules/gui/images/icons/32x32/apps/utilities-system-monitor.png")
++        .getImage());
+         // No SimpleTab.addMember(ScilabComponent ...) so perform a raw
+         // association.
 -        ((SwingScilabTab) getAsSimpleTab()).setContentPane(diagram
 -                .getAsComponent());
++        setContentPane(diagram.getAsComponent());
+         // Get the palette window position and align on it.
+         if (PaletteManager.isVisible()) {
 -            final Window win = PaletteManager.getInstance().getView()
 -                    .getParentWindow();
 -            final Position palPosition = win.getPosition();
 -            final Size palSize = win.getDims();
++            final SwingScilabWindow palWin = SwingScilabWindow.allScilabWindows
++                    .get(PaletteManager.getInstance().getView().getParentWindowId());
++            final Position palPosition = palWin.getPosition();
++            final Size palSize = palWin.getDims();
+             final Position mainPosition = new Position(palPosition.getX()
+                     + palSize.getWidth(), palPosition.getY());
 -            getParentWindow().setPosition(mainPosition);
++
++            final SwingScilabWindow xcosWin = SwingScilabWindow.allScilabWindows
++                    .get(getParentWindowId());
++            xcosWin.setPosition(mainPosition);
+         }
+         /*
+          * VIEW PORT
+          */
+         XcosTab.createViewPort(diagram);
+         setCallback(new CloseAction(diagram));
+         diagram.getAsComponent().addKeyListener(new ArrowKeyListener());
+         diagram.updateTabTitle();
+     }
+     /**
+      * Instantiate all the subcomponents of this Tab.
+      * 
+      * @param diagram
+      *            the diagram
+      */
+     private void initComponents(final XcosDiagram diagram) {
 -        final Window window = ScilabWindow.createWindow();
++        final SwingScilabWindow window = new SwingScilabWindow();
+         final ConfigurationManager manager = ConfigurationManager.getInstance();
+         final PositionType p = manager.getSettings().getWindows().getDiagram();
+         window.setDims(new Size(p.getWidth(), p.getHeight()));
+         window.setPosition(new Position(p.getX(), p.getY()));
+         /* Create the menu bar */
+         menuBar = createMenuBar(diagram);
 -        addMenuBar(menuBar);
++        setMenuBar(menuBar);
+         /* Create the toolbar */
+         final ToolBar toolBar = createToolBar(diagram);
 -        addToolBar(toolBar);
++        setToolBar(toolBar);
+         /* Create the infoBar */
 -        addInfoBar(ScilabTextBox.createTextBox());
++        setInfoBar(ScilabTextBox.createTextBox());
+         window.addTab(this);
+         BarUpdater.updateBars(getParentWindowId(), getMenuBar(), getToolBar(),
+                 getInfoBar(), getName());
+     }
+     /**
+      * Create the windows menu bar
+      * 
+      * @param diagram
+      *            the diagram
+      * @return the Xcos diagram menu bar
+      */
+     // CSOFF: JavaNCSS
+     private MenuBar createMenuBar(final XcosDiagram diagram) {
+         menuBar = ScilabMenuBar.createMenuBar();
+         /** FILE MENU */
+         fileMenu = ScilabMenu.createMenu();
+         fileMenu.setText(XcosMessages.FILE);
+         fileMenu.setMnemonic('F');
+         fileMenu.add(NewDiagramAction.createMenu(diagram));
+         fileMenu.add(OpenAction.createMenu(diagram));
+         fileMenu.addSeparator();
+         fileMenu.add(SaveAction.createMenu(diagram));
+         fileMenu.add(SaveAsAction.createMenu(diagram));
+         fileMenu.add(ExportAction.createMenu(diagram));
+         recentsMenu = createRecentMenu();
+         fileMenu.add(recentsMenu);
+         fileMenu.add(PrintAction.createMenu(diagram));
+         fileMenu.addSeparator();
+         fileMenu.add(CloseAction.createMenu(diagram));
+         fileMenu.addSeparator();
+         fileMenu.add(QuitAction.createMenu(diagram));
+         menuBar.add(fileMenu);
+         /** Edit menu */
+         edit = ScilabMenu.createMenu();
+         edit.setText(XcosMessages.EDIT);
+         edit.setMnemonic('E');
+         menuBar.add(edit);
+         edit.add(UndoAction.undoMenu(diagram));
+         edit.add(RedoAction.redoMenu(diagram));
+         edit.addSeparator();
+         edit.add(CutAction.cutMenu(diagram));
+         edit.add(CopyAction.copyMenu(diagram));
+         edit.add(PasteAction.pasteMenu(diagram));
+         edit.add(DeleteAction.createMenu(diagram));
+         edit.addSeparator();
+         edit.add(SelectAllAction.createMenu(diagram));
+         edit.add(InvertSelectionAction.createMenu(diagram));
+         edit.addSeparator();
+         edit.add(BlockParametersAction.createMenu(diagram));
+         edit.addSeparator();
+         edit.add(RegionToSuperblockAction.createMenu(diagram));
+         /** View menu */
+         view = ScilabMenu.createMenu();
+         view.setText(XcosMessages.VIEW);
+         view.setMnemonic('V');
+         menuBar.add(view);
+         view.add(ZoomInAction.zoominMenu(diagram));
+         view.add(ZoomOutAction.zoomoutMenu(diagram));
+         view.add(FitDiagramToViewAction.createMenu(diagram));
+         view.add(NormalViewAction.createMenu(diagram));
+         view.addSeparator();
+         view.add(ViewPaletteBrowserAction.createCheckBoxMenu(diagram));
+         view.add(ViewDiagramBrowserAction.createMenu(diagram));
+         final CheckBoxMenuItem menu = ViewViewportAction
+                 .createCheckBoxMenu(diagram);
+         view.add(menu);
+         (diagram).setViewPortMenuItem(menu);
+         view.add(ViewDetailsAction.createMenu(diagram));
+         /** Simulation menu */
+         simulate = ScilabMenu.createMenu();
+         simulate.setText(XcosMessages.SIMULATION);
+         simulate.setMnemonic('S');
+         menuBar.add(simulate);
+         final MenuItem startMenu = StartAction.createMenu(diagram);
+         final MenuItem stopMenu = StopAction.createMenu(diagram);
+         simulate.add(SetupAction.createMenu(diagram));
+         simulate.add(DebugLevelAction.createMenu(diagram));
+         simulate.add(SetContextAction.createMenu(diagram));
+         simulate.add(CompileAction.createMenu(diagram));
+         simulate.add(InitModelicaAction.createMenu(diagram));
+         simulate.add(startMenu);
+         simulate.add(stopMenu);
+         /** Format menu */
+         format = ScilabMenu.createMenu();
+         format.setText(XcosMessages.FORMAT);
+         format.setMnemonic('O');
+         menuBar.add(format);
+         format.add(RotateAction.createMenu(diagram));
+         format.add(FlipAction.createMenu(diagram));
+         format.add(MirrorAction.createMenu(diagram));
+         format.add(ShowHideShadowAction.createMenu(diagram));
+         format.addSeparator();
+         alignMenu = ScilabMenu.createMenu();
+         alignMenu.setText(XcosMessages.ALIGN_BLOCKS);
+         alignMenu.add(AlignBlockActionLeft.createMenu(diagram));
+         alignMenu.add(AlignBlockActionCenter.createMenu(diagram));
+         alignMenu.add(AlignBlockActionRight.createMenu(diagram));
+         alignMenu.addSeparator();
+         alignMenu.add(AlignBlockActionTop.createMenu(diagram));
+         alignMenu.add(AlignBlockActionMiddle.createMenu(diagram));
+         alignMenu.add(AlignBlockActionBottom.createMenu(diagram));
+         format.add(alignMenu);
+         format.addSeparator();
+         format.add(BorderColorAction.createMenu(diagram));
+         format.add(FilledColorAction.createMenu(diagram));
+         format.addSeparator();
+         linkStyle = ScilabMenu.createMenu();
+         linkStyle.setText(XcosMessages.LINK_STYLE);
+         linkStyle.add(StyleHorizontalAction.createMenu(diagram));
+         linkStyle.add(StyleStraightAction.createMenu(diagram));
+         linkStyle.add(StyleVerticalAction.createMenu(diagram));
+         format.add(linkStyle);
+         format.addSeparator();
+         format.add(DiagramBackgroundAction.createMenu(diagram));
+         final CheckBoxMenuItem gridMenu = ViewGridAction
+                 .createCheckBoxMenu(diagram);
+         format.add(gridMenu);
+         /** Tools menu */
+         tools = ScilabMenu.createMenu();
+         tools.setText(XcosMessages.TOOLS);
+         tools.setMnemonic('T');
+         menuBar.add(tools);
+         tools.add(CodeGenerationAction.createMenu(diagram));
+         /** Help menu */
+         help = ScilabMenu.createMenu();
+         help.setText(XcosMessages.HELP);
+         help.setMnemonic('?');
+         menuBar.add(help);
+         help.add(XcosDocumentationAction.createMenu(diagram));
+         help.add(BlockDocumentationAction.createMenu(diagram));
+         help.addSeparator();
+         help.add(XcosDemonstrationsAction.createMenu(diagram));
+         help.addSeparator();
+         help.add(AboutXcosAction.createMenu(diagram));
+         return menuBar;
+     }
+     // CSON: JavaNCSS
+     /**
+      * Create the recent menu from the previously opened files
+      * 
+      * @return the recent menu
+      */
+     private Menu createRecentMenu() {
+         final Menu recent;
+         recent = ScilabMenu.createMenu();
+         recent.setText(XcosMessages.RECENT_FILES);
+         final ConfigurationManager manager = ConfigurationManager.getInstance();
+         final List<DocumentType> recentFiles = manager.getSettings()
+                 .getRecentFiles().getDocument();
+         for (int i = 0; i < recentFiles.size(); i++) {
+             URL url;
+             try {
+                 url = new URL(recentFiles.get(i).getUrl());
+             } catch (final MalformedURLException e) {
+                 LogFactory.getLog(XcosTab.class).error(e);
+                 break;
+             }
+             recent.add(RecentFileAction.createMenu(url));
+         }
+         ConfigurationManager.getInstance().addPropertyChangeListener(
+                 ConfigurationConstants.RECENT_FILES_CHANGED,
+                 new PropertyChangeListener() {
+                     @Override
+                     public void propertyChange(final PropertyChangeEvent evt) {
+                         assert evt.getPropertyName().equals(
+                                 ConfigurationConstants.RECENT_FILES_CHANGED);
+                         /*
+                          * We only handle menu creation there. Return when this
+                          * is not the case.
+                          */
+                         if (evt.getOldValue() != null) {
+                             return;
+                         }
+                         URL url;
+                         try {
+                             url = new URL(((DocumentType) evt.getNewValue())
+                                     .getUrl());
+                         } catch (final MalformedURLException e) {
+                             LogFactory.getLog(XcosTab.class).error(e);
+                             return;
+                         }
+                         ((SwingScilabMenu) recent.getAsSimpleMenu()).add(
+                                 (SwingScilabMenu) RecentFileAction.createMenu(
+                                         url).getAsSimpleMenu(), 0);
+                     }
+                 });
+         return recent;
+     }
+     /**
+      * Create the Tab toolbar
+      * 
+      * @param diagram
+      *            the associated diagram
+      * @return tool bar
+      */
+     private ToolBar createToolBar(final XcosDiagram diagram) {
+         final ToolBar toolBar = ScilabToolBar.createToolBar();
+         newDiagramAction = NewDiagramAction.createButton(diagram);
+         toolBar.add(newDiagramAction);
+         openAction = OpenAction.createButton(diagram);
+         toolBar.add(openAction);
+         toolBar.addSeparator();
+         saveAction = SaveAction.createButton(diagram);
+         toolBar.add(saveAction);
+         saveAsAction = SaveAsAction.createButton(diagram);
+         toolBar.add(saveAsAction);
+         toolBar.addSeparator();
+         printAction = PrintAction.createButton(diagram);
+         toolBar.add(printAction);
+         toolBar.addSeparator();
+         deleteAction = DeleteAction.createButton(diagram);
+         toolBar.add(deleteAction);
+         toolBar.addSeparator();
+         // UNDO / REDO
+         undoAction = UndoAction.undoButton(diagram);
+         redoAction = RedoAction.redoButton(diagram);
+         toolBar.add(undoAction);
+         toolBar.add(redoAction);
+         toolBar.addSeparator();
+         fitDiagramToViewAction = FitDiagramToViewAction.createButton(diagram);
+         toolBar.add(fitDiagramToViewAction);
+         toolBar.addSeparator();
+         // START / STOP
+         startAction = StartAction.createButton(diagram);
+         stopAction = StopAction.createButton(diagram);
+         toolBar.add(startAction);
+         toolBar.add(stopAction);
+         toolBar.addSeparator();
+         // ZOOMIN / ZOOMOUT
+         zoomInAction = ZoomInAction.zoominButton(diagram);
+         toolBar.add(zoomInAction);
+         zoomOutAction = ZoomOutAction.zoomoutButton(diagram);
+         toolBar.add(zoomOutAction);
+         toolBar.addSeparator();
+         xcosDemonstrationAction = XcosDemonstrationsAction
+                 .createButton(diagram);
+         toolBar.add(xcosDemonstrationAction);
+         xcosDocumentationAction = XcosDocumentationAction.createButton(diagram);
+         toolBar.add(xcosDocumentationAction);
+         return toolBar;
+     }
+     /**
+      * @param xcosDiagramm
+      *            diagram
+      */
+     private static void createViewPort(final ScilabGraph xcosDiagramm) {
 -        final Window outline = ScilabWindow.createWindow();
 -        final Tab outlineTab = ScilabTab.createTab(XcosMessages.VIEWPORT);
++        final SwingScilabWindow outline = new SwingScilabWindow();
++        final SwingScilabTab outlineTab = new SwingScilabTab(XcosMessages.VIEWPORT);
  
-               outlineTab.setCallback(new CloseViewportAction(xcosDiagramm));
-               final MenuBar vpMenuBar = ScilabMenuBar.createMenuBar();
-               outlineTab.setMenuBar(vpMenuBar);
+         outlineTab.setCallback(new CloseViewportAction(xcosDiagramm));
+         final MenuBar vpMenuBar = ScilabMenuBar.createMenuBar();
 -        outlineTab.addMenuBar(vpMenuBar);
++        outlineTab.setMenuBar(vpMenuBar);
  
-               final Menu vpMenu = ScilabMenu.createMenu();
-               vpMenu.setText(XcosMessages.VIEWPORT);
-               vpMenu.setMnemonic('V');
-               vpMenuBar.add(vpMenu);
+         final Menu vpMenu = ScilabMenu.createMenu();
+         vpMenu.setText(XcosMessages.VIEWPORT);
+         vpMenu.setMnemonic('V');
+         vpMenuBar.add(vpMenu);
  
-               vpMenu.add(CloseViewportAction.createMenu(xcosDiagramm));
+         vpMenu.add(CloseViewportAction.createMenu(xcosDiagramm));
  
-               outlineTab.setInfoBar(ScilabTextBox.createTextBox());
 -        outlineTab.getAsSimpleTab().setInfoBar(ScilabTextBox.createTextBox());
++        outlineTab.setInfoBar(ScilabTextBox.createTextBox());
  
-               ((XcosDiagram) xcosDiagramm).setViewPort(outlineTab);
+         ((XcosDiagram) xcosDiagramm).setViewPort(outlineTab);
  
-               // Creates the graph outline component
-               final mxGraphOutline graphOutline = new mxGraphOutline(xcosDiagramm
-                               .getAsComponent());
+         // Creates the graph outline component
+         final mxGraphOutline graphOutline = new mxGraphOutline(
+                 xcosDiagramm.getAsComponent());
  
-               graphOutline.setDrawLabels(true);
+         graphOutline.setDrawLabels(true);
  
-               outlineTab.setContentPane(graphOutline);
-               outline.addTab(outlineTab);
-               outline.setBounds(0, 0, 200, 320);
-               outline.setVisible(false);
-               outlineTab.setVisible(false);
-       }
 -        ((SwingScilabTab) outlineTab.getAsSimpleTab())
 -                .setContentPane(graphOutline);
++        outlineTab.setContentPane(graphOutline);
+         outline.addTab(outlineTab);
++        outline.setBounds(0, 0, 200, 320);
+         outline.setVisible(false);
+         outlineTab.setVisible(false);
+     }
  
-       /**
-        * Set the current tab and the associated window visible when a unique Tab
-        * is docked.
-        * 
-        * @param newVisibleState the new state
-        * @see org.scilab.modules.gui.tab.ScilabTab#setVisible(boolean)
-        */
-       @Override
-       public void setVisible(final boolean newVisibleState) {
-               final SwingScilabWindow win = SwingScilabWindow.allScilabWindows
-                               .get(getParentWindowId());
-               if (win != null && win.getNbDockedObjects() == 1) {
-                       win.setVisible(newVisibleState);
-               }
+     /**
+      * Set the current tab and the associated window visible when a unique Tab
+      * is docked.
+      * 
+      * @param newVisibleState
+      *            the new state
+      * @see org.scilab.modules.gui.tab.ScilabTab#setVisible(boolean)
+      */
+     @Override
+     public void setVisible(final boolean newVisibleState) {
 -        if (getParentWindow().getNbDockedObjects() == 1) {
 -            getParentWindow().setVisible(newVisibleState);
++        final SwingScilabWindow win = SwingScilabWindow.allScilabWindows.get(getParentWindowId());
++        if (win != null && win.getNbDockedObjects() == 1) {
++            win.setVisible(newVisibleState);
+         }
  
-               super.setVisible(newVisibleState);
-       }
+         super.setVisible(newVisibleState);
+     }
  }
  
- //CSON: ClassDataAbstractionCoupling
- //CSON: ClassFanOutComplexity
+ // CSON: ClassDataAbstractionCoupling
+ // CSON: ClassFanOutComplexity
@@@ -23,43 -23,49 +23,49 @@@ import org.scilab.modules.xcos.graph.Xc
  import org.scilab.modules.xcos.utils.XcosMessages;
  
  /**
-  * Viewport tab visibility managemet 
+  * Viewport tab visibility managemet
   */
  public final class ViewViewportAction extends DefaultAction {
-       /** Name of the action */
-       public static final String NAME = XcosMessages.VIEWPORT;
-       /** Icon name of the action */
-       public static final String SMALL_ICON = "";
-       /** Mnemonic key of the action */
-       public static final int MNEMONIC_KEY = 0;
-       /** Accelerator key for the action */
-       public static final int ACCELERATOR_KEY = 0;
+     /** Name of the action */
+     public static final String NAME = XcosMessages.VIEWPORT;
+     /** Icon name of the action */
+     public static final String SMALL_ICON = "";
+     /** Mnemonic key of the action */
+     public static final int MNEMONIC_KEY = 0;
+     /** Accelerator key for the action */
+     public static final int ACCELERATOR_KEY = 0;
  
-       /**
-        * Constructor
-        * @param scilabGraph associated Scilab Graph
-        */
-       public ViewViewportAction(ScilabGraph scilabGraph) {
-               super(scilabGraph);
-       }
+     /**
+      * Constructor
+      * 
+      * @param scilabGraph
+      *            associated Scilab Graph
+      */
+     public ViewViewportAction(ScilabGraph scilabGraph) {
+         super(scilabGraph);
+     }
  
-       /**
-        * Create checkbox menu for the graph menu bar
-        * @param scilabGraph associated Scilab Graph
-        * @return the menu
-        */
-       public static CheckBoxMenuItem createCheckBoxMenu(ScilabGraph scilabGraph) {
-               return createCheckBoxMenu(scilabGraph, ViewViewportAction.class);
-       }
-       
-       /**
-        * @param e parameter
-        * @see org.scilab.modules.graph.actions.base.DefaultAction#actionPerformed(java.awt.event.ActionEvent)
-        */
-       @Override
-       public void actionPerformed(ActionEvent e) {
-               SwingScilabTab viewPort = ((XcosDiagram) getGraph(null)).getViewPort();
+     /**
+      * Create checkbox menu for the graph menu bar
+      * 
+      * @param scilabGraph
+      *            associated Scilab Graph
+      * @return the menu
+      */
+     public static CheckBoxMenuItem createCheckBoxMenu(ScilabGraph scilabGraph) {
+         return createCheckBoxMenu(scilabGraph, ViewViewportAction.class);
+     }
  
-               ((XcosDiagram) getGraph(null)).setViewPortVisible(!viewPort.isVisible());
-       }
+     /**
+      * @param e
+      *            parameter
+      * @see org.scilab.modules.graph.actions.base.DefaultAction#actionPerformed(java.awt.event.ActionEvent)
+      */
+     @Override
+     public void actionPerformed(ActionEvent e) {
 -        Tab viewPort = ((XcosDiagram) getGraph(null)).getViewPort();
++        SwingScilabTab viewPort = ((XcosDiagram) getGraph(null)).getViewPort();
+         ((XcosDiagram) getGraph(null))
+                 .setViewPortVisible(!viewPort.isVisible());
+     }
  }
@@@ -113,1734 -113,1754 +113,1754 @@@ import com.mxgraph.util.mxUtils
  // CSOFF: ClassDataAbstractionCoupling
  // CSOFF: ClassFanOutComplexity
  public class BasicBlock extends ScilabGraphUniqueObject implements Serializable {
-       /*
-        * Property names
-        */
-       /**
-        * Property name of interfaceFunctionName
-        */
-       public static final String INTERFACE_FUNCTION_NAME = "interfaceFunctionName";
-       /**
-        * Property name of simulationFunctionName
-        */
-       public static final String SIMULATION_FUNCTION_NAME = "simulationFunctionName";
-       /**
-        * Property name of simulationFunctionType
-        */
-       public static final String SIMULATION_FUNCTION_TYPE = "simulationFunctionType";
-       /**
-        * Property name of realParameters
-        */
-       public static final String REAL_PARAMETERS = "realParameters";
-       /**
-        * Property name of integerParameters
-        */
-       public static final String INTEGER_PARAMETERS = "integerParameters";
-       /**
-        * Property name of objectsParameters
-        */
-       public static final String OBJECTS_PARAMETERS = "objectsParameters";
-       /**
-        * Property name of dependsOnU
-        */
-       public static final String DEPENDS_ON_U = "dependsOnU";
-       /**
-        * Property name of dependsOnT
-        */
-       public static final String DEPENDS_ON_T = "dependsOnT";
-       /**
-        * Property name of blockType
-        */
-       public static final String BLOCK_TYPE = "blockType";
-       /**
-        * Property name of ordering
-        */
-       public static final String ORDERING = "ordering";
-       /**
-        * Property name of exprs
-        */
-       public static final String EXPRS = "exprs";
-       /**
-        * Property name of nbZerosCrossing
-        */
-       public static final String NB_ZEROS_CROSSING = "nbZerosCrossing";
-       /**
-        * Property name of nmode
-        */
-       public static final String NMODE = "nmode";
-       /**
-        * Property name of state
-        */
-       public static final String STATE = "state";
-       /**
-        * Property name of dState
-        */
-       public static final String D_STATE = "dState";
-       /**
-        * Property name of oDState
-        */
-       public static final String O_D_STATE = "oDState";
-       /**
-        * Property name of equations
-        */
-       public static final String EQUATIONS = "equations";
-       /*
-        * Default values
-        */
-       /**
-        * Default interface function name
-        */
-       public static final String DEFAULT_INTERFACE_FUNCTION = "xcos_block";
-       /**
-        * Default simulation function name
-        */
-       public static final String DEFAULT_SIMULATION_FUNCTION = "xcos_simulate";
-       /*
-        * Local constants
-        */
-       private static final String PARENT_DIAGRAM_WAS_NULL = "Parent diagram was null";
-       private static final double DEFAULT_POSITION_X = 10.0;
-       private static final double DEFAULT_POSITION_Y = 10.0;
-       private static final double DEFAULT_WIDTH = 40.0;
-       private static final double DEFAULT_HEIGHT = 40.0;
-       private static final PropertyChangeListener STYLE_UPDATER = new UpdateStyleFromInterfunction();
-       private static final Log LOG = LogFactory.getLog(BasicBlock.class);
-       /**
-        * Manage events for block parameters.
-        * 
-        * The property name is the field name, is one of: - "interfaceFunctionName"
-        * - "simulationFunctionName" - "simulationFunctionType" - "exprs" -
-        * "realParameters" - "integerParameters" - "objectsParameters" -
-        * "nbZerosCrossing" - "nmode" - "state" - "dState" - "oDState" -
-        * "equations" - "dependsOnU" - "dependsOnT" - "blockType" - "ordering"
-        * 
-        * you can easily access to then by using property name constants.
-        */
-       private PropertyChangeSupport parametersPCS = new PropertyChangeSupport(
-                       this);
-       private String interfaceFunctionName = DEFAULT_INTERFACE_FUNCTION;
-       private String simulationFunctionName = DEFAULT_SIMULATION_FUNCTION;
-       private SimulationFunctionType simulationFunctionType = SimulationFunctionType.DEFAULT;
-       private transient XcosDiagram parentDiagram;
-       private int angle;
-       private boolean isFlipped;
-       private boolean isMirrored;
-       // TODO : Must make this types evolve, but for now keep a strong link to
-       // Scilab
-       // !! WARNING !!
-       // exprs = [] ; rpar = [] ; ipar = [] ; opar = list()
-       // private List<String> exprs = new ArrayList<String>();
-       private ScilabType exprs;
-       // private List<Double> realParameters = new ArrayList<Double>();
-       private ScilabType realParameters;
-       // private List<Integer> integerParameters = new ArrayList<Integer>();
-       private ScilabType integerParameters;
-       // private List objectsParameters = new ArrayList();
-       private ScilabType objectsParameters;
-       private ScilabType nbZerosCrossing = new ScilabDouble();
-       private ScilabType nmode = new ScilabDouble();
-       private ScilabType state = new ScilabDouble();
-       private ScilabType dState = new ScilabDouble();
-       private ScilabType oDState = new ScilabDouble();
-       private ScilabType equations;
-       private boolean dependsOnU;
-       private boolean dependsOnT;
-       private String blockType = "c";
-       private int ordering;
-       private boolean locked;
-       /**
-        * Represent a simulation function type compatible with Scilab/Scicos
-        * function type descriptors.
-        */
-       public static enum SimulationFunctionType {
-               /** event select; reduced at compilation */
-               ESELECT(-2.0),
-               /** if then else; reduced at compilation */
-               IFTHENELSE(-1.0),
-               /** first common block */
-               DEFAULT(0.0),
-               /** first native block */
-               TYPE_1(1.0),
-               /** second native block */
-               TYPE_2(2.0),
-               /** third native block */
-               TYPE_3(3.0),
-               /** forth native block */
-               C_OR_FORTRAN(4.0),
-               /** Scilab blocks */
-               SCILAB(5.0),
-               /** Debug blocks */
-               DEBUG(99),
-               /** Modelica {@link #C_OR_FORTRAN} blocks */
-               MODELICA(30004.0),
-               /** Magic types */
-               UNKNOWN(5.0),
-               /** Implicit {@link #TYPE_1} blocks */
-               OLDBLOCKS(10001.0),
-               /** Implicit {@link #C_OR_FORTRAN} blocks */
-               IMPLICIT_C_OR_FORTRAN(10004.0);
-               private double value;
-               /**
-                * Default constructor
-                * 
-                * @param scilabValue
-                *            Scilab/Scicos function type descriptor
-                */
-               private SimulationFunctionType(double scilabValue) {
-                       value = scilabValue;
-               }
-               /**
-                * Get the Java descriptor from the Scilab descriptor.
-                * 
-                * @param scilabValue
-                *            Scilab/Scicos function type descriptor
-                * @return The corresponding java descriptor
-                */
-               public static SimulationFunctionType convertScilabValue(int scilabValue) {
-                       for (SimulationFunctionType iter : SimulationFunctionType.values()) {
-                               if (iter.getAsDouble() == scilabValue) {
-                                       return iter;
-                               }
-                       }
-                       return UNKNOWN;
-               }
-               /**
-                * Get the Scilab Descriptor from the Java Descriptor
-                * 
-                * @return The corresponding Scilab/Scicos descriptor
-                */
-               public double getAsDouble() {
-                       return value;
-               }
-       };
-       /**
-        * Update the source block when the interfunction change.
-        */
-       private static final class UpdateStyleFromInterfunction implements
-                       PropertyChangeListener, Serializable {
-               /**
-                * Default constructor.
-                */
-               public UpdateStyleFromInterfunction() {
-               }
-               /**
-                * Update the label on interfunction change.
-                * 
-                * @param evt
-                *            the property change event.
-                * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
-                */
-               @Override
-               public void propertyChange(PropertyChangeEvent evt) {
-                       final BasicBlock source = (BasicBlock) evt.getSource();
-                       /*
-                        * Put the interfunction at the start of the style map to preserve
-                        * style modification.
-                        * 
-                        * oldStyle="SUPER_f;fillColor=red" newStyle="DSUPER;fillColor=red"
-                        * 
-                        * and not newStyle="fillColor=red;DSUPER"
-                        */
-                       final StyleMap style = new StyleMap((String) evt.getNewValue());
-                       style.putAll(source.getStyle());
-                       style.remove(evt.getOldValue());
-                       source.setStyle(style.toString());
-               }
-       }
-       /**
-        * Trace the parameters change on the {@link Log}.
-        * 
-        * This listener is only installed if the trace is enable.
-        */
-       private static final class TraceParametersListener implements
-                       PropertyChangeListener, Serializable {
-               private static TraceParametersListener instance;
-               /**
-                * Default constructor.
-                */
-               private TraceParametersListener() {
-                       super();
-               }
-               /**
-                * @return the instance
-                */
-               public static TraceParametersListener getInstance() {
-                       if (instance == null) {
-                               instance = new TraceParametersListener();
-                       }
-                       return instance;
-               }
-               /**
-                * Trace.
-                * 
-                * @param evt
-                *            the event
-                * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
-                */
-               @Override
-               public void propertyChange(PropertyChangeEvent evt) {
-                       LOG.trace(evt.getPropertyName() + ": " + evt.getOldValue() + ", "
-                                       + evt.getNewValue());
-               }
-       }
-       /**
-        * Default constructor.
-        */
-       public BasicBlock() {
-               super();
-               setDefaultValues();
-               setVisible(true);
-               setVertex(true);
-               if (getStyle().isEmpty() && !getInterfaceFunctionName().isEmpty()) {
-                       setStyle(getInterfaceFunctionName());
-               }
-               parametersPCS.addPropertyChangeListener(INTERFACE_FUNCTION_NAME,
-                               STYLE_UPDATER);
-               /*
-                * Trace block parameters change if applicable.
-                */
-               if (LOG.isTraceEnabled()) {
-                       parametersPCS.addPropertyChangeListener(TraceParametersListener
-                                       .getInstance());
-               }
-       }
-       /**
-        * @param label
-        *            block label
-        */
-       protected BasicBlock(String label) {
-               this();
-               setDefaultValues();
-       }
-       /**
-        * @param label
-        *            block label
-        * @param style
-        *            initial style
-        */
-       protected BasicBlock(String label, String style) {
-               this(label);
-               setStyle(style);
-       }
-       /**
-        * Initialize the block with the default values
-        */
-       protected void setDefaultValues() {
-               setVisible(true);
-               setVertex(true);
-               setConnectable(false);
-               setGeometry(new mxGeometry(DEFAULT_POSITION_X, DEFAULT_POSITION_Y,
-                               DEFAULT_WIDTH, DEFAULT_HEIGHT));
-               setValue("");
-               setStyle("");
-       }
-       /**
-        * @return parent diagram
-        */
-       public XcosDiagram getParentDiagram() {
-               return parentDiagram;
-       }
-       /**
-        * @param parentDiagram
-        *            parent diagram
-        */
-       public void setParentDiagram(XcosDiagram parentDiagram) {
-               this.parentDiagram = parentDiagram;
-       }
-       /**
-        * @return interface function name
-        */
-       public String getInterfaceFunctionName() {
-               return interfaceFunctionName;
-       }
-       /**
-        * @param interfaceFunctionName
-        *            interface function name
-        */
-       public void setInterfaceFunctionName(String interfaceFunctionName) {
-               if ((this.interfaceFunctionName == null && interfaceFunctionName != null)
-                               || !this.interfaceFunctionName.equals(interfaceFunctionName)) {
-                       final String oldValue = this.interfaceFunctionName;
-                       this.interfaceFunctionName = interfaceFunctionName;
-                       parametersPCS.firePropertyChange(INTERFACE_FUNCTION_NAME, oldValue,
-                                       interfaceFunctionName);
-               }
-       }
-       /**
-        * @param simulationFunctionName
-        *            sumulation function name
-        */
-       public void setSimulationFunctionName(String simulationFunctionName) {
-               if ((this.simulationFunctionName == null && simulationFunctionName != null)
-                               || !this.simulationFunctionName.equals(simulationFunctionName)) {
-                       final String oldValue = this.simulationFunctionName;
-                       this.simulationFunctionName = simulationFunctionName;
-                       parametersPCS.firePropertyChange(SIMULATION_FUNCTION_NAME,
-                                       oldValue, simulationFunctionName);
-               }
-       }
-       /**
-        * @return sumulation function name
-        */
-       public String getSimulationFunctionName() {
-               return simulationFunctionName;
-       }
-       /**
-        * @param scilabValue
-        *            simulation function type
-        */
-       public void setSimulationFunctionType(int scilabValue) {
-               SimulationFunctionType simFunctionType = SimulationFunctionType
-                               .convertScilabValue(scilabValue);
-               setSimulationFunctionType(simFunctionType);
-       }
-       /**
-        * @param simulationFunctionType
-        *            simulation function type
-        */
-       public void setSimulationFunctionType(
-                       SimulationFunctionType simulationFunctionType) {
-               if ((this.simulationFunctionType == null && simulationFunctionType != null)
-                               || !this.simulationFunctionType.equals(simulationFunctionType)) {
-                       final SimulationFunctionType oldValue = this.simulationFunctionType;
-                       this.simulationFunctionType = simulationFunctionType;
-                       parametersPCS.firePropertyChange(SIMULATION_FUNCTION_TYPE,
-                                       oldValue, simulationFunctionType);
-               }
-       }
-       /**
-        * @return simulation function type
-        */
-       public SimulationFunctionType getSimulationFunctionType() {
-               return simulationFunctionType;
-       }
-       /**
-        * @return real parameter ( rpar )
-        */
-       public ScilabType getRealParameters() {
-               return realParameters;
-       }
-       /**
-        * @param realParameters
-        *            reaL parameter ( rpar )
-        */
-       public void setRealParameters(ScilabType realParameters) {
-               if ((this.realParameters == null && realParameters != null)
-                               || !this.realParameters.equals(realParameters)) {
-                       final ScilabType oldValue = this.realParameters;
-                       this.realParameters = realParameters;
-                       parametersPCS.firePropertyChange(REAL_PARAMETERS, oldValue,
-                                       realParameters);
-               }
-       }
-       /**
-        * @return integer parameter ( ipar )
-        */
-       public ScilabType getIntegerParameters() {
-               return integerParameters;
-       }
-       /**
-        * @param integerParameters
-        *            integer parameter ( ipar )
-        */
-       public void setIntegerParameters(ScilabType integerParameters) {
-               if ((this.integerParameters == null && integerParameters != null)
-                               || !this.integerParameters.equals(integerParameters)) {
-                       final ScilabType oldValue = this.integerParameters;
-                       this.integerParameters = integerParameters;
-                       parametersPCS.firePropertyChange(INTEGER_PARAMETERS, oldValue,
-                                       integerParameters);
-               }
-       }
-       /**
-        * @return object parameter ( opar )
-        */
-       public ScilabType getObjectsParameters() {
-               return objectsParameters;
-       }
-       /**
-        * @param objectsParameters
-        *            object parameter ( opar )
-        */
-       public void setObjectsParameters(ScilabType objectsParameters) {
-               if ((this.objectsParameters == null && objectsParameters != null)
-                               || !this.objectsParameters.equals(objectsParameters)) {
-                       final ScilabType oldValue = this.objectsParameters;
-                       this.objectsParameters = objectsParameters;
-                       parametersPCS.firePropertyChange(OBJECTS_PARAMETERS, oldValue,
-                                       objectsParameters);
-               }
-       }
-       /**
-        * @param dependsOnU
-        *            ?
-        */
-       public void setDependsOnU(boolean dependsOnU) {
-               if (this.dependsOnU != dependsOnU) {
-                       final boolean oldValue = this.dependsOnU;
-                       this.dependsOnU = dependsOnU;
-                       parametersPCS
-                                       .firePropertyChange(DEPENDS_ON_U, oldValue, dependsOnU);
-               }
-       }
-       /**
-        * @return ?
-        */
-       public boolean isDependsOnU() {
-               return dependsOnU;
-       }
-       /**
-        * @param dependsOnT
-        *            ?
-        */
-       public void setDependsOnT(boolean dependsOnT) {
-               if (this.dependsOnT != dependsOnT) {
-                       final boolean oldValue = this.dependsOnT;
-                       this.dependsOnT = dependsOnT;
-                       parametersPCS
-                                       .firePropertyChange(DEPENDS_ON_T, oldValue, dependsOnT);
-               }
-       }
-       /**
-        * @return ?
-        */
-       public boolean isDependsOnT() {
-               return dependsOnT;
-       }
-       /**
-        * @param blockType
-        *            block type
-        */
-       public void setBlockType(String blockType) {
-               if ((this.blockType == null && blockType != null)
-                               || !this.blockType.equals(blockType)) {
-                       final String oldValue = this.blockType;
-                       this.blockType = blockType;
-                       parametersPCS.firePropertyChange(BLOCK_TYPE, oldValue, blockType);
-               }
-       }
-       /**
-        * @return block type
-        */
-       public String getBlockType() {
-               return blockType;
-       }
-       /**
-        * @param ordering
-        *            order value
-        */
-       public void setOrdering(int ordering) {
-               if (this.ordering != ordering) {
-                       final int oldValue = this.ordering;
-                       this.ordering = ordering;
-                       parametersPCS.firePropertyChange(ORDERING, oldValue, ordering);
-               }
-       }
-       /**
-        * @return order value
-        */
-       public int getOrdering() {
-               return ordering;
-       }
-       /**
-        * @param exprs
-        *            expression
-        */
-       public void setExprs(ScilabType exprs) {
-               if ((this.exprs == null && exprs != null) || !this.exprs.equals(exprs)) {
-                       final ScilabType oldValue = this.exprs;
-                       this.exprs = exprs;
-                       parametersPCS.firePropertyChange(EXPRS, oldValue, exprs);
-               }
-       }
-       /**
-        * @return expression
-        */
-       public ScilabType getExprs() {
-               return exprs;
-       }
-       /**
-        * @return the expression as a object array
-        */
-       public Object[] getExprsFormat() {
-               // evaluate emptiness
-               if (getExprs() == null || getExprs().isEmpty()
-                               || getExprs().getHeight() == 0 || getExprs().getWidth() == 0) {
-                       return new String[0];
-               }
-               List<String[]> stack = getString(null, getExprs());
-               int len = 0;
-               for (Object[] strings : stack) {
-                       len += strings.length;
-               }
-               final Object[] array = new Object[len];
-               int start = 0;
-               for (Object[] strings : stack) {
-                       System.arraycopy(strings, 0, array, start, strings.length);
-                       start += strings.length;
-               }
-               return array;
-       }
-       /**
-        * Append the data recursively to the stack
-        * 
-        * @param currentStack
-        *            the current stack
-        * @param data
-        *            the data to append
-        * @return the stack
-        */
-       private List<String[]> getString(List<String[]> currentStack,
-                       ScilabType data) {
-               final List<String[]> stack;
-               if (currentStack == null) {
-                       stack = new LinkedList<String[]>();
-               } else {
-                       stack = currentStack;
-               }
-               if (data instanceof List) {
-                       /*
-                        * Container case (ScilabList, ScilabMList, ScilabTList)
-                        */
-                       @SuppressWarnings("unchecked")
-                       final List<ScilabType> list = (List<ScilabType>) data;
-                       for (final ScilabType scilabType : list) {
-                               getString(stack, scilabType);
-                       }
-               } else if (data instanceof ScilabString) {
-                       /*
-                        * native case (only ScilabString supported)
-                        */
-                       final String[][] scilabData = ((ScilabString) data).getData();
-                       final int height = data.getHeight();
-                       final int width = data.getWidth();
-                       final String[] array = new String[height * width];
-                       for (int i = 0; i < height; ++i) {
-                               System.arraycopy(scilabData[i], 0, array, i * width, width);
-                       }
-                       stack.add(array);
-               }
-               return stack;
-       }
-       /**
-        * @return zero crossing value
-        */
-       public ScilabType getNbZerosCrossing() {
-               return nbZerosCrossing;
-       }
-       /**
-        * @param nbZerosCrossing
-        *            zero crossing value
-        */
-       public void setNbZerosCrossing(ScilabType nbZerosCrossing) {
-               if ((this.nbZerosCrossing == null && nbZerosCrossing != null)
-                               || !this.nbZerosCrossing.equals(nbZerosCrossing)) {
-                       final ScilabType oldValue = this.nbZerosCrossing;
-                       this.nbZerosCrossing = nbZerosCrossing;
-                       parametersPCS.firePropertyChange(NB_ZEROS_CROSSING, oldValue,
-                                       nbZerosCrossing);
-               }
-       }
-       /**
-        * @return nmode
-        */
-       public ScilabType getNmode() {
-               return nmode;
-       }
-       /**
-        * @param nmode
-        *            nmode
-        */
-       public void setNmode(ScilabType nmode) {
-               if ((this.nmode == null && nmode != null) || !this.nmode.equals(nmode)) {
-                       final ScilabType oldValue = this.nmode;
-                       this.nmode = nmode;
-                       parametersPCS.firePropertyChange(NMODE, oldValue, nmode);
-               }
-       }
-       /**
-        * @return current state
-        */
-       public ScilabType getState() {
-               return state;
-       }
-       /**
-        * @param state
-        *            new state
-        */
-       public void setState(ScilabType state) {
-               if ((this.state == null && state != null) || !this.state.equals(state)) {
-                       final ScilabType oldValue = this.state;
-                       this.state = state;
-                       parametersPCS.firePropertyChange(STATE, oldValue, state);
-               }
-       }
-       /**
-        * @return current dstate
-        */
-       public ScilabType getDState() {
-               return dState;
-       }
-       /**
-        * @param dState
-        *            new dstate
-        */
-       public void setDState(ScilabType dState) {
-               if ((this.dState == null && dState != null)
-                               || !this.dState.equals(dState)) {
-                       final ScilabType oldValue = this.dState;
-                       this.dState = dState;
-                       parametersPCS.firePropertyChange(D_STATE, oldValue, dState);
-               }
-       }
-       /**
-        * @return current ostate
-        */
-       public ScilabType getODState() {
-               return oDState;
-       }
-       /**
-        * @param oDState
-        *            new odstate
-        */
-       public void setODState(ScilabType oDState) {
-               if ((this.oDState == null && oDState != null)
-                               || !this.oDState.equals(oDState)) {
-                       final ScilabType oldValue = this.oDState;
-                       this.oDState = oDState;
-                       parametersPCS.firePropertyChange(O_D_STATE, oldValue, oDState);
-               }
-       }
-       /**
-        * @return equations
-        */
-       public ScilabType getEquations() {
-               return equations;
-       }
-       /**
-        * @param equations
-        *            equations
-        */
-       public void setEquations(ScilabType equations) {
-               if ((this.equations == null && equations != null)
-                               || !this.equations.equals(equations)) {
-                       final ScilabType oldValue = this.equations;
-                       this.equations = equations;
-                       parametersPCS.firePropertyChange(EQUATIONS, oldValue, equations);
-               }
-       }
-       /**
-        * @return locked status
-        */
-       public synchronized boolean isLocked() {
-               return locked;
-       }
-       /**
-        * @param locked
-        *            change locked status
-        */
-       public synchronized void setLocked(boolean locked) {
-               this.locked = locked;
-       }
-       /**
-        * @param port
-        *            to remove
-        */
-       public void removePort(BasicPort port) {
-               if (port.getEdgeCount() != 0 && getParentDiagram() != null) {
-                       getParentDiagram().removeCells(new Object[] { port.getEdgeAt(0) });
-               }
-               remove(port);
-       }
-       /**
-        * Add a port on the block.
-        * 
-        * This call should only be used when a port reordering operation must be
-        * performed.
-        * 
-        * @param port
-        *            The port to be added to the block
-        */
-       public void addPort(BasicPort port) {
-               insert(port);
-               port.setOrdering(BasicBlockInfo.getAllTypedPorts(this, false,
-                               port.getClass()).size());
-               BlockPositioning.updateBlockView(this);
-       }
-       /**
-        * @return command ports initial state
-        */
-       public ScilabDouble getAllCommandPortsInitialStates() {
-               final List<CommandPort> cmdPorts = BasicBlockInfo.getAllTypedPorts(
-                               this, false, CommandPort.class);
-               if (cmdPorts.isEmpty()) {
-                       return new ScilabDouble();
-               }
-               double[][] data = new double[cmdPorts.size()][1];
-               for (int i = 0; i < cmdPorts.size(); ++i) {
-                       data[i][0] = cmdPorts.get(i).getInitialState();
-               }
-               return new ScilabDouble(data);
-       }
-       /**
-        * @return name and type of the simulation function
-        */
-       public ScilabType getSimulationFunctionNameAndType() {
-               if (getSimulationFunctionType() == SimulationFunctionType.DEFAULT) {
-                       return new ScilabString(getSimulationFunctionName());
-               }
-               ScilabList data = new ScilabList();
-               data.add(new ScilabString(getSimulationFunctionName()));
-               data.add(new ScilabDouble(getSimulationFunctionType().getAsDouble()));
-               return data;
-       }
-       /**
-        * Does the block update and register on the undo manager
-        * 
-        * @param modifiedBlock
-        *            the new settings
-        */
-       public void updateBlockSettings(BasicBlock modifiedBlock) {
-               if (modifiedBlock == null) {
-                       return;
-               }
-               /*
-                * Update the block settings
-                */
-               updateFields(modifiedBlock);
-               /*
-                * Update the children ports
-                */
-               if (children != null) {
-                       updateChildren(modifiedBlock);
-               }
-               /*
-                * If the block is in a superblock then update it.
-                */
-               if (getParentDiagram() instanceof SuperBlockDiagram) {
-                       SuperBlock block = ((SuperBlockDiagram) getParentDiagram())
-                                       .getContainer();
-                       XcosDiagram graph = block.getParentDiagram();
-                       if (graph == null) {
-                               setParentDiagram(Xcos.findParent(block));
-                               graph = block.getParentDiagram();
-                               LogFactory.getLog(getClass()).error(PARENT_DIAGRAM_WAS_NULL);
-                       }
-                       graph.fireEvent(new mxEventObject(XcosEvent.SUPER_BLOCK_UPDATED,
-                                       XcosConstants.EVENT_BLOCK_UPDATED, block));
-               }
-       }
-       /**
-        * Update the instance field.
-        * 
-        * @param modifiedBlock
-        *            the modified instance
-        */
-       private void updateFields(BasicBlock modifiedBlock) {
-               if (modifiedBlock == null) {
-                       return;
-               }
-               setDependsOnT(modifiedBlock.isDependsOnT());
-               setDependsOnU(modifiedBlock.isDependsOnU());
-               setExprs(modifiedBlock.getExprs());
-               setRealParameters(modifiedBlock.getRealParameters());
-               setIntegerParameters(modifiedBlock.getIntegerParameters());
-               setObjectsParameters(modifiedBlock.getObjectsParameters());
-               setState(modifiedBlock.getState());
-               setDState(modifiedBlock.getDState());
-               setODState(modifiedBlock.getODState());
-               setEquations(modifiedBlock.getEquations());
-               setStyle(modifiedBlock.getStyle());
-       }
-       /**
-        * Update the children of the block.
-        * 
-        * @param modifiedBlock
-        *            the new block instance
-        */
-       private void updateChildren(BasicBlock modifiedBlock) {
-               if (modifiedBlock == null) {
-                       return;
-               }
-               XcosDiagram graph = getParentDiagram();
-               if (graph == null) {
-                       setParentDiagram(Xcos.findParent(this));
-                       graph = getParentDiagram();
-                       LogFactory.getLog(getClass()).error(PARENT_DIAGRAM_WAS_NULL);
-               }
-               /*
-                * Checked as port classes only
-                */
-               @SuppressWarnings("unchecked")
-               Set<Class<? extends mxICell>> types = new HashSet<Class<? extends mxICell>>(
-                               Arrays.asList(InputPort.class, OutputPort.class,
-                                               ControlPort.class, CommandPort.class));
-               Map<Class<? extends mxICell>, Deque<mxICell>> annotatedOlds = getTypedChildren(types);
-               Map<Class<? extends mxICell>, Deque<mxICell>> annotatedNews = modifiedBlock
-                               .getTypedChildren(types);
-               getParentDiagram().getModel().beginUpdate();
-               try {
-                       for (Class<? extends mxICell> klass : types) {
-                               final Deque<mxICell> olds = annotatedOlds.get(klass);
-                               final Deque<mxICell> news = annotatedNews.get(klass);
-                               // updated ports
-                               while (!olds.isEmpty() && !news.isEmpty()) {
-                                       mxICell previous = olds.poll();
-                                       mxICell modified = news.poll();
-                                       final int previousIndex = children.indexOf(previous);
-                                       // relink
-                                       if (previous.getEdgeCount() != 0) {
-                                               final mxICell edge = previous.getEdgeAt(0);
-                                               final boolean isOutgoing = previous == edge
-                                                               .getTerminal(true);
-                                               previous.removeEdge(edge, isOutgoing);
-                                               modified.insertEdge(edge, isOutgoing);
-                                       }
-                                       getParentDiagram().removeCells(new Object[] { previous },
-                                                       false);
-                                       getParentDiagram().addCells(new Object[] { modified },
-                                                       this, previousIndex);
-                                       // Clone the geometry to avoid empty geometry on new cells.
-                                       getParentDiagram().getModel().setGeometry(modified,
-                                                       (mxGeometry) previous.getGeometry().clone());
-                               }
-                               // removed ports
-                               if (!olds.isEmpty()) {
-                                       getParentDiagram().removeCells(olds.toArray(), true);
-                               }
-                               // added ports
-                               if (!news.isEmpty()) {
-                                       getParentDiagram().addCells(news.toArray(), this);
-                               }
-                       }
-               } finally {
-                       getParentDiagram().getModel().endUpdate();
-               }
-       }
-       /**
-        * Format the children as a typed map for the given class set.
-        * 
-        * @param types
-        *            the classes to search for.
-        * @return a map which linked foreach type the corresponding cell list.
-        */
-       private Map<Class<? extends mxICell>, Deque<mxICell>> getTypedChildren(
-                       Set<Class<? extends mxICell>> types) {
-               Map<Class<? extends mxICell>, Deque<mxICell>> oldPorts = new HashMap<Class<? extends mxICell>, Deque<mxICell>>();
-               // Allocate all types set
-               for (Class<? extends mxICell> type : types) {
-                       oldPorts.put(type, new LinkedList<mxICell>());
-               }
-               // sort children according to the ordering parameter (useful on
-               // scilab-5.2.x diagrams)
-               Collections.sort(children, new Comparator<Object>() {
-                       @Override
-                       public int compare(Object o1, Object o2) {
-                               if (o1 instanceof BasicPort && o2 instanceof BasicPort) {
-                                       return ((BasicPort) o1).getOrdering()
-                                                       - ((BasicPort) o2).getOrdering();
-                               } else {
-                                       return 0;
-                               }
-                       }
-               });
-               // children lookup
-               for (Object cell : children) {
-                       Class<? extends Object> klass = cell.getClass();
-                       while (klass != null) {
-                               if (types.contains(klass)) {
-                                       break;
-                               }
-                               klass = klass.getSuperclass();
-                       }
-                       final Deque<mxICell> current = oldPorts.get(klass);
-                       if (current != null) {
-                               current.add((mxICell) cell);
-                       }
-               }
-               return oldPorts;
-       }
-       /**
-        * @param context
-        *            parent diagram context
-        */
-       public void openBlockSettings(String[] context) {
-               final XcosDiagram graph;
-               if (getParentDiagram() == null) {
-                       setParentDiagram(Xcos.findParent(this));
-                       graph = getParentDiagram();
-                       LogFactory.getLog(getClass()).error(PARENT_DIAGRAM_WAS_NULL);
-               } else {
-                       graph = getParentDiagram();
-               }
-               if (getParentDiagram() instanceof PaletteDiagram) {
-                       return;
-               }
-               if (context == null) {
-                       throw new IllegalArgumentException();
-               }
-               // prevent to open twice
-               if (isLocked()) {
-                       return;
-               }
-               final String tempOutput;
-               final String tempInput;
-               final String tempContext;
-               final BasicBlock currentBlock = this;
-               try {
-                       tempInput = FileUtils.createTempFile();
-                       // Write scs_m
-                       tempOutput = exportBlockStruct();
-                       // Write context
-                       tempContext = exportContext(context);
-                       final ActionListener action = new ActionListener() {
-                               @Override
-                               public void actionPerformed(ActionEvent e) {
-                                       if (exists(tempInput)) {
-                                               LOG.trace("Updating data.");
-                                               graph.getView().clear(this, true, true);
-                                               // Now read new Block
-                                               graph.getModel().beginUpdate();
-                                               try {
-                                                       BasicBlock modifiedBlock = new H5RWHandler(
-                                                                       tempInput).readBlock();
-                                                       updateBlockSettings(modifiedBlock);
-                                                       graph.fireEvent(new mxEventObject(
-                                                                       XcosEvent.ADD_PORTS,
-                                                                       XcosConstants.EVENT_BLOCK_UPDATED,
-                                                                       currentBlock));
-                                               } catch (ScicosFormatException e1) {
-                                                       LOG.error(e1);
-                                               } finally {
-                                                       graph.getModel().endUpdate();
-                                               }
-                                               delete(tempInput);
-                                       } else {
-                                               LOG.trace("No needs to update data.");
-                                       }
-                                       delete(tempOutput);
-                                       delete(tempContext);
-                                       setLocked(false);
-                               }
-                       };
-                       try {
-                               setLocked(true);
-                               ScilabInterpreterManagement.asynchronousScilabExec(action,
-                                               "xcosBlockInterface", tempOutput, tempInput,
-                                               getInterfaceFunctionName().toCharArray(), "set",
-                                               tempContext);
-                       } catch (InterpreterException e) {
-                               LOG.error(e);
-                               setLocked(false);
-                       }
-               } catch (IOException e) {
-                       LOG.error(e);
-               }
-       }
-       /**
-        * @return exported file
-        */
-       protected String exportBlockStruct() {
-               // Write scs_m
-               String tempOutput;
-               try {
-                       tempOutput = FileUtils.createTempFile();
-                       File f = new File(tempOutput);
-                       f.deleteOnExit();
-                       new H5RWHandler(tempOutput).writeBlock(this);
-                       return tempOutput;
-               } catch (IOException e) {
-                       e.printStackTrace();
-               }
-               return null;
-       }
-       /**
-        * @param context
-        *            parent diagram context
-        * @return exported file
-        */
-       protected String exportContext(String[] context) {
-               // Write context
-               try {
-                       String fileString = FileUtils.createTempFile();
-                       File tempContext = new File(fileString);
-                       tempContext.deleteOnExit();
-                       int contextFileId = H5Write.createFile(tempContext
-                                       .getAbsolutePath());
-                       H5Write.writeInDataSet(contextFileId, "context", new ScilabString(
-                                       context));
-                       H5Write.closeFile(contextFileId);
-                       return fileString;
-               } catch (IOException e) {
-                       e.printStackTrace();
-               } catch (HDF5Exception e) {
-                       e.printStackTrace();
-               }
-               return null;
-       }
-       /**
-        * @return tooltip text
-        */
-       public String getToolTipText() {
-               StringBuilder result = new StringBuilder();
-               result.append(ScilabGraphConstants.HTML_BEGIN);
-               result.append("Block Name : " + getInterfaceFunctionName()
-                               + ScilabGraphConstants.HTML_NEWLINE);
-               result.append("Simulation : " + getSimulationFunctionName()
-                               + ScilabGraphConstants.HTML_NEWLINE);
-               if (getParentDiagram() instanceof PaletteDiagram) {
-                       if (getIntegerParameters() != null) {
-                               result.append("Integer parameters : " + getIntegerParameters()
-                                               + ScilabGraphConstants.HTML_NEWLINE);
-                       }
-                       if (getRealParameters() != null
-                                       && getRealParameters().getHeight() != 0
-                                       && getRealParameters().getWidth() != 0) {
-                               result.append("Real parameters : " + getRealParameters()
-                                               + ScilabGraphConstants.HTML_NEWLINE);
-                       }
-                       if (getObjectsParameters() != null) {
-                               result.append("Object parameters : " + getObjectsParameters()
-                                               + ScilabGraphConstants.HTML_NEWLINE);
-                       }
-               } else {
-                       result.append("UID : " + getId()
-                                       + ScilabGraphConstants.HTML_NEWLINE);
-                       final int length = getStyle().length();
-                       result.append("Style : ");
-                       if (length > XcosConstants.MAX_CHAR_IN_STYLE) {
-                               result.append(getStyle().substring(0,
-                                               XcosConstants.MAX_CHAR_IN_STYLE));
-                               result.append(XcosMessages.DOTS);
-                       } else {
-                               result.append(getStyle());
-                       }
-                       result.append(ScilabGraphConstants.HTML_NEWLINE);
-                       result.append("Flip : " + getFlip()
-                                       + ScilabGraphConstants.HTML_NEWLINE);
-                       result.append("Mirror : " + getMirror()
-                                       + ScilabGraphConstants.HTML_NEWLINE);
-                       result.append("Input ports : "
-                                       + BasicBlockInfo.getAllTypedPorts(this, false,
-                                                       InputPort.class).size()
-                                       + ScilabGraphConstants.HTML_NEWLINE);
-                       result.append("Output ports : "
-                                       + BasicBlockInfo.getAllTypedPorts(this, false,
-                                                       OutputPort.class).size()
-                                       + ScilabGraphConstants.HTML_NEWLINE);
-                       result.append("Control ports : "
-                                       + BasicBlockInfo.getAllTypedPorts(this, false,
-                                                       ControlPort.class).size()
-                                       + ScilabGraphConstants.HTML_NEWLINE);
-                       result.append("Command ports : "
-                                       + BasicBlockInfo.getAllTypedPorts(this, false,
-                                                       CommandPort.class).size()
-                                       + ScilabGraphConstants.HTML_NEWLINE);
-               }
-               result.append("x : " + getGeometry().getX()
-                               + ScilabGraphConstants.HTML_NEWLINE);
-               result.append("y : " + getGeometry().getY()
-                               + ScilabGraphConstants.HTML_NEWLINE);
-               result.append("w : " + getGeometry().getWidth()
-                               + ScilabGraphConstants.HTML_NEWLINE);
-               result.append("h : " + getGeometry().getHeight()
-                               + ScilabGraphConstants.HTML_NEWLINE);
-               result.append(ScilabGraphConstants.HTML_END);
-               return result.toString();
-       }
-       /**
-        * @param graph
-        *            parent graph
-        */
-       public void openContextMenu(ScilabGraph graph) {
-               ContextMenu menu = null;
-               if (getParentDiagram() instanceof PaletteDiagram) {
-                       menu = createPaletteContextMenu(graph);
-               } else {
-                       menu = createContextMenu(graph);
-               }
-               menu.setVisible(true);
-       }
-       /**
-        * @param graph
-        *            parent graph
-        * @return context menu
-        */
-       // CSOFF: JavaNCSS
-       public ContextMenu createPaletteContextMenu(ScilabGraph graph) {
-               ContextMenu menu = ScilabContextMenu.createContextMenu();
-               final List<XcosDiagram> allDiagrams = Xcos.getInstance().getDiagrams();
-               if (allDiagrams.size() == 0) {
-                       // No diagram opened: should never happen if Xcos opens an empty
-                       // diagram when it is launched
-                       MenuItem addTo = ScilabMenuItem.createMenuItem();
-                       addTo.setText(XcosMessages.ADDTO_NEW_DIAGRAM);
-                       addTo.setCallback(new CommonCallBack(XcosMessages.ADDTO_NEW_DIAGRAM) {
-                               @Override
-                               public void callBack() {
-                                       XcosDiagram theDiagram = new XcosDiagram();
-                                       BasicBlock block = (BasicBlock) BlockFactory
-                                                       .createClone(BasicBlock.this);
-                                       theDiagram.getModel().add(theDiagram.getDefaultParent(),
-                                                       block, 0);
-                                       mxGeometry geom = BasicBlock.this.getGeometry();
-                                       setDefaultPosition(geom);
-                                       theDiagram.getModel().setGeometry(block, geom);
-                                       new XcosTab(theDiagram).setVisible(true);
-                                       BlockPositioning.updateBlockView(block);
-                               }
-                       });
-                       menu.add(addTo);
-               } else if (allDiagrams.size() == 1) {
-                       // A single diagram opened: add to this diagram
-                       MenuItem addTo = ScilabMenuItem.createMenuItem();
-                       addTo.setText(XcosMessages.ADDTO + " "
-                                       + allDiagrams.get(0).getParentTab().getName());
-                       final XcosDiagram theDiagram = allDiagrams.get(0);
-                       addTo.setCallback(new CommonCallBack(theDiagram.getTitle()) {
-                               private static final long serialVersionUID = -99601763227525686L;
-                               @Override
-                               public void callBack() {
-                                       BasicBlock block = (BasicBlock) BlockFactory
-                                                       .createClone(BasicBlock.this);
-                                       theDiagram.getModel().add(theDiagram.getDefaultParent(),
-                                                       block, 0);
-                                       mxGeometry geom = BasicBlock.this.getGeometry();
-                                       setDefaultPosition(geom);
-                                       theDiagram.getModel().setGeometry(block, geom);
-                                       BlockPositioning.updateBlockView(block);
-                                       block.setParentDiagram(theDiagram);
-                               }
-                       });
-                       menu.add(addTo);
-               } else {
-                       // The user has to choose
-                       Menu addTo = ScilabMenu.createMenu();
-                       addTo.setText(XcosMessages.ADDTO);
-                       for (int i = 0; i < allDiagrams.size(); i++) {
-                               MenuItem diagram = ScilabMenuItem.createMenuItem();
-                               final XcosDiagram theDiagram = allDiagrams.get(i);
-                               diagram.setText(allDiagrams.get(i).getParentTab().getName());
-                               diagram.setCallback(new CommonCallBack(theDiagram.getTitle()) {
-                                       private static final long serialVersionUID = 3345416658377835057L;
-                                       @Override
-                                       public void callBack() {
-                                               BasicBlock block = (BasicBlock) BlockFactory
-                                                               .createClone(BasicBlock.this);
-                                               theDiagram.getModel().add(
-                                                               theDiagram.getDefaultParent(), block, 0);
-                                               mxGeometry geom = BasicBlock.this.getGeometry();
-                                               setDefaultPosition(geom);
-                                               theDiagram.getModel().setGeometry(block, geom);
-                                               BlockPositioning.updateBlockView(block);
-                                       }
-                               });
-                               addTo.add(diagram);
-                       }
-                       menu.add(addTo);
-               }
-               menu.getAsSimpleContextMenu().addSeparator();
-               MenuItem help = ScilabMenuItem.createMenuItem();
-               help.setText(XcosMessages.BLOCK_DOCUMENTATION);
-               help.setCallback(new CommonCallBack(XcosMessages.BLOCK_DOCUMENTATION) {
-                       private static final long serialVersionUID = -1480947262397441951L;
-                       @Override
-                       public void callBack() {
-                               InterpreterManagement.requestScilabExec("help "
-                                               + getInterfaceFunctionName());
-                       }
-               });
-               menu.add(help);
-               menu.setVisible(true);
-               ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()).setLocation(
-                               MouseInfo.getPointerInfo().getLocation().x, MouseInfo
-                                               .getPointerInfo().getLocation().y);
-               return menu;
-       }
-       // CSON: JavaNCSS
-       /**
-        * @param graph
-        *            parent graph
-        * @return context menu
-        */
-       // CSOFF: JavaNCSS
-       public ContextMenu createContextMenu(ScilabGraph graph) {
-               ContextMenu menu = ScilabContextMenu.createContextMenu();
-               Map<Class<? extends DefaultAction>, Menu> menuList = new HashMap<Class<? extends DefaultAction>, Menu>();
-               MenuItem value = BlockParametersAction.createMenu(graph);
-               menuList.put(BlockParametersAction.class, value);
-               menu.add(value);
-               /*--- */
-               menu.getAsSimpleContextMenu().addSeparator();
-               /*--- */
-               value = CutAction.cutMenu(graph);
-               menuList.put(CutAction.class, value);
-               menu.add(value);
-               value = CopyAction.copyMenu(graph);
-               menuList.put(CopyAction.class, value);
-               menu.add(value);
-               value = DeleteAction.createMenu(graph);
-               menuList.put(DeleteAction.class, value);
-               menu.add(value);
-               /*--- */
-               menu.getAsSimpleContextMenu().addSeparator();
-               /*--- */
-               value = RegionToSuperblockAction.createMenu(graph);
-               menuList.put(RegionToSuperblockAction.class, value);
-               menu.add(value);
-               /*--- */
-               menu.getAsSimpleContextMenu().addSeparator();
-               /*--- */
-               Menu format = ScilabMenu.createMenu();
-               format.setText(XcosMessages.FORMAT);
-               menu.add(format);
-               value = RotateAction.createMenu(graph);
-               menuList.put(RotateAction.class, value);
-               format.add(value);
-               value = MirrorAction.createMenu(graph);
-               menuList.put(MirrorAction.class, value);
-               format.add(value);
-               value = FlipAction.createMenu(graph);
-               menuList.put(FlipAction.class, value);
-               format.add(value);
-               value = ShowHideShadowAction.createMenu(graph);
-               menuList.put(ShowHideShadowAction.class, value);
-               format.add(value);
-               /*--- */
-               format.addSeparator();
-               /*--- */
-               Menu alignMenu = ScilabMenu.createMenu();
-               alignMenu.setText(XcosMessages.ALIGN_BLOCKS);
-               alignMenu.add(AlignBlockActionLeft.createMenu(graph));
-               alignMenu.add(AlignBlockActionCenter.createMenu(graph));
-               alignMenu.add(AlignBlockActionRight.createMenu(graph));
-               alignMenu.addSeparator();
-               alignMenu.add(AlignBlockActionTop.createMenu(graph));
-               alignMenu.add(AlignBlockActionMiddle.createMenu(graph));
-               alignMenu.add(AlignBlockActionBottom.createMenu(graph));
-               menuList.put(AlignBlockAction.class, alignMenu);
-               format.add(alignMenu);
-               /*--- */
-               format.addSeparator();
-               /*--- */
-               if (graph.getSelectionCells().length > 1) {
-                       format.add(BorderColorAction.createMenu(graph));
-                       format.add(FilledColorAction.createMenu(graph));
-               } else {
-                       format.add(EditFormatAction.createMenu(graph));
-               }
-               /*--- */
-               menu.getAsSimpleContextMenu().addSeparator();
-               /*--- */
-               menu.add(ViewDetailsAction.createMenu(graph));
-               /*--- */
-               menu.getAsSimpleContextMenu().addSeparator();
-               /*--- */
-               menu.add(BlockDocumentationAction.createMenu(graph));
-               ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()).setLocation(
-                               MouseInfo.getPointerInfo().getLocation().x, MouseInfo
-                                               .getPointerInfo().getLocation().y);
-               customizeMenu(menuList);
-               return menu;
-       }
-       // CSON: JavaNCSS
-       /**
-        * @param flip
-        *            value
-        */
-       public void setFlip(boolean flip) {
-               if (getParentDiagram() != null) {
-                       isFlipped = flip;
-                       final mxIGraphModel model = getParentDiagram().getModel();
-                       mxUtils.setCellStyles(model, new Object[] { this },
-                                       ScilabGraphConstants.STYLE_FLIP, Boolean.toString(flip));
-               }
-       }
-       /**
-        * Override this to customize contextual menu
-        * 
-        * @param menuList
-        *            list of menu
-        */
-       protected void customizeMenu(
-                       Map<Class<? extends DefaultAction>, Menu> menuList) {
-               // To be overridden by sub-classes
-       }
-       /**
-        * @return mirror value
-        */
-       public boolean getMirror() {
-               return isMirrored;
-       }
-       /**
-        * @param mirror
-        *            new mirror value
-        */
-       public void setMirror(boolean mirror) {
-               if (getParentDiagram() != null) {
-                       isMirrored = mirror;
-                       final mxIGraphModel model = getParentDiagram().getModel();
-                       mxUtils.setCellStyles(model, new Object[] { this },
-                                       ScilabGraphConstants.STYLE_MIRROR, Boolean.toString(mirror));
-               }
-       }
-       /**
-        * @return flip status
-        */
-       public boolean getFlip() {
-               return isFlipped;
-       }
-       /**
-        * invert flip status
-        */
-       public void toggleFlip() {
-               BlockPositioning.toggleFlip(this);
-       }
-       /**
-        * invert mirror value
-        */
-       public void toggleMirror() {
-               BlockPositioning.toggleMirror(this);
-       }
-       /**
+     /*
+      * Property names
+      */
+     /**
+      * Property name of interfaceFunctionName
+      */
+     public static final String INTERFACE_FUNCTION_NAME = "interfaceFunctionName";
+     /**
+      * Property name of simulationFunctionName
+      */
+     public static final String SIMULATION_FUNCTION_NAME = "simulationFunctionName";
+     /**
+      * Property name of simulationFunctionType
+      */
+     public static final String SIMULATION_FUNCTION_TYPE = "simulationFunctionType";
+     /**
+      * Property name of realParameters
+      */
+     public static final String REAL_PARAMETERS = "realParameters";
+     /**
+      * Property name of integerParameters
+      */
+     public static final String INTEGER_PARAMETERS = "integerParameters";
+     /**
+      * Property name of objectsParameters
+      */
+     public static final String OBJECTS_PARAMETERS = "objectsParameters";
+     /**
+      * Property name of dependsOnU
+      */
+     public static final String DEPENDS_ON_U = "dependsOnU";
+     /**
+      * Property name of dependsOnT
+      */
+     public static final String DEPENDS_ON_T = "dependsOnT";
+     /**
+      * Property name of blockType
+      */
+     public static final String BLOCK_TYPE = "blockType";
+     /**
+      * Property name of ordering
+      */
+     public static final String ORDERING = "ordering";
+     /**
+      * Property name of exprs
+      */
+     public static final String EXPRS = "exprs";
+     /**
+      * Property name of nbZerosCrossing
+      */
+     public static final String NB_ZEROS_CROSSING = "nbZerosCrossing";
+     /**
+      * Property name of nmode
+      */
+     public static final String NMODE = "nmode";
+     /**
+      * Property name of state
+      */
+     public static final String STATE = "state";
+     /**
+      * Property name of dState
+      */
+     public static final String D_STATE = "dState";
+     /**
+      * Property name of oDState
+      */
+     public static final String O_D_STATE = "oDState";
+     /**
+      * Property name of equations
+      */
+     public static final String EQUATIONS = "equations";
+     /*
+      * Default values
+      */
+     /**
+      * Default interface function name
+      */
+     public static final String DEFAULT_INTERFACE_FUNCTION = "xcos_block";
+     /**
+      * Default simulation function name
+      */
+     public static final String DEFAULT_SIMULATION_FUNCTION = "xcos_simulate";
+     /*
+      * Local constants
+      */
+     private static final String PARENT_DIAGRAM_WAS_NULL = "Parent diagram was null";
+     private static final double DEFAULT_POSITION_X = 10.0;
+     private static final double DEFAULT_POSITION_Y = 10.0;
+     private static final double DEFAULT_WIDTH = 40.0;
+     private static final double DEFAULT_HEIGHT = 40.0;
+     private static final PropertyChangeListener STYLE_UPDATER = new UpdateStyleFromInterfunction();
+     private static final Log LOG = LogFactory.getLog(BasicBlock.class);
+     /**
+      * Manage events for block parameters.
+      * 
+      * The property name is the field name, is one of:
+      * <ol>
+      * <li>"interfaceFunctionName"
+      * <li>"simulationFunctionName"
+      * <li>"simulationFunctionType"
+      * <li>"exprs"
+      * <li>"realParameters"
+      * <li>"integerParameters"
+      * <li>"objectsParameters"
+      * <li>"nbZerosCrossing"
+      * <li>"nmode"
+      * <li>"state"
+      * <li>"dState"
+      * <li>"oDState"
+      * <li>"equations"
+      * <li>"dependsOnU"
+      * <li>"dependsOnT"
+      * <li>"blockType"
+      * <li>"ordering"
+      * </ol>
+      * 
+      * you can easily access to then by using property name constants.
+      */
+     private PropertyChangeSupport parametersPCS = new PropertyChangeSupport(
+             this);
+     private String interfaceFunctionName = DEFAULT_INTERFACE_FUNCTION;
+     private String simulationFunctionName = DEFAULT_SIMULATION_FUNCTION;
+     private SimulationFunctionType simulationFunctionType = SimulationFunctionType.DEFAULT;
+     private transient XcosDiagram parentDiagram;
+     private int angle;
+     private boolean isFlipped;
+     private boolean isMirrored;
+     // TODO : Must make this types evolve, but for now keep a strong link to
+     // Scilab
+     // !! WARNING !!
+     // exprs = [] ; rpar = [] ; ipar = [] ; opar = list()
+     // private List<String> exprs = new ArrayList<String>();
+     private ScilabType exprs;
+     // private List<Double> realParameters = new ArrayList<Double>();
+     private ScilabType realParameters;
+     // private List<Integer> integerParameters = new ArrayList<Integer>();
+     private ScilabType integerParameters;
+     // private List objectsParameters = new ArrayList();
+     private ScilabType objectsParameters;
+     private ScilabType nbZerosCrossing = new ScilabDouble();
+     private ScilabType nmode = new ScilabDouble();
+     private ScilabType state = new ScilabDouble();
+     private ScilabType dState = new ScilabDouble();
+     private ScilabType oDState = new ScilabDouble();
+     private ScilabType equations;
+     private boolean dependsOnU;
+     private boolean dependsOnT;
+     private String blockType = "c";
+     private int ordering;
+     private boolean locked;
+     /**
+      * Represent a simulation function type compatible with Scilab/Scicos
+      * function type descriptors.
+      */
+     public static enum SimulationFunctionType {
+         /** event select; reduced at compilation */
+         ESELECT(-2.0),
+         /** if then else; reduced at compilation */
+         IFTHENELSE(-1.0),
+         /** first common block */
+         DEFAULT(0.0),
+         /** first native block */
+         TYPE_1(1.0),
+         /** second native block */
+         TYPE_2(2.0),
+         /** third native block */
+         TYPE_3(3.0),
+         /** forth native block */
+         C_OR_FORTRAN(4.0),
+         /** Scilab blocks */
+         SCILAB(5.0),
+         /** Debug blocks */
+         DEBUG(99),
+         /** Modelica {@link #C_OR_FORTRAN} blocks */
+         MODELICA(30004.0),
+         /** Magic types */
+         UNKNOWN(5.0),
+         /** Implicit {@link #TYPE_1} blocks */
+         OLDBLOCKS(10001.0),
+         /** Implicit {@link #C_OR_FORTRAN} blocks */
+         IMPLICIT_C_OR_FORTRAN(10004.0);
+         private double value;
+         /**
+          * Default constructor
+          * 
+          * @param scilabValue
+          *            Scilab/Scicos function type descriptor
+          */
+         private SimulationFunctionType(double scilabValue) {
+             value = scilabValue;
+         }
+         /**
+          * Get the Java descriptor from the Scilab descriptor.
+          * 
+          * @param scilabValue
+          *            Scilab/Scicos function type descriptor
+          * @return The corresponding java descriptor
+          */
+         public static SimulationFunctionType convertScilabValue(int scilabValue) {
+             for (SimulationFunctionType iter : SimulationFunctionType.values()) {
+                 if (iter.getAsDouble() == scilabValue) {
+                     return iter;
+                 }
+             }
+             return UNKNOWN;
+         }
+         /**
+          * Get the Scilab Descriptor from the Java Descriptor
+          * 
+          * @return The corresponding Scilab/Scicos descriptor
+          */
+         public double getAsDouble() {
+             return value;
+         }
+     };
+     /**
+      * Update the source block when the interfunction change.
+      */
+     private static final class UpdateStyleFromInterfunction implements
+             PropertyChangeListener, Serializable {
+         /**
+          * Default constructor.
+          */
+         public UpdateStyleFromInterfunction() {
+         }
+         /**
+          * Update the label on interfunction change.
+          * 
+          * @param evt
+          *            the property change event.
+          * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+          */
+         @Override
+         public void propertyChange(PropertyChangeEvent evt) {
+             final BasicBlock source = (BasicBlock) evt.getSource();
+             /*
+              * Put the interfunction at the start of the style map to preserve
+              * style modification.
+              * 
+              * oldStyle="SUPER_f;fillColor=red" newStyle="DSUPER;fillColor=red"
+              * 
+              * and not newStyle="fillColor=red;DSUPER"
+              */
+             final StyleMap style = new StyleMap((String) evt.getNewValue());
+             style.putAll(source.getStyle());
+             style.remove(evt.getOldValue());
+             source.setStyle(style.toString());
+         }
+     }
+     /**
+      * Trace the parameters change on the {@link Log}.
+      * 
+      * This listener is only installed if the trace is enable.
+      */
+     private static final class TraceParametersListener implements
+             PropertyChangeListener, Serializable {
+         private static TraceParametersListener instance;
+         /**
+          * Default constructor.
+          */
+         private TraceParametersListener() {
+             super();
+         }
+         /**
+          * @return the instance
+          */
+         public static TraceParametersListener getInstance() {
+             if (instance == null) {
+                 instance = new TraceParametersListener();
+             }
+             return instance;
+         }
+         /**
+          * Trace.
+          * 
+          * @param evt
+          *            the event
+          * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+          */
+         @Override
+         public void propertyChange(PropertyChangeEvent evt) {
+             LOG.trace(evt.getPropertyName() + ": " + evt.getOldValue() + ", "
+                     + evt.getNewValue());
+         }
+     }
+     /**
+      * Default constructor.
+      */
+     public BasicBlock() {
+         super();
+         setDefaultValues();
+         setVisible(true);
+         setVertex(true);
+         if (getStyle().isEmpty() && !getInterfaceFunctionName().isEmpty()) {
+             setStyle(getInterfaceFunctionName());
+         }
+         parametersPCS.addPropertyChangeListener(INTERFACE_FUNCTION_NAME,
+                 STYLE_UPDATER);
+         /*
+          * Trace block parameters change if applicable.
+          */
+         if (LOG.isTraceEnabled()) {
+             parametersPCS.addPropertyChangeListener(TraceParametersListener
+                     .getInstance());
+         }
+     }
+     /**
+      * @param label
+      *            block label
+      */
+     protected BasicBlock(String label) {
+         this();
+         setDefaultValues();
+     }
+     /**
+      * @param label
+      *            block label
+      * @param style
+      *            initial style
+      */
+     protected BasicBlock(String label, String style) {
+         this(label);
+         setStyle(style);
+     }
+     /**
+      * Initialize the block with the default values
+      */
+     protected void setDefaultValues() {
+         setVisible(true);
+         setVertex(true);
+         setConnectable(false);
+         setGeometry(new mxGeometry(DEFAULT_POSITION_X, DEFAULT_POSITION_Y,
+                 DEFAULT_WIDTH, DEFAULT_HEIGHT));
+         setValue("");
+         setStyle("");
+     }
+     /**
+      * @return parent diagram
+      */
+     public XcosDiagram getParentDiagram() {
+         return parentDiagram;
+     }
+     /**
+      * @param parentDiagram
+      *            parent diagram
+      */
+     public void setParentDiagram(XcosDiagram parentDiagram) {
+         this.parentDiagram = parentDiagram;
+     }
+     /**
+      * @return interface function name
+      */
+     public String getInterfaceFunctionName() {
+         return interfaceFunctionName;
+     }
+     /**
+      * @param interfaceFunctionName
+      *            interface function name
+      */
+     public void setInterfaceFunctionName(String interfaceFunctionName) {
+         if ((this.interfaceFunctionName == null && interfaceFunctionName != null)
+                 || !this.interfaceFunctionName.equals(interfaceFunctionName)) {
+             final String oldValue = this.interfaceFunctionName;
+             this.interfaceFunctionName = interfaceFunctionName;
+             parametersPCS.firePropertyChange(INTERFACE_FUNCTION_NAME, oldValue,
+                     interfaceFunctionName);
+         }
+     }
+     /**
+      * @param simulationFunctionName
+      *            sumulation function name
+      */
+     public void setSimulationFunctionName(String simulationFunctionName) {
+         if ((this.simulationFunctionName == null && simulationFunctionName != null)
+                 || !this.simulationFunctionName.equals(simulationFunctionName)) {
+             final String oldValue = this.simulationFunctionName;
+             this.simulationFunctionName = simulationFunctionName;
+             parametersPCS.firePropertyChange(SIMULATION_FUNCTION_NAME,
+                     oldValue, simulationFunctionName);
+         }
+     }
+     /**
+      * @return sumulation function name
+      */
+     public String getSimulationFunctionName() {
+         return simulationFunctionName;
+     }
+     /**
+      * @param scilabValue
+      *            simulation function type
+      */
+     public void setSimulationFunctionType(int scilabValue) {
+         SimulationFunctionType simFunctionType = SimulationFunctionType
+                 .convertScilabValue(scilabValue);
+         setSimulationFunctionType(simFunctionType);
+     }
+     /**
+      * @param simulationFunctionType
+      *            simulation function type
+      */
+     public void setSimulationFunctionType(
+             SimulationFunctionType simulationFunctionType) {
+         if ((this.simulationFunctionType == null && simulationFunctionType != null)
+                 || !this.simulationFunctionType.equals(simulationFunctionType)) {
+             final SimulationFunctionType oldValue = this.simulationFunctionType;
+             this.simulationFunctionType = simulationFunctionType;
+             parametersPCS.firePropertyChange(SIMULATION_FUNCTION_TYPE,
+                     oldValue, simulationFunctionType);
+         }
+     }
+     /**
+      * @return simulation function type
+      */
+     public SimulationFunctionType getSimulationFunctionType() {
+         return simulationFunctionType;
+     }
+     /**
+      * @return real parameter ( rpar )
+      */
+     public ScilabType getRealParameters() {
+         return realParameters;
+     }
+     /**
+      * @param realParameters
+      *            reaL parameter ( rpar )
+      */
+     public void setRealParameters(ScilabType realParameters) {
+         if ((this.realParameters == null && realParameters != null)
+                 || !this.realParameters.equals(realParameters)) {
+             final ScilabType oldValue = this.realParameters;
+             this.realParameters = realParameters;
+             parametersPCS.firePropertyChange(REAL_PARAMETERS, oldValue,
+                     realParameters);
+         }
+     }
+     /**
+      * @return integer parameter ( ipar )
+      */
+     public ScilabType getIntegerParameters() {
+         return integerParameters;
+     }
+     /**
+      * @param integerParameters
+      *            integer parameter ( ipar )
+      */
+     public void setIntegerParameters(ScilabType integerParameters) {
+         if ((this.integerParameters == null && integerParameters != null)
+                 || !this.integerParameters.equals(integerParameters)) {
+             final ScilabType oldValue = this.integerParameters;
+             this.integerParameters = integerParameters;
+             parametersPCS.firePropertyChange(INTEGER_PARAMETERS, oldValue,
+                     integerParameters);
+         }
+     }
+     /**
+      * @return object parameter ( opar )
+      */
+     public ScilabType getObjectsParameters() {
+         return objectsParameters;
+     }
+     /**
+      * @param objectsParameters
+      *            object parameter ( opar )
+      */
+     public void setObjectsParameters(ScilabType objectsParameters) {
+         if ((this.objectsParameters == null && objectsParameters != null)
+                 || !this.objectsParameters.equals(objectsParameters)) {
+             final ScilabType oldValue = this.objectsParameters;
+             this.objectsParameters = objectsParameters;
+             parametersPCS.firePropertyChange(OBJECTS_PARAMETERS, oldValue,
+                     objectsParameters);
+         }
+     }
+     /**
+      * @param dependsOnU
+      *            ?
+      */
+     public void setDependsOnU(boolean dependsOnU) {
+         if (this.dependsOnU != dependsOnU) {
+             final boolean oldValue = this.dependsOnU;
+             this.dependsOnU = dependsOnU;
+             parametersPCS
+                     .firePropertyChange(DEPENDS_ON_U, oldValue, dependsOnU);
+         }
+     }
+     /**
+      * @return ?
+      */
+     public boolean isDependsOnU() {
+         return dependsOnU;
+     }
+     /**
+      * @param dependsOnT
+      *            ?
+      */
+     public void setDependsOnT(boolean dependsOnT) {
+         if (this.dependsOnT != dependsOnT) {
+             final boolean oldValue = this.dependsOnT;
+             this.dependsOnT = dependsOnT;
+             parametersPCS
+                     .firePropertyChange(DEPENDS_ON_T, oldValue, dependsOnT);
+         }
+     }
+     /**
+      * @return ?
+      */
+     public boolean isDependsOnT() {
+         return dependsOnT;
+     }
+     /**
+      * @param blockType
+      *            block type
+      */
+     public void setBlockType(String blockType) {
+         if ((this.blockType == null && blockType != null)
+                 || !this.blockType.equals(blockType)) {
+             final String oldValue = this.blockType;
+             this.blockType = blockType;
+             parametersPCS.firePropertyChange(BLOCK_TYPE, oldValue, blockType);
+         }
+     }
+     /**
+      * @return block type
+      */
+     public String getBlockType() {
+         return blockType;
+     }
+     /**
+      * @param ordering
+      *            order value
+      */
+     public void setOrdering(int ordering) {
+         if (this.ordering != ordering) {
+             final int oldValue = this.ordering;
+             this.ordering = ordering;
+             parametersPCS.firePropertyChange(ORDERING, oldValue, ordering);
+         }
+     }
+     /**
+      * @return order value
+      */
+     public int getOrdering() {
+         return ordering;
+     }
+     /**
+      * @param exprs
+      *            expression
+      */
+     public void setExprs(ScilabType exprs) {
+         if ((this.exprs == null && exprs != null) || !this.exprs.equals(exprs)) {
+             final ScilabType oldValue = this.exprs;
+             this.exprs = exprs;
+             parametersPCS.firePropertyChange(EXPRS, oldValue, exprs);
+         }
+     }
+     /**
+      * @return expression
+      */
+     public ScilabType getExprs() {
+         return exprs;
+     }
+     /**
+      * @return the expression as a object array
+      */
+     public Object[] getExprsFormat() {
+         // evaluate emptiness
+         if (getExprs() == null || getExprs().isEmpty()
+                 || getExprs().getHeight() == 0 || getExprs().getWidth() == 0) {
+             return new String[0];
+         }
+         List<String[]> stack = getString(null, getExprs());
+         int len = 0;
+         for (Object[] strings : stack) {
+             len += strings.length;
+         }
+         final Object[] array = new Object[len];
+         int start = 0;
+         for (Object[] strings : stack) {
+             System.arraycopy(strings, 0, array, start, strings.length);
+             start += strings.length;
+         }
+         return array;
+     }
+     /**
+      * Append the data recursively to the stack
+      * 
+      * @param currentStack
+      *            the current stack
+      * @param data
+      *            the data to append
+      * @return the stack
+      */
+     private List<String[]> getString(List<String[]> currentStack,
+             ScilabType data) {
+         final List<String[]> stack;
+         if (currentStack == null) {
+             stack = new LinkedList<String[]>();
+         } else {
+             stack = currentStack;
+         }
+         if (data instanceof List) {
+             /*
+              * Container case (ScilabList, ScilabMList, ScilabTList)
+              */
+             @SuppressWarnings("unchecked")
+             final List<ScilabType> list = (List<ScilabType>) data;
+             for (final ScilabType scilabType : list) {
+                 getString(stack, scilabType);
+             }
+         } else if (data instanceof ScilabString) {
+             /*
+              * native case (only ScilabString supported)
+              */
+             final String[][] scilabData = ((ScilabString) data).getData();
+             final int height = data.getHeight();
+             final int width = data.getWidth();
+             final String[] array = new String[height * width];
+             for (int i = 0; i < height; ++i) {
+                 System.arraycopy(scilabData[i], 0, array, i * width, width);
+             }
+             stack.add(array);
+         }
+         return stack;
+     }
+     /**
+      * @return zero crossing value
+      */
+     public ScilabType getNbZerosCrossing() {
+         return nbZerosCrossing;
+     }
+     /**
+      * @param nbZerosCrossing
+      *            zero crossing value
+      */
+     public void setNbZerosCrossing(ScilabType nbZerosCrossing) {
+         if ((this.nbZerosCrossing == null && nbZerosCrossing != null)
+                 || !this.nbZerosCrossing.equals(nbZerosCrossing)) {
+             final ScilabType oldValue = this.nbZerosCrossing;
+             this.nbZerosCrossing = nbZerosCrossing;
+             parametersPCS.firePropertyChange(NB_ZEROS_CROSSING, oldValue,
+                     nbZerosCrossing);
+         }
+     }
+     /**
+      * @return nmode
+      */
+     public ScilabType getNmode() {
+         return nmode;
+     }
+     /**
+      * @param nmode
+      *            nmode
+      */
+     public void setNmode(ScilabType nmode) {
+         if ((this.nmode == null && nmode != null) || !this.nmode.equals(nmode)) {
+             final ScilabType oldValue = this.nmode;
+             this.nmode = nmode;
+             parametersPCS.firePropertyChange(NMODE, oldValue, nmode);
+         }
+     }
+     /**
+      * @return current state
+      */
+     public ScilabType getState() {
+         return state;
+     }
+     /**
+      * @param state
+      *            new state
+      */
+     public void setState(ScilabType state) {
+         if ((this.state == null && state != null) || !this.state.equals(state)) {
+             final ScilabType oldValue = this.state;
+             this.state = state;
+             parametersPCS.firePropertyChange(STATE, oldValue, state);
+         }
+     }
+     /**
+      * @return current dstate
+      */
+     public ScilabType getDState() {
+         return dState;
+     }
+     /**
+      * @param dState
+      *            new dstate
+      */
+     public void setDState(ScilabType dState) {
+         if ((this.dState == null && dState != null)
+                 || !this.dState.equals(dState)) {
+             final ScilabType oldValue = this.dState;
+             this.dState = dState;
+             parametersPCS.firePropertyChange(D_STATE, oldValue, dState);
+         }
+     }
+     /**
+      * @return current ostate
+      */
+     public ScilabType getODState() {
+         return oDState;
+     }
+     /**
+      * @param oDState
+      *            new odstate
+      */
+     public void setODState(ScilabType oDState) {
+         if ((this.oDState == null && oDState != null)
+                 || !this.oDState.equals(oDState)) {
+             final ScilabType oldValue = this.oDState;
+             this.oDState = oDState;
+             parametersPCS.firePropertyChange(O_D_STATE, oldValue, oDState);
+         }
+     }
+     /**
+      * @return equations
+      */
+     public ScilabType getEquations() {
+         return equations;
+     }
+     /**
+      * @param equations
+      *            equations
+      */
+     public void setEquations(ScilabType equations) {
+         if ((this.equations == null && equations != null)
+                 || !this.equations.equals(equations)) {
+             final ScilabType oldValue = this.equations;
+             this.equations = equations;
+             parametersPCS.firePropertyChange(EQUATIONS, oldValue, equations);
+         }
+     }
+     /**
+      * @return locked status
+      */
+     public synchronized boolean isLocked() {
+         return locked;
+     }
+     /**
+      * @param locked
+      *            change locked status
+      */
+     public synchronized void setLocked(boolean locked) {
+         this.locked = locked;
+     }
+     /**
+      * @param port
+      *            to remove
+      */
+     public void removePort(BasicPort port) {
+         if (port.getEdgeCount() != 0 && getParentDiagram() != null) {
+             getParentDiagram().removeCells(new Object[] { port.getEdgeAt(0) });
+         }
+         remove(port);
+     }
+     /**
+      * Add a port on the block.
+      * 
+      * This call should only be used when a port reordering operation must be
+      * performed.
+      * 
+      * @param port
+      *            The port to be added to the block
+      */
+     public void addPort(BasicPort port) {
+         insert(port);
+         port.setOrdering(BasicBlockInfo.getAllTypedPorts(this, false,
+                 port.getClass()).size());
+         BlockPositioning.updateBlockView(this);
+     }
+     /**
+      * @return command ports initial state
+      */
+     public ScilabDouble getAllCommandPortsInitialStates() {
+         final List<CommandPort> cmdPorts = BasicBlockInfo.getAllTypedPorts(
+                 this, false, CommandPort.class);
+         if (cmdPorts.isEmpty()) {
+             return new ScilabDouble();
+         }
+         double[][] data = new double[cmdPorts.size()][1];
+         for (int i = 0; i < cmdPorts.size(); ++i) {
+             data[i][0] = cmdPorts.get(i).getInitialState();
+         }
+         return new ScilabDouble(data);
+     }
+     /**
+      * @return name and type of the simulation function
+      */
+     public ScilabType getSimulationFunctionNameAndType() {
+         if (getSimulationFunctionType() == SimulationFunctionType.DEFAULT) {
+             return new ScilabString(getSimulationFunctionName());
+         }
+         ScilabList data = new ScilabList();
+         data.add(new ScilabString(getSimulationFunctionName()));
+         data.add(new ScilabDouble(getSimulationFunctionType().getAsDouble()));
+         return data;
+     }
+     /**
+      * Does the block update and register on the undo manager
+      * 
+      * @param modifiedBlock
+      *            the new settings
+      */
+     public void updateBlockSettings(BasicBlock modifiedBlock) {
+         if (modifiedBlock == null) {
+             return;
+         }
+         /*
+          * Update the block settings
+          */
+         updateFields(modifiedBlock);
+         /*
+          * Update the children ports
+          */
+         if (children != null) {
+             updateChildren(modifiedBlock);
+         }
+         /*
+          * If the block is in a superblock then update it.
+          */
+         if (getParentDiagram() instanceof SuperBlockDiagram) {
+             SuperBlock block = ((SuperBlockDiagram) getParentDiagram())
+                     .getContainer();
+             XcosDiagram graph = block.getParentDiagram();
+             if (graph == null) {
+                 setParentDiagram(Xcos.findParent(block));
+                 graph = block.getParentDiagram();
+                 LogFactory.getLog(getClass()).error(PARENT_DIAGRAM_WAS_NULL);
+             }
+             graph.fireEvent(new mxEventObject(XcosEvent.SUPER_BLOCK_UPDATED,
+                     XcosConstants.EVENT_BLOCK_UPDATED, block));
+         }
+     }
+     /**
+      * Update the instance field.
+      * 
+      * @param modifiedBlock
+      *            the modified instance
+      */
+     private void updateFields(BasicBlock modifiedBlock) {
+         if (modifiedBlock == null) {
+             return;
+         }
+         setDependsOnT(modifiedBlock.isDependsOnT());
+         setDependsOnU(modifiedBlock.isDependsOnU());
+         setExprs(modifiedBlock.getExprs());
+         setRealParameters(modifiedBlock.getRealParameters());
+         setIntegerParameters(modifiedBlock.getIntegerParameters());
+         setObjectsParameters(modifiedBlock.getObjectsParameters());
+         setState(modifiedBlock.getState());
+         setDState(modifiedBlock.getDState());
+         setODState(modifiedBlock.getODState());
+         setBlockType(modifiedBlock.getBlockType());
+         setSimulationFunctionName(modifiedBlock.getSimulationFunctionName());
+         setSimulationFunctionType(modifiedBlock.getSimulationFunctionType());
+         setEquations(modifiedBlock.getEquations());
+         setStyle(modifiedBlock.getStyle());
+     }
+     /**
+      * Update the children of the block.
+      * 
+      * @param modifiedBlock
+      *            the new block instance
+      */
+     private void updateChildren(BasicBlock modifiedBlock) {
+         if (modifiedBlock == null) {
+             return;
+         }
+         XcosDiagram graph = getParentDiagram();
+         if (graph == null) {
+             setParentDiagram(Xcos.findParent(this));
+             graph = getParentDiagram();
+             LogFactory.getLog(getClass()).error(PARENT_DIAGRAM_WAS_NULL);
+         }
+         /*
+          * Checked as port classes only
+          */
+         @SuppressWarnings("unchecked")
+         Set<Class<? extends mxICell>> types = new HashSet<Class<? extends mxICell>>(
+                 Arrays.asList(InputPort.class, OutputPort.class,
+                         ControlPort.class, CommandPort.class));
+         Map<Class<? extends mxICell>, Deque<mxICell>> annotatedOlds = getTypedChildren(types);
+         Map<Class<? extends mxICell>, Deque<mxICell>> annotatedNews = modifiedBlock
+                 .getTypedChildren(types);
+         getParentDiagram().getModel().beginUpdate();
+         try {
+             for (Class<? extends mxICell> klass : types) {
+                 final Deque<mxICell> olds = annotatedOlds.get(klass);
+                 final Deque<mxICell> news = annotatedNews.get(klass);
+                 // updated ports
+                 while (!olds.isEmpty() && !news.isEmpty()) {
+                     mxICell previous = olds.poll();
+                     mxICell modified = news.poll();
+                     final int previousIndex = children.indexOf(previous);
+                     // relink
+                     if (previous.getEdgeCount() != 0) {
+                         final mxICell edge = previous.getEdgeAt(0);
+                         final boolean isOutgoing = previous == edge
+                                 .getTerminal(true);
+                         previous.removeEdge(edge, isOutgoing);
+                         modified.insertEdge(edge, isOutgoing);
+                     }
+                     getParentDiagram().removeCells(new Object[] { previous },
+                             false);
+                     getParentDiagram().addCells(new Object[] { modified },
+                             this, previousIndex);
+                     // Clone the geometry to avoid empty geometry on new cells.
+                     getParentDiagram().getModel().setGeometry(modified,
+                             (mxGeometry) previous.getGeometry().clone());
+                 }
+                 // removed ports
+                 if (!olds.isEmpty()) {
+                     getParentDiagram().removeCells(olds.toArray(), true);
+                 }
+                 // added ports
+                 if (!news.isEmpty()) {
+                     getParentDiagram().addCells(news.toArray(), this);
+                 }
+             }
+         } finally {
+             getParentDiagram().getModel().endUpdate();
+         }
+     }
+     /**
+      * Format the children as a typed map for the given class set.
+      * 
+      * @param types
+      *            the classes to search for.
+      * @return a map which linked foreach type the corresponding cell list.
+      */
+     private Map<Class<? extends mxICell>, Deque<mxICell>> getTypedChildren(
+             Set<Class<? extends mxICell>> types) {
+         Map<Class<? extends mxICell>, Deque<mxICell>> oldPorts = new HashMap<Class<? extends mxICell>, Deque<mxICell>>();
+         // Allocate all types set
+         for (Class<? extends mxICell> type : types) {
+             oldPorts.put(type, new LinkedList<mxICell>());
+         }
+         // sort children according to the ordering parameter (useful on
+         // scilab-5.2.x diagrams)
+         Collections.sort(children, new Comparator<Object>() {
+             @Override
+             public int compare(Object o1, Object o2) {
+                 if (o1 instanceof BasicPort && o2 instanceof BasicPort) {
+                     return ((BasicPort) o1).getOrdering()
+                             - ((BasicPort) o2).getOrdering();
+                 } else {
+                     return 0;
+                 }
+             }
+         });
+         // children lookup
+         for (Object cell : children) {
+             Class<? extends Object> klass = cell.getClass();
+             while (klass != null) {
+                 if (types.contains(klass)) {
+                     break;
+                 }
+                 klass = klass.getSuperclass();
+             }
+             final Deque<mxICell> current = oldPorts.get(klass);
+             if (current != null) {
+                 current.add((mxICell) cell);
+             }
+         }
+         return oldPorts;
+     }
+     /**
+      * @param context
+      *            parent diagram context
+      */
+     public void openBlockSettings(String[] context) {
+         final XcosDiagram graph;
+         if (getParentDiagram() == null) {
+             setParentDiagram(Xcos.findParent(this));
+             graph = getParentDiagram();
+             LogFactory.getLog(getClass()).error(PARENT_DIAGRAM_WAS_NULL);
+         } else {
+             graph = getParentDiagram();
+         }
+         if (getParentDiagram() instanceof PaletteDiagram) {
+             return;
+         }
+         if (context == null) {
+             throw new IllegalArgumentException();
+         }
+         // prevent to open twice
+         if (isLocked()) {
+             return;
+         }
+         final String tempOutput;
+         final String tempInput;
+         final String tempContext;
+         final BasicBlock currentBlock = this;
+         try {
+             tempInput = FileUtils.createTempFile();
+             // Write scs_m
+             tempOutput = exportBlockStruct();
+             // Write context
+             tempContext = exportContext(context);
+             final ActionListener action = new ActionListener() {
+                 @Override
+                 public void actionPerformed(ActionEvent e) {
+                     if (exists(tempInput)) {
+                         LOG.trace("Updating data.");
+                         graph.getView().clear(this, true, true);
+                         // Now read new Block
+                         graph.getModel().beginUpdate();
+                         try {
+                             BasicBlock modifiedBlock = new H5RWHandler(
+                                     tempInput).readBlock();
+                             updateBlockSettings(modifiedBlock);
+                             graph.fireEvent(new mxEventObject(
+                                     XcosEvent.ADD_PORTS,
+                                     XcosConstants.EVENT_BLOCK_UPDATED,
+                                     currentBlock));
+                         } catch (ScicosFormatException e1) {
+                             System.err.println(e1.getMessage());
+                             LOG.error(e1);
+                         } finally {
+                             graph.getModel().endUpdate();
+                         }
+                         delete(tempInput);
+                     } else {
+                         LOG.trace("No needs to update data.");
+                     }
+                     delete(tempOutput);
+                     delete(tempContext);
+                     setLocked(false);
+                 }
+             };
+             try {
+                 setLocked(true);
+                 ScilabInterpreterManagement.asynchronousScilabExec(action,
+                         "xcosBlockInterface", tempOutput, tempInput,
+                         getInterfaceFunctionName().toCharArray(), "set",
+                         tempContext);
+             } catch (InterpreterException e) {
+                 LOG.error(e);
+                 setLocked(false);
+             }
+         } catch (IOException e) {
+             LOG.error(e);
+         }
+     }
+     /**
+      * @return exported file
+      */
+     protected String exportBlockStruct() {
+         // Write scs_m
+         String tempOutput;
+         try {
+             tempOutput = FileUtils.createTempFile();
+             File f = new File(tempOutput);
+             f.deleteOnExit();
+             new H5RWHandler(tempOutput).writeBlock(this);
+             return tempOutput;
+         } catch (IOException e) {
+             e.printStackTrace();
+         }
+         return null;
+     }
+     /**
+      * @param context
+      *            parent diagram context
+      * @return exported file
+      */
+     protected String exportContext(String[] context) {
+         // Write context
+         try {
+             String fileString = FileUtils.createTempFile();
+             File tempContext = new File(fileString);
+             tempContext.deleteOnExit();
+             int contextFileId = H5Write.createFile(tempContext
+                     .getAbsolutePath());
+             H5Write.writeInDataSet(contextFileId, "context", new ScilabString(
+                     context));
+             H5Write.closeFile(contextFileId);
+             return fileString;
+         } catch (IOException e) {
+             e.printStackTrace();
+         } catch (HDF5Exception e) {
+             e.printStackTrace();
+         }
+         return null;
+     }
+     /**
+      * @return tooltip text
+      */
+     public String getToolTipText() {
+         StringBuilder result = new StringBuilder();
+         result.append(ScilabGraphConstants.HTML_BEGIN);
+         result.append("Block Name : " + getInterfaceFunctionName()
+                 + ScilabGraphConstants.HTML_NEWLINE);
+         result.append("Simulation : " + getSimulationFunctionName()
+                 + ScilabGraphConstants.HTML_NEWLINE);
+         if (getParentDiagram() instanceof PaletteDiagram) {
+             if (getIntegerParameters() != null) {
+                 result.append("Integer parameters : " + getIntegerParameters()
+                         + ScilabGraphConstants.HTML_NEWLINE);
+             }
+             if (getRealParameters() != null
+                     && getRealParameters().getHeight() != 0
+                     && getRealParameters().getWidth() != 0) {
+                 result.append("Real parameters : " + getRealParameters()
+                         + ScilabGraphConstants.HTML_NEWLINE);
+             }
+             if (getObjectsParameters() != null) {
+                 result.append("Object parameters : " + getObjectsParameters()
+                         + ScilabGraphConstants.HTML_NEWLINE);
+             }
+         } else {
+             result.append("UID : " + getId()
+                     + ScilabGraphConstants.HTML_NEWLINE);
+             final int length = getStyle().length();
+             result.append("Style : ");
+             if (length > XcosConstants.MAX_CHAR_IN_STYLE) {
+                 result.append(getStyle().substring(0,
+                         XcosConstants.MAX_CHAR_IN_STYLE));
+                 result.append(XcosMessages.DOTS);
+             } else {
+                 result.append(getStyle());
+             }
+             result.append(ScilabGraphConstants.HTML_NEWLINE);
+             result.append("Flip : " + getFlip()
+                     + ScilabGraphConstants.HTML_NEWLINE);
+             result.append("Mirror : " + getMirror()
+                     + ScilabGraphConstants.HTML_NEWLINE);
+             result.append("Input ports : "
+                     + BasicBlockInfo.getAllTypedPorts(this, false,
+                             InputPort.class).size()
+                     + ScilabGraphConstants.HTML_NEWLINE);
+             result.append("Output ports : "
+                     + BasicBlockInfo.getAllTypedPorts(this, false,
+                             OutputPort.class).size()
+                     + ScilabGraphConstants.HTML_NEWLINE);
+             result.append("Control ports : "
+                     + BasicBlockInfo.getAllTypedPorts(this, false,
+                             ControlPort.class).size()
+                     + ScilabGraphConstants.HTML_NEWLINE);
+             result.append("Command ports : "
+                     + BasicBlockInfo.getAllTypedPorts(this, false,
+                             CommandPort.class).size()
+                     + ScilabGraphConstants.HTML_NEWLINE);
+         }
+         result.append("x : " + getGeometry().getX()
+                 + ScilabGraphConstants.HTML_NEWLINE);
+         result.append("y : " + getGeometry().getY()
+                 + ScilabGraphConstants.HTML_NEWLINE);
+         result.append("w : " + getGeometry().getWidth()
+                 + ScilabGraphConstants.HTML_NEWLINE);
+         result.append("h : " + getGeometry().getHeight()
+                 + ScilabGraphConstants.HTML_NEWLINE);
+         result.append(ScilabGraphConstants.HTML_END);
+         return result.toString();
+     }
+     /**
+      * @param graph
+      *            parent graph
+      */
+     public void openContextMenu(ScilabGraph graph) {
+         ContextMenu menu = null;
+         if (getParentDiagram() instanceof PaletteDiagram) {
+             menu = createPaletteContextMenu(graph);
+         } else {
+             menu = createContextMenu(graph);
+         }
+         menu.setVisible(true);
+     }
+     /**
+      * @param graph
+      *            parent graph
+      * @return context menu
+      */
+     // CSOFF: JavaNCSS
+     public ContextMenu createPaletteContextMenu(ScilabGraph graph) {
+         ContextMenu menu = ScilabContextMenu.createContextMenu();
+         final List<XcosDiagram> allDiagrams = Xcos.getInstance().getDiagrams();
+         if (allDiagrams.size() == 0) {
+             // No diagram opened: should never happen if Xcos opens an empty
+             // diagram when it is launched
+             MenuItem addTo = ScilabMenuItem.createMenuItem();
+             addTo.setText(XcosMessages.ADDTO_NEW_DIAGRAM);
 -            addTo.setCallback(new CallBack(XcosMessages.ADDTO_NEW_DIAGRAM) {
++            addTo.setCallback(new CommonCallBack(XcosMessages.ADDTO_NEW_DIAGRAM) {
+                 @Override
+                 public void callBack() {
+                     XcosDiagram theDiagram = new XcosDiagram();
+                     BasicBlock block = (BasicBlock) BlockFactory
+                             .createClone(BasicBlock.this);
+                     theDiagram.getModel().add(theDiagram.getDefaultParent(),
+                             block, 0);
+                     mxGeometry geom = BasicBlock.this.getGeometry();
+                     setDefaultPosition(geom);
+                     theDiagram.getModel().setGeometry(block, geom);
+                     new XcosTab(theDiagram).setVisible(true);
+                     BlockPositioning.updateBlockView(block);
+                 }
+             });
+             menu.add(addTo);
+         } else if (allDiagrams.size() == 1) {
+             // A single diagram opened: add to this diagram
+             MenuItem addTo = ScilabMenuItem.createMenuItem();
+             addTo.setText(XcosMessages.ADDTO + " "
+                     + allDiagrams.get(0).getParentTab().getName());
+             final XcosDiagram theDiagram = allDiagrams.get(0);
 -            addTo.setCallback(new CallBack(theDiagram.getTitle()) {
++            addTo.setCallback(new CommonCallBack(theDiagram.getTitle()) {
+                 private static final long serialVersionUID = -99601763227525686L;
+                 @Override
+                 public void callBack() {
+                     BasicBlock block = (BasicBlock) BlockFactory
+                             .createClone(BasicBlock.this);
+                     theDiagram.getModel().add(theDiagram.getDefaultParent(),
+                             block, 0);
+                     mxGeometry geom = BasicBlock.this.getGeometry();
+                     setDefaultPosition(geom);
+                     theDiagram.getModel().setGeometry(block, geom);
+                     BlockPositioning.updateBlockView(block);
+                     block.setParentDiagram(theDiagram);
+                 }
+             });
+             menu.add(addTo);
+         } else {
+             // The user has to choose
+             Menu addTo = ScilabMenu.createMenu();
+             addTo.setText(XcosMessages.ADDTO);
+             for (int i = 0; i < allDiagrams.size(); i++) {
+                 MenuItem diagram = ScilabMenuItem.createMenuItem();
+                 final XcosDiagram theDiagram = allDiagrams.get(i);
+                 diagram.setText(allDiagrams.get(i).getParentTab().getName());
 -                diagram.setCallback(new CallBack(theDiagram.getTitle()) {
++                diagram.setCallback(new CommonCallBack(theDiagram.getTitle()) {
+                     private static final long serialVersionUID = 3345416658377835057L;
+                     @Override
+                     public void callBack() {
+                         BasicBlock block = (BasicBlock) BlockFactory
+                                 .createClone(BasicBlock.this);
+                         theDiagram.getModel().add(
+                                 theDiagram.getDefaultParent(), block, 0);
+                         mxGeometry geom = BasicBlock.this.getGeometry();
+                         setDefaultPosition(geom);
+                         theDiagram.getModel().setGeometry(block, geom);
+                         BlockPositioning.updateBlockView(block);
+                     }
+                 });
+                 addTo.add(diagram);
+             }
+             menu.add(addTo);
+         }
+         menu.getAsSimpleContextMenu().addSeparator();
+         MenuItem help = ScilabMenuItem.createMenuItem();
+         help.setText(XcosMessages.BLOCK_DOCUMENTATION);
 -        help.setCallback(new CallBack(XcosMessages.BLOCK_DOCUMENTATION) {
++        help.setCallback(new CommonCallBack(XcosMessages.BLOCK_DOCUMENTATION) {
+             private static final long serialVersionUID = -1480947262397441951L;
+             @Override
+             public void callBack() {
+                 InterpreterManagement.requestScilabExec("help "
+                         + getInterfaceFunctionName());
+             }
+         });
+         menu.add(help);
+         menu.setVisible(true);
+         ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()).setLocation(
+                 MouseInfo.getPointerInfo().getLocation().x, MouseInfo
+                         .getPointerInfo().getLocation().y);
+         return menu;
+     }
+     // CSON: JavaNCSS
+     /**
+      * @param graph
+      *            parent graph
+      * @return context menu
+      */
+     // CSOFF: JavaNCSS
+     public ContextMenu createContextMenu(ScilabGraph graph) {
+         ContextMenu menu = ScilabContextMenu.createContextMenu();
+         Map<Class<? extends DefaultAction>, Menu> menuList = new HashMap<Class<? extends DefaultAction>, Menu>();
+         MenuItem value = BlockParametersAction.createMenu(graph);
+         menuList.put(BlockParametersAction.class, value);
+         menu.add(value);
+         /*--- */
+         menu.getAsSimpleContextMenu().addSeparator();
+         /*--- */
+         value = CutAction.cutMenu(graph);
+         menuList.put(CutAction.class, value);
+         menu.add(value);
+         value = CopyAction.copyMenu(graph);
+         menuList.put(CopyAction.class, value);
+         menu.add(value);
+         value = DeleteAction.createMenu(graph);
+         menuList.put(DeleteAction.class, value);
+         menu.add(value);
+         /*--- */
+         menu.getAsSimpleContextMenu().addSeparator();
+         /*--- */
+         value = RegionToSuperblockAction.createMenu(graph);
+         menuList.put(RegionToSuperblockAction.class, value);
+         menu.add(value);
+         /*--- */
+         menu.getAsSimpleContextMenu().addSeparator();
+         /*--- */
+         Menu format = ScilabMenu.createMenu();
+         format.setText(XcosMessages.FORMAT);
+         menu.add(format);
+         value = RotateAction.createMenu(graph);
+         menuList.put(RotateAction.class, value);
+         format.add(value);
+         value = MirrorAction.createMenu(graph);
+         menuList.put(MirrorAction.class, value);
+         format.add(value);
+         value = FlipAction.createMenu(graph);
+         menuList.put(FlipAction.class, value);
+         format.add(value);
+         value = ShowHideShadowAction.createMenu(graph);
+         menuList.put(ShowHideShadowAction.class, value);
+         format.add(value);
+         /*--- */
+         format.addSeparator();
+         /*--- */
+         Menu alignMenu = ScilabMenu.createMenu();
+         alignMenu.setText(XcosMessages.ALIGN_BLOCKS);
+         alignMenu.add(AlignBlockActionLeft.createMenu(graph));
+         alignMenu.add(AlignBlockActionCenter.createMenu(graph));
+         alignMenu.add(AlignBlockActionRight.createMenu(graph));
+         alignMenu.addSeparator();
+         alignMenu.add(AlignBlockActionTop.createMenu(graph));
+         alignMenu.add(AlignBlockActionMiddle.createMenu(graph));
+         alignMenu.add(AlignBlockActionBottom.createMenu(graph));
+         menuList.put(AlignBlockAction.class, alignMenu);
+         format.add(alignMenu);
+         /*--- */
+         format.addSeparator();
+         /*--- */
+         if (graph.getSelectionCells().length > 1) {
+             format.add(BorderColorAction.createMenu(graph));
+             format.add(FilledColorAction.createMenu(graph));
+         } else {
+             format.add(EditFormatAction.createMenu(graph));
+         }
+         /*--- */
+         menu.getAsSimpleContextMenu().addSeparator();
+         /*--- */
+         menu.add(ViewDetailsAction.createMenu(graph));
+         /*--- */
+         menu.getAsSimpleContextMenu().addSeparator();
+         /*--- */
+         menu.add(BlockDocumentationAction.createMenu(graph));
+         ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()).setLocation(
+                 MouseInfo.getPointerInfo().getLocation().x, MouseInfo
+                         .getPointerInfo().getLocation().y);
+         customizeMenu(menuList);
+         return menu;
+     }
+     // CSON: JavaNCSS
+     /**
+      * @param flip
+      *            value
+      */
+     public void setFlip(boolean flip) {
+         if (getParentDiagram() != null) {
+             isFlipped = flip;
+             final mxIGraphModel model = getParentDiagram().getModel();
+             mxUtils.setCellStyles(model, new Object[] { this },
+                     ScilabGraphConstants.STYLE_FLIP, Boolean.toString(flip));
+         }
+     }
+     /**
+      * Override this to customize contextual menu
+      * 
+      * @param menuList
+      *            list of menu
+      */
+     protected void customizeMenu(
+             Map<Class<? extends DefaultAction>, Menu> menuList) {
+         // To be overridden by sub-classes
+     }
+     /**
+      * @return mirror value
+      */
+     public boolean getMirror() {
+         return isMirrored;
+     }
+     /**
+      * @param mirror
+      *            new mirror value
+      */
+     public void setMirror(boolean mirror) {
+         if (getParentDiagram() != null) {
+             isMirrored = mirror;
+             final mxIGraphModel model = getParentDiagram().getModel();
+             mxUtils.setCellStyles(model, new Object[] { this },
+                     ScilabGraphConstants.STYLE_MIRROR, Boolean.toString(mirror));
+         }
+     }
+     /**
+      * @return flip status
+      */
+     public boolean getFlip() {
+         return isFlipped;
+     }
+     /**
+      * invert flip status
+      */
+     public void toggleFlip() {
+         BlockPositioning.toggleFlip(this);
+     }
+     /**
+      * invert mirror value
+      */
+     public void toggleMirror() {
+         BlockPositioning.toggleMirror(this);
+     }
+     /**
+      * 
+      */
+     public void toggleAntiClockwiseRotation() {
+         BlockPositioning.toggleAntiClockwiseRotation(this);
+     }
+     /**
+      * @return current angle
+      */
+     public int getAngle() {
+         return angle;
+     }
+     /**
+      * @param angle
+      *            new block angle
+      */
+     public void setAngle(int angle) {
+         this.angle = angle;
+         if (getParentDiagram() != null) {
+             mxUtils.setCellStyles(getParentDiagram().getModel(),
+                     new Object[] { this }, mxConstants.STYLE_ROTATION,
+                     Integer.toString(angle));
+         }
+     }
+     /**
+      * Useful when we need to update local properties with mxCell style
+      * properties
+      */
+     public void updateFieldsFromStyle() {
+         StyleMap map = new StyleMap(getStyle());
+         if (map.get(mxConstants.STYLE_ROTATION) != null) {
+             angle = Integer.parseInt(map.get(mxConstants.STYLE_ROTATION));
+         } else {
+             angle = 0;
+         }
+         isFlipped = Boolean.parseBoolean(map
+                 .get(ScilabGraphConstants.STYLE_FLIP));
+         isMirrored = Boolean.parseBoolean(map
+                 .get(ScilabGraphConstants.STYLE_MIRROR));
+     }
+     /**
+      * Set the default block position on the geom
+      * 
+      * @param geom
+      *            the current geom
+      */
+     private void setDefaultPosition(mxGeometry geom) {
+         geom.setX(DEFAULT_POSITION_X);
+         geom.setY(DEFAULT_POSITION_Y);
+     }
+     /**
+      * Get the parameters change support.
+      * 
+      * The property name for each event is the field name, so one of: -
+      * "interfaceFunctionName" - "simulationFunctionName" -
+      * "simulationFunctionType" - "exprs" - "realParameters" -
+      * "integerParameters" - "objectsParameters" - "nbZerosCrossing" - "nmode" -
+      * "state" - "dState" - "oDState" - "equations" - "dependsOnU" -
+      * "dependsOnT" - "blockType" - "ordering"
+      * 
+      * @return the associated {@link PropertyChangeSupport} instance
+      */
+     protected PropertyChangeSupport getParametersPCS() {
+         return parametersPCS;
+     }
+     /*
+      * Overriden methods from jgraphx
+      */
+     /**
+      * @return always false
+      * @see com.mxgraph.model.mxCell#isConnectable()
+      */
+     @Override
+     public boolean isConnectable() {
+         return false;
+     }
+     /**
+      * Re-associate fields with the new instance.
+      * 
+      * @return a new clone instance
+      * @throws CloneNotSupportedException
+      *             never
+      * @see com.mxgraph.model.mxCell#clone()
+      */
+     @Override
+     public Object clone() throws CloneNotSupportedException {
+         BasicBlock clone = (BasicBlock) super.clone();
+         /* Reinstall the PropertyChangeSupport and all of it listeners */
+         clone.parametersPCS = new PropertyChangeSupport(clone);
+         PropertyChangeSupport pcs = getParametersPCS();
+         for (PropertyChangeListener iter : pcs.getPropertyChangeListeners()) {
+             clone.parametersPCS.addPropertyChangeListener(iter);
+         }
+         return clone;
+     }
+     /**
+      * {@inheritDoc}
       * 
+      * Sync the specific child {@link EditFormatAction#HASH_IDENTIFIER}
       */
-       public void toggleAntiClockwiseRotation() {
-               BlockPositioning.toggleAntiClockwiseRotation(this);
-       }
-       /**
-        * @return current angle
-        */
-       public int getAngle() {
-               return angle;
-       }
-       /**
-        * @param angle
-        *            new block angle
-        */
-       public void setAngle(int angle) {
-               this.angle = angle;
-               if (getParentDiagram() != null) {
-                       mxUtils.setCellStyles(getParentDiagram().getModel(),
-                                       new Object[] { this }, mxConstants.STYLE_ROTATION,
-                                       Integer.toString(angle));
-               }
-       }
-       /**
-        * Useful when we need to update local properties with mxCell style
-        * properties
-        */
-       public void updateFieldsFromStyle() {
-               StyleMap map = new StyleMap(getStyle());
-               if (map.get(mxConstants.STYLE_ROTATION) != null) {
-                       angle = Integer.parseInt(map.get(mxConstants.STYLE_ROTATION));
-               } else {
-                       angle = 0;
-               }
-               isFlipped = Boolean.parseBoolean(map
-                               .get(ScilabGraphConstants.STYLE_FLIP));
-               isMirrored = Boolean.parseBoolean(map
-                               .get(ScilabGraphConstants.STYLE_MIRROR));
-       }
-       /**
-        * Set the default block position on the geom
-        * 
-        * @param geom
-        *            the current geom
-        */
-       private void setDefaultPosition(mxGeometry geom) {
-               geom.setX(DEFAULT_POSITION_X);
-               geom.setY(DEFAULT_POSITION_Y);
-       }
-       /**
-        * Get the parameters change support.
-        * 
-        * The property name for each event is the field name, so one of: -
-        * "interfaceFunctionName" - "simulationFunctionName" -
-        * "simulationFunctionType" - "exprs" - "realParameters" -
-        * "integerParameters" - "objectsParameters" - "nbZerosCrossing" - "nmode" -
-        * "state" - "dState" - "oDState" - "equations" - "dependsOnU" -
-        * "dependsOnT" - "blockType" - "ordering"
-        * 
-        * @return the associated {@link PropertyChangeSupport} instance
-        */
-       protected PropertyChangeSupport getParametersPCS() {
-               return parametersPCS;
-       }
-       /*
-        * Overriden methods from jgraphx
-        */
-       /**
-        * @return always false
-        * @see com.mxgraph.model.mxCell#isConnectable()
-        */
-       @Override
-       public boolean isConnectable() {
-               return false;
-       }
-       /**
-        * Re-associate fields with the new instance.
-        * 
-        * @return a new clone instance
-        * @throws CloneNotSupportedException
-        *             never
-        * @see com.mxgraph.model.mxCell#clone()
-        */
-       @Override
-       public Object clone() throws CloneNotSupportedException {
-               BasicBlock clone = (BasicBlock) super.clone();
-               /* Reinstall the PropertyChangeSupport and all of it listeners */
-               clone.parametersPCS = new PropertyChangeSupport(clone);
-               PropertyChangeSupport pcs = getParametersPCS();
-               for (PropertyChangeListener iter : pcs.getPropertyChangeListeners()) {
-                       clone.parametersPCS.addPropertyChangeListener(iter);
-               }
-               return clone;
-       }
-       /**
-        * {@inheritDoc}
-        * 
-        * Sync the specific child {@link EditFormatAction#HASH_IDENTIFIER}
-        */
-       @Override
-       public mxICell insert(mxICell child, int index) {
-               /*
-                * Update the id if this is an identifier cell (herited identifier)
-                */
-               if (child.getId().endsWith(EditFormatAction.HASH_IDENTIFIER)) {
-                       child.setId(getId() + EditFormatAction.HASH_IDENTIFIER);
-               }
-               return super.insert(child, index);
-       }
+     @Override
+     public mxICell insert(mxICell child, int index) {
+         /*
+          * Update the id if this is an identifier cell (herited identifier)
+          */
+         if (child.getId().endsWith(EditFormatAction.HASH_IDENTIFIER)) {
+             child.setId(getId() + EditFormatAction.HASH_IDENTIFIER);
+         }
+         return super.insert(child, index);
+     }
  }
  // CSON: ClassDataAbstractionCoupling
  // CSON: ClassFanOutComplexity
@@@ -63,7 -61,7 +63,6 @@@ import org.scilab.modules.gui.messagebo
  import org.scilab.modules.gui.messagebox.ScilabModalDialog.AnswerOption;
  import org.scilab.modules.gui.messagebox.ScilabModalDialog.ButtonType;
  import org.scilab.modules.gui.messagebox.ScilabModalDialog.IconType;
--import org.scilab.modules.gui.tab.Tab;
  import org.scilab.modules.types.ScilabMList;
  import org.scilab.modules.xcos.Xcos;
  import org.scilab.modules.xcos.XcosTab;
@@@ -124,26 -122,26 +123,26 @@@ import com.mxgraph.view.mxStylesheet
   * The base class for a diagram. This class contains jgraphx + Scicos data.
   */
  public class XcosDiagram extends ScilabGraph {
-       private static final Log LOG = LogFactory.getLog(XcosDiagram.class);
-       
-       private static final String MODIFIED = "modified";
-       private static final String CELLS = "cells";
-       
-       /*
-        * diagram data
-        */
-       
-       // the associated parameters
-       private ScicosParameters scicosParameters;
-       
-       // the scicos engine current status
-       private final transient CompilationEngineStatus engine;
-       
-     //private Window palette;
+     private static final Log LOG = LogFactory.getLog(XcosDiagram.class);
+     private static final String MODIFIED = "modified";
+     private static final String CELLS = "cells";
+     /*
+      * diagram data
+      */
+     // the associated parameters
+     private ScicosParameters scicosParameters;
+     // the scicos engine current status
+     private final transient CompilationEngineStatus engine;
+     // private Window palette;
 -    private Tab viewPort;
 +    private SwingScilabTab viewPort;
  
      private CheckBoxMenuItem viewPortMenu;
-       
      /**
       * Constructor
       */
       * @return the context at the current node
       */
      public String[] getContext() {
-               return scicosParameters.getContext();
+         return scicosParameters.getContext();
      }
-     
      /**
       * Set the associated ViewPort
-      * @param viewPort the Viewport
+      * 
+      * @param viewPort
+      *            the Viewport
       */
 -    public void setViewPort(final Tab viewPort) {
 +    public void setViewPort(final SwingScilabTab viewPort) {
-       this.viewPort = viewPort;
+         this.viewPort = viewPort;
      }
  
      /**
       * Get the associated ViewPort
+      * 
       * @return the Viewport
       */
 -    public Tab getViewPort() {
 +    public SwingScilabTab getViewPort() {
-       return viewPort;
+         return viewPort;
      }
  
      /**
       * Manage the visibility of the associated viewport
-      * @param status new status
+      * 
+      * @param status
+      *            new status
       */
-       public void setViewPortVisible(final boolean status) {
-               final SwingScilabWindow win = SwingScilabWindow.allScilabWindows
-                               .get(viewPort.getParentWindowId());
-               // Hide/Show parent window if the viewport is the only tab
-               if (win.getNbDockedObjects() == 1) {
-                       win.setVisible(status);
-               }
-               // Hide/Show viewport tab
-               viewPort.setVisible(status);
-               // (Un)Check the corresponding menu
-               viewPortMenu.setChecked(status);
-       }
+     public void setViewPortVisible(final boolean status) {
++        final SwingScilabWindow win = SwingScilabWindow.allScilabWindows
++                .get(viewPort.getParentWindowId());
+         // Hide/Show parent window if the viewport is the only tab
 -        if (viewPort.getParentWindow().getNbDockedObjects() == 1) {
 -            viewPort.getParentWindow().setVisible(status);
++        if (win != null && win.getNbDockedObjects() == 1) {
++            win.setVisible(status);
+         }
+         // Hide/Show viewport tab
+         viewPort.setVisible(status);
+         // (Un)Check the corresponding menu
+         viewPortMenu.setChecked(status);
+     }
  
      /**
       * Set menu used to manage Viewport visibility
@@@ -38,118 -38,136 +38,136 @@@ import org.scilab.modules.xcos.utils.Xc
  
  /** Implement the default mouse listener for the block */
  public final class PaletteBlockMouseListener implements MouseListener {
-       /** Default constructor */
-       public PaletteBlockMouseListener() { }
-       /**
-        * Load and perform display update on mouse click
-        * @param e The associated event 
-        */
-       @Override
-       public void mouseClicked(MouseEvent e) {
-               if ((e.getClickCount() == 1 && SwingUtilities.isRightMouseButton(e))
-                               || e.isPopupTrigger()
-                               || XcosMessages.isMacOsPopupTrigger(e)) {
-                       ContextMenu menu = ScilabContextMenu.createContextMenu();
-                       final List<XcosDiagram> allDiagrams = Xcos.getInstance().getDiagrams();
-                       final PaletteBlockCtrl control = ((PaletteBlockView) e.getSource()).getController();
-                       
-                       // No diagram opened: should never happen as Xcos opens an empty diagram when it is launched
-                       assert allDiagrams.size() != 0;
-                       
-                       if (allDiagrams.size() == 1) {
-                               // A single diagram opened: add to this diagram
-                               MenuItem addTo = ScilabMenuItem.createMenuItem();
-                               addTo.setText(XcosMessages.ADDTO + " " + allDiagrams.get(0).getParentTab().getName());
-                               final XcosDiagram theDiagram = allDiagrams.get(0);
-                               addTo.setCallback(new CommonCallBack(e.toString()) {
-                                       @Override
-                                       public void callBack() {
-                                               BasicBlock current = control.getBlock();
-                                               theDiagram.addCell(current);
-                                       }
-                               });
-                               menu.add(addTo);
-                       } else {
-                               // The user has to choose
-                               Menu addTo = ScilabMenu.createMenu();
-                               addTo.setText(XcosMessages.ADDTO);
-                               for (int i = 0; i < allDiagrams.size(); i++) {
-                                       MenuItem diagram = ScilabMenuItem.createMenuItem();
-                                       final XcosDiagram theDiagram = allDiagrams.get(i);
-                                       diagram.setText(allDiagrams.get(i).getParentTab().getName());
-                                       diagram.setCallback(new CommonCallBack(e.toString()) {
-                                               @Override
-                                               public void callBack() {
-                                                       BasicBlock current = control.getBlock();
-                                                       theDiagram.addCell(current);
-                                               }
-                                       });
-                                       addTo.add(diagram);
-                               }
-                               menu.add(addTo);
-                       }
-                       menu.getAsSimpleContextMenu().addSeparator();
-                       MenuItem help = ScilabMenuItem.createMenuItem();
-                       help.setText("Block help");
-                       help.setCallback(new CommonCallBack(e.toString()) {
-                               @Override
-                               public void callBack() {
-                                       try {
-                                               ScilabInterpreterManagement.asynchronousScilabExec(null, "help", control.getModel().getName());
-                                       } catch (InterpreterException e) {
-                                               e.printStackTrace();
-                                       }
-                               }
-                       });
-                       menu.add(help);
-                       menu.setVisible(true);
-                       ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()).setLocation(
-                                       MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y);
-               }
-       }
-       /**
-        * Not used
-        * @param e Not used
-        */
-       @Override
-       public void mouseEntered(MouseEvent e) { }
-       /**
-        * Not used
-        * @param e Not used
-        */
-       @Override
-       public void mouseExited(MouseEvent e) { }
-       /**
-        * Select on mouse press
-        * @param e The associated event
-        */
-       @Override
-       public void mousePressed(MouseEvent e) {
-               PaletteBlockView view = (PaletteBlockView) e.getSource();
-               view.getController().setSelected(true);
-       }
-       /**
-        * Not used
-        * @param e Not used
-        */
-       @Override
-       public void mouseReleased(MouseEvent e) { }
+     /** Default constructor */
+     public PaletteBlockMouseListener() {
+     }
+     /**
+      * Load and perform display update on mouse click
+      * 
+      * @param e
+      *            The associated event
+      */
+     @Override
+     public void mouseClicked(MouseEvent e) {
+         if ((e.getClickCount() == 1 && SwingUtilities.isRightMouseButton(e))
+                 || e.isPopupTrigger() || XcosMessages.isMacOsPopupTrigger(e)) {
+             ContextMenu menu = ScilabContextMenu.createContextMenu();
+             final List<XcosDiagram> allDiagrams = Xcos.getInstance()
+                     .getDiagrams();
+             final PaletteBlockCtrl control = ((PaletteBlockView) e.getSource())
+                     .getController();
+             // No diagram opened: should never happen as Xcos opens an empty
+             // diagram when it is launched
+             assert allDiagrams.size() != 0;
+             if (allDiagrams.size() == 1) {
+                 // A single diagram opened: add to this diagram
+                 MenuItem addTo = ScilabMenuItem.createMenuItem();
+                 addTo.setText(XcosMessages.ADDTO + " "
+                         + allDiagrams.get(0).getParentTab().getName());
+                 final XcosDiagram theDiagram = allDiagrams.get(0);
 -                addTo.setCallback(new CallBack(e.toString()) {
++                addTo.setCallback(new CommonCallBack(e.toString()) {
+                     @Override
+                     public void callBack() {
+                         BasicBlock current = control.getBlock();
+                         theDiagram.addCell(current);
+                     }
+                 });
+                 menu.add(addTo);
+             } else {
+                 // The user has to choose
+                 Menu addTo = ScilabMenu.createMenu();
+                 addTo.setText(XcosMessages.ADDTO);
+                 for (int i = 0; i < allDiagrams.size(); i++) {
+                     MenuItem diagram = ScilabMenuItem.createMenuItem();
+                     final XcosDiagram theDiagram = allDiagrams.get(i);
+                     diagram.setText(allDiagrams.get(i).getParentTab().getName());
 -                    diagram.setCallback(new CallBack(e.toString()) {
++                    diagram.setCallback(new CommonCallBack(e.toString()) {
+                         @Override
+                         public void callBack() {
+                             BasicBlock current = control.getBlock();
+                             theDiagram.addCell(current);
+                         }
+                     });
+                     addTo.add(diagram);
+                 }
+                 menu.add(addTo);
+             }
+             menu.getAsSimpleContextMenu().addSeparator();
+             MenuItem help = ScilabMenuItem.createMenuItem();
+             help.setText("Block help");
 -            help.setCallback(new CallBack(e.toString()) {
++            help.setCallback(new CommonCallBack(e.toString()) {
+                 @Override
+                 public void callBack() {
+                     try {
+                         ScilabInterpreterManagement.asynchronousScilabExec(
+                                 null, "help", control.getModel().getName());
+                     } catch (InterpreterException e) {
+                         e.printStackTrace();
+                     }
+                 }
+             });
+             menu.add(help);
+             menu.setVisible(true);
+             ((SwingScilabContextMenu) menu.getAsSimpleContextMenu())
+                     .setLocation(MouseInfo.getPointerInfo().getLocation().x,
+                             MouseInfo.getPointerInfo().getLocation().y);
+         }
+     }
+     /**
+      * Not used
+      * 
+      * @param e
+      *            Not used
+      */
+     @Override
+     public void mouseEntered(MouseEvent e) {
+     }
+     /**
+      * Not used
+      * 
+      * @param e
+      *            Not used
+      */
+     @Override
+     public void mouseExited(MouseEvent e) {
+     }
+     /**
+      * Select on mouse press
+      * 
+      * @param e
+      *            The associated event
+      */
+     @Override
+     public void mousePressed(MouseEvent e) {
+         PaletteBlockView view = (PaletteBlockView) e.getSource();
+         view.getController().setSelected(true);
+     }
+     /**
+      * Not used
+      * 
+      * @param e
+      *            Not used
+      */
+     @Override
+     public void mouseReleased(MouseEvent e) {
+     }
  }
@@@ -38,172 -38,194 +38,194 @@@ import org.scilab.modules.xcos.utils.Xc
   */
  public class PaletteManagerMouseListener implements MouseListener {
  
-       /** Default constructor */
-       public PaletteManagerMouseListener() { }
-       
-       /**
-        * Manage category selection
-        * @param e Not used
-        * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
-        */
-       @Override
-       public void mouseClicked(final MouseEvent e) {
-               // Right click
-               if ((e.getClickCount() == 1 && SwingUtilities.isRightMouseButton(e))
-                               || e.isPopupTrigger() || XcosMessages.isMacOsPopupTrigger(e)) {
-                       final PaletteManager manager = PaletteManager.getInstance();
-                       final JTree paletteTree = manager.getView().getTree();
-                       final TreePath path = paletteTree.getPathForLocation(e.getX(), e
-                                       .getY());
-                       paletteTree.setSelectionPath(path);
-                       final ContextMenu menu = ScilabContextMenu.createContextMenu();
-                       final MenuItem create = ScilabMenuItem.createMenuItem();
-                       setupCreateOrAdd(paletteTree, path, create);
-                       menu.add(create);
-                       
-                       final MenuItem remove = ScilabMenuItem.createMenuItem();
-                       setupRemove(paletteTree, path, remove);
-                       menu.add(remove);
-                       
-                       menu.setVisible(true);
-                       ((SwingScilabContextMenu) menu.getAsSimpleContextMenu())
-                                       .setLocation(MouseInfo.getPointerInfo().getLocation().x,
-                                                       MouseInfo.getPointerInfo().getLocation().y);
-               }
-       }
-       /**
-        * Setup the create item
-        * @param paletteTree the current tree
-        * @param path the current path
-        * @param create the menu item
-        */
-       private void setupCreateOrAdd(final JTree paletteTree, final TreePath path,
-                       final MenuItem create) {
-               PaletteNode node;
-               if (path != null) {
-                       node = (PaletteNode) (path.getLastPathComponent());
-               } else {
-                       node = (PaletteNode) paletteTree.getModel().getRoot();
-               }
-               final PaletteNode currentNode = node; 
-               
-               if (currentNode instanceof Category) {
-                       create.setText(XcosMessages.CREATE);
-               } else if (currentNode instanceof Palette) {
-                       create.setText(XcosMessages.ADDTO_CATEGORY);
-               } else {
-                       throw new IllegalArgumentException("Invalid node selected");
-               }
-               
-               create.setCallback(new CommonCallBack(XcosMessages.CREATE) {
-                       @Override
-                       public void callBack() {
-                               Category nonModifiedRoot = currentNode.getParent();
-                               final Category c = new Category();
-                               c.setEnable(true);
-                               c.setName(XcosMessages.DEFAULT_CATEGORY_NAME);
-                               
-                               if (currentNode instanceof Category) {
-                                       ((Category) currentNode).getNode().add(c);
-                                       c.setParent((Category) currentNode);
-                                       if (path != null) {
-                                               path.pathByAddingChild(c);
-                                       } else {
-                                               nonModifiedRoot = (Category) currentNode;
-                                       }
-                               } else if (currentNode instanceof Palette) {
-                                       final int index = nonModifiedRoot.getIndex(currentNode);
-                                       nonModifiedRoot.getNode().set(index, c);
-                                       c.getNode().add(currentNode);
-                                       currentNode.setParent(c);
-                                       c.setParent(nonModifiedRoot);
-                                       path.getParentPath().pathByAddingChild(c);
-                               }
-                               
-                               PaletteNode.refreshView(c);
-                       }
-               });
-               create.setEnabled(true);
-       }
-       
-       /**
-        * Setup the remove item
-        * @param paletteTree the current tree
-        * @param path the current path
-        * @param remove the menu item
-        */
-       // CSOFF: IllegalCatch
-       private void setupRemove(final JTree paletteTree, final TreePath path,
-                       final MenuItem remove) {
-               remove.setText(XcosMessages.REMOVE);
-               remove.setCallback(new CommonCallBack(XcosMessages.REMOVE) {
-                       @Override
-                       public void callBack() {
-                               if (path == null) {
-                                       return;
-                               }
-                               
-                               try {
-                                       final PaletteNode currentNode = (PaletteNode) path.getLastPathComponent();
-                                       PaletteNode.remove(currentNode);
-                               } catch (final Exception exception) {
-                                       LogFactory.getLog(PaletteManagerMouseListener.class).error(exception);
-                               }
-                       }
-               });
-               boolean canBeRemoved = true;
-               try {
-                       org.scilab.modules.xcos.palette.model.PaletteNode
-                                       .checkRemoving((PaletteNode) path.getLastPathComponent());
-               } catch (final Exception exception) {
-                       canBeRemoved = false;
-               }
-               
-               remove.setEnabled(canBeRemoved);
-       }
-       // CSON: IllegalCatch
-       
-       /**
-        * Not used
-        * @param e Not used
-        * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
-        */
-       @Override
-       public void mouseEntered(final MouseEvent e) {
-       }
-       /**
-        * Not used
-        * @param e Not used
-        * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
-        */
-       @Override
-       public void mouseExited(final MouseEvent e) {   
-       }
-       /**
-        * Not used
-        * @param e Not used
-        * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
-        */
-       @Override
-       public void mousePressed(final MouseEvent e) {
-       }
-       /**
-        * Not used
-        * @param e Not used
-        * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
-        */
-       @Override
-       public void mouseReleased(final MouseEvent e) {
-       }
+     /** Default constructor */
+     public PaletteManagerMouseListener() {
+     }
+     /**
+      * Manage category selection
+      * 
+      * @param e
+      *            Not used
+      * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+      */
+     @Override
+     public void mouseClicked(final MouseEvent e) {
+         // Right click
+         if ((e.getClickCount() == 1 && SwingUtilities.isRightMouseButton(e))
+                 || e.isPopupTrigger() || XcosMessages.isMacOsPopupTrigger(e)) {
+             final PaletteManager manager = PaletteManager.getInstance();
+             final JTree paletteTree = manager.getView().getTree();
+             final TreePath path = paletteTree.getPathForLocation(e.getX(),
+                     e.getY());
+             paletteTree.setSelectionPath(path);
+             final ContextMenu menu = ScilabContextMenu.createContextMenu();
+             final MenuItem create = ScilabMenuItem.createMenuItem();
+             setupCreateOrAdd(paletteTree, path, create);
+             menu.add(create);
+             final MenuItem remove = ScilabMenuItem.createMenuItem();
+             setupRemove(paletteTree, path, remove);
+             menu.add(remove);
+             menu.setVisible(true);
+             ((SwingScilabContextMenu) menu.getAsSimpleContextMenu())
+                     .setLocation(MouseInfo.getPointerInfo().getLocation().x,
+                             MouseInfo.getPointerInfo().getLocation().y);
+         }
+     }
+     /**
+      * Setup the create item
+      * 
+      * @param paletteTree
+      *            the current tree
+      * @param path
+      *            the current path
+      * @param create
+      *            the menu item
+      */
+     private void setupCreateOrAdd(final JTree paletteTree, final TreePath path,
+             final MenuItem create) {
+         PaletteNode node;
+         if (path != null) {
+             node = (PaletteNode) (path.getLastPathComponent());
+         } else {
+             node = (PaletteNode) paletteTree.getModel().getRoot();
+         }
+         final PaletteNode currentNode = node;
+         if (currentNode instanceof Category) {
+             create.setText(XcosMessages.CREATE);
+         } else if (currentNode instanceof Palette) {
+             create.setText(XcosMessages.ADDTO_CATEGORY);
+         } else {
+             throw new IllegalArgumentException("Invalid node selected");
+         }
 -        create.setCallback(new CallBack(XcosMessages.CREATE) {
++        create.setCallback(new CommonCallBack(XcosMessages.CREATE) {
+             @Override
+             public void callBack() {
+                 Category nonModifiedRoot = currentNode.getParent();
+                 final Category c = new Category();
+                 c.setEnable(true);
+                 c.setName(XcosMessages.DEFAULT_CATEGORY_NAME);
+                 if (currentNode instanceof Category) {
+                     ((Category) currentNode).getNode().add(c);
+                     c.setParent((Category) currentNode);
+                     if (path != null) {
+                         path.pathByAddingChild(c);
+                     } else {
+                         nonModifiedRoot = (Category) currentNode;
+                     }
+                 } else if (currentNode instanceof Palette) {
+                     final int index = nonModifiedRoot.getIndex(currentNode);
+                     nonModifiedRoot.getNode().set(index, c);
+                     c.getNode().add(currentNode);
+                     currentNode.setParent(c);
+                     c.setParent(nonModifiedRoot);
+                     path.getParentPath().pathByAddingChild(c);
+                 }
+                 PaletteNode.refreshView(c);
+             }
+         });
+         create.setEnabled(true);
+     }
+     /**
+      * Setup the remove item
+      * 
+      * @param paletteTree
+      *            the current tree
+      * @param path
+      *            the current path
+      * @param remove
+      *            the menu item
+      */
+     // CSOFF: IllegalCatch
+     private void setupRemove(final JTree paletteTree, final TreePath path,
+             final MenuItem remove) {
+         remove.setText(XcosMessages.REMOVE);
 -        remove.setCallback(new CallBack(XcosMessages.REMOVE) {
++        remove.setCallback(new CommonCallBack(XcosMessages.REMOVE) {
+             @Override
+             public void callBack() {
+                 if (path == null) {
+                     return;
+                 }
+                 try {
+                     final PaletteNode currentNode = (PaletteNode) path
+                             .getLastPathComponent();
+                     PaletteNode.remove(currentNode);
+                 } catch (final Exception exception) {
+                     LogFactory.getLog(PaletteManagerMouseListener.class).error(
+                             exception);
+                 }
+             }
+         });
+         boolean canBeRemoved = true;
+         try {
+             org.scilab.modules.xcos.palette.model.PaletteNode
+                     .checkRemoving((PaletteNode) path.getLastPathComponent());
+         } catch (final Exception exception) {
+             canBeRemoved = false;
+         }
+         remove.setEnabled(canBeRemoved);
+     }
+     // CSON: IllegalCatch
+     /**
+      * Not used
+      * 
+      * @param e
+      *            Not used
+      * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
+      */
+     @Override
+     public void mouseEntered(final MouseEvent e) {
+     }
+     /**
+      * Not used
+      * 
+      * @param e
+      *            Not used
+      * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
+      */
+     @Override
+     public void mouseExited(final MouseEvent e) {
+     }
+     /**
+      * Not used
+      * 
+      * @param e
+      *            Not used
+      * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
+      */
+     @Override
+     public void mousePressed(final MouseEvent e) {
+     }
+     /**
+      * Not used
+      * 
+      * @param e
+      *            Not used
+      * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
+      */
+     @Override
+     public void mouseReleased(final MouseEvent e) {
+     }
  
  }
@@@ -32,8 -31,12 +32,9 @@@ import org.scilab.modules.gui.menubar.S
  import org.scilab.modules.gui.textbox.ScilabTextBox;
  import org.scilab.modules.gui.toolbar.ScilabToolBar;
  import org.scilab.modules.gui.toolbar.ToolBar;
+ import org.scilab.modules.gui.utils.BarUpdater;
  import org.scilab.modules.gui.utils.Position;
  import org.scilab.modules.gui.utils.Size;
 -import org.scilab.modules.gui.window.ScilabWindow;
 -import org.scilab.modules.gui.window.Window;
  import org.scilab.modules.xcos.Xcos;
  import org.scilab.modules.xcos.configuration.ConfigurationManager;
  import org.scilab.modules.xcos.configuration.model.PositionType;
@@@ -45,166 -48,175 +46,178 @@@ import org.scilab.modules.xcos.utils.Xc
  /**
   * Implement the default view for the palette
   */
 -public class PaletteManagerView extends ScilabTab {
 +public class PaletteManagerView extends SwingScilabTab {
-       private static final String ICON_PATH = System.getenv("SCI") + "/modules/gui/images/icons/32x32/apps/utilities-system-monitor.png";
-       
-       private final PaletteManager controller;
-       private PaletteManagerPanel panel;
-       /**
-        * Default constructor
-        * @param controller the associated controller
-        */
-       public PaletteManagerView(final PaletteManager controller) {
-               super(XcosMessages.PALETTE_BROWSER + " - " + Xcos.TRADENAME);
-               setWindowIcon(new ImageIcon(ICON_PATH).getImage());
-               this.controller = controller;
-               initComponents();
-       }
-       /**
-        * @return the controller
-        */
-       protected PaletteManager getController() {
-               return controller;
-       }
-       
-       /**
-        * @return the panel
-        */
-       public PaletteManagerPanel getPanel() {
-               return panel;
-       }
-       
-       /**
-        * @param panel the panel to set
-        */
-       public void setPanel(final PaletteManagerPanel panel) {
-               this.panel = panel;
-       }
-       
-       /** Instantiate and setup all the components */
-       private void initComponents() {
-               final SwingScilabWindow window = new SwingScilabWindow();
-               
-               final ConfigurationManager manager = ConfigurationManager.getInstance();
-               final PositionType p = manager.getSettings().getWindows().getPalette();
-               
-               window.setBounds(p.getX(), p.getY(), p.getWidth(), p.getHeight());
-               
-               /* Create the menu bar */
-               final MenuBar menuBar = ScilabMenuBar.createMenuBar();
-               final Menu menu = ScilabMenu.createMenu();
-               menu.setText(XcosMessages.PALETTES);
-               menu.setMnemonic('P');
-               menuBar.add(menu);
-               menu.add(LoadAsPalAction.createMenu(null));
-               menu.addSeparator();
-               menu.add(ClosePalettesAction.createMenu(null));
-               
-               setMenuBar(menuBar);
-               /* Create the toolbar */
-               final ToolBar toolbar = ScilabToolBar.createToolBar();
-               toolbar.add(LoadAsPalAction.createButton(null));
-               
-               setToolBar(toolbar);
-               /* Create the content pane */
-               panel = new PaletteManagerPanel(getController());
-               setContentPane(panel);
-               
-               /* Create the infobar */
-               setInfoBar(ScilabTextBox.createTextBox());
-               
-               setCallback(new ClosePalettesAction(null));
-               window.addTab(this);
-               window.setVisible(true);
-               
-               getTree().revalidate();
-               getPanel().performStartUpLayout();
-       }
-       
-       /** @return the category tree */
-       public JTree getTree() {
-               return (JTree) ((JScrollPane) panel.getLeftComponent()).getViewport()
-                               .getView();
-       }
-       
-       /**
-        * Update the selected path on the tree
-        */
-       public static void updateTree() {
-               final JTree t = PaletteManager.getInstance().getView().getTree();
-               final TreePath p = t.getSelectionPath();
-               
-               if (p == null) {
-                       updateWholeTree();
-               } else {
-                       ((DefaultTreeModel) t.getModel()).reload((TreeNode) p.getLastPathComponent());
-                       t.setSelectionPath(p);
-               }
-       }
-       
-       /**
-        * Update the whole tree
-        */
-       public static void updateWholeTree() {
-               final JTree t = PaletteManager.getInstance().getView().getTree();
-               
-               final TreePath selectedPath = t.getSelectionPath();
-               ((DefaultTreeModel) t.getModel()).reload();
-               t.setSelectionPath(selectedPath);
-       }
-       
-       /** @param info the information to write on the infobar */
-       public void setInfo(final String info) {
-               getInfoBar().setText(info);
-               
-               /*
-                * Force repaint
-                */
-               ((SwingScilabTextBox) getInfoBar()
-                               .getAsSimpleTextBox()).repaint();
-               RepaintManager.currentManager(this).paintDirtyRegions();
-       }
-       
-       /**
-        * Handle the associated Tab removing and recreation 
-        * 
-        * @param newVisibleState the new status
-        * @see org.scilab.modules.gui.tab.ScilabTab#setVisible(boolean)
-        */
-       @Override
-       public void setVisible(final boolean newVisibleState) {
-               super.setVisible(newVisibleState);
-               
-               SwingScilabWindow win = SwingScilabWindow.allScilabWindows
-                               .get(getParentWindowId());
-               
-               /*
-                * Recreate the window if applicable
-                */
-               if (newVisibleState && win == null) {
-                       final SwingScilabWindow paletteWindow = new SwingScilabWindow();
-                       paletteWindow.setVisible(true);
-                       super.setVisible(true);
-                       paletteWindow.addTab(this);
-                       
-                       win = SwingScilabWindow.allScilabWindows.get(getParentWindowId());
-               }
-               
-               if (win != null) {
-                       if (win.getNbDockedObjects() == 1) {
-                               win.setVisible(newVisibleState);
-                       } else {
-                               if (!newVisibleState) {
-                                       DockingManager.undock((Dockable) this);
-                                       setParentWindowId(null);
-                               }
-                       }
-               }
-       }
+     private static final String ICON_PATH = System.getenv("SCI")
+             + "/modules/gui/images/icons/32x32/apps/utilities-system-monitor.png";
+     private final PaletteManager controller;
+     private PaletteManagerPanel panel;
+     /**
+      * Default constructor
+      * 
+      * @param controller
+      *            the associated controller
+      */
+     public PaletteManagerView(final PaletteManager controller) {
+         super(XcosMessages.PALETTE_BROWSER + " - " + Xcos.TRADENAME);
 -        ((SwingScilabTab) getAsSimpleTab()).setWindowIcon(new ImageIcon(
 -                ICON_PATH).getImage());
++        setWindowIcon(new ImageIcon(ICON_PATH).getImage());
+         this.controller = controller;
+         initComponents();
+     }
+     /**
+      * @return the controller
+      */
+     protected PaletteManager getController() {
+         return controller;
+     }
+     /**
+      * @return the panel
+      */
+     public PaletteManagerPanel getPanel() {
+         return panel;
+     }
+     /**
+      * @param panel
+      *            the panel to set
+      */
+     public void setPanel(final PaletteManagerPanel panel) {
+         this.panel = panel;
+     }
+     /** Instantiate and setup all the components */
+     private void initComponents() {
 -        final Window window = ScilabWindow.createWindow();
++        final SwingScilabWindow window = new SwingScilabWindow();
+         final ConfigurationManager manager = ConfigurationManager.getInstance();
+         final PositionType p = manager.getSettings().getWindows().getPalette();
+         window.setDims(new Size(p.getWidth(), p.getHeight()));
+         window.setPosition(new Position(p.getX(), p.getY()));
+         /* Create the menu bar */
+         final MenuBar menuBar = ScilabMenuBar.createMenuBar();
+         final Menu menu = ScilabMenu.createMenu();
+         menu.setText(XcosMessages.PALETTES);
+         menu.setMnemonic('P');
+         menuBar.add(menu);
+         menu.add(LoadAsPalAction.createMenu(null));
+         menu.addSeparator();
+         menu.add(ClosePalettesAction.createMenu(null));
 -        addMenuBar(menuBar);
++        setMenuBar(menuBar);
+         /* Create the toolbar */
+         final ToolBar toolbar = ScilabToolBar.createToolBar();
+         toolbar.add(LoadAsPalAction.createButton(null));
 -        addToolBar(toolbar);
++        setToolBar(toolbar);
+         /* Create the content pane */
+         panel = new PaletteManagerPanel(getController());
 -        ((SwingScilabTab) getAsSimpleTab()).setContentPane(panel);
++        setContentPane(panel);
+         /* Create the infobar */
 -        getAsSimpleTab().setInfoBar(ScilabTextBox.createTextBox());
++        setInfoBar(ScilabTextBox.createTextBox());
+         setCallback(new ClosePalettesAction(null));
+         window.addTab(this);
+         BarUpdater.updateBars(getParentWindowId(), getMenuBar(), getToolBar(),
+                 getInfoBar(), getName());
+         window.setVisible(true);
+         getTree().revalidate();
+         getPanel().performStartUpLayout();
+     }
+     /** @return the category tree */
+     public JTree getTree() {
+         return (JTree) ((JScrollPane) panel.getLeftComponent()).getViewport()
+                 .getView();
+     }
+     /**
+      * Update the selected path on the tree
+      */
+     public static void updateTree() {
+         final JTree t = PaletteManager.getInstance().getView().getTree();
+         final TreePath p = t.getSelectionPath();
+         if (p == null) {
+             updateWholeTree();
+         } else {
+             ((DefaultTreeModel) t.getModel()).reload((TreeNode) p
+                     .getLastPathComponent());
+             t.setSelectionPath(p);
+         }
+     }
+     /**
+      * Update the whole tree
+      */
+     public static void updateWholeTree() {
+         final JTree t = PaletteManager.getInstance().getView().getTree();
+         final TreePath selectedPath = t.getSelectionPath();
+         ((DefaultTreeModel) t.getModel()).reload();
+         t.setSelectionPath(selectedPath);
+     }
+     /**
+      * @param info
+      *            the information to write on the infobar
+      */
+     public void setInfo(final String info) {
 -        getAsSimpleTab().getInfoBar().setText(info);
++        getInfoBar().setText(info);
+         /*
+          * Force repaint
+          */
 -        ((SwingScilabTextBox) getAsSimpleTab().getInfoBar()
++        ((SwingScilabTextBox) getInfoBar()
+                 .getAsSimpleTextBox()).repaint();
 -        RepaintManager.currentManager((SwingScilabTab) this.getAsSimpleTab())
++        RepaintManager.currentManager((SwingScilabTab) this)
+                 .paintDirtyRegions();
+     }
+     /**
+      * Handle the associated Tab removing and recreation
+      * 
+      * @param newVisibleState
+      *            the new status
+      * @see org.scilab.modules.gui.tab.ScilabTab#setVisible(boolean)
+      */
+     @Override
+     public void setVisible(final boolean newVisibleState) {
+         super.setVisible(newVisibleState);
 -
 -        /*
++        
++        SwingScilabWindow win = SwingScilabWindow.allScilabWindows.get(getParentWindowId());
++        
++                /*
+          * Recreate the window if applicable
+          */
 -        if (newVisibleState && getParentWindow() == null) {
 -            final Window paletteWindow = ScilabWindow.createWindow();
++        if (newVisibleState && win == null) {
++            final SwingScilabWindow paletteWindow = new SwingScilabWindow();
+             paletteWindow.setVisible(true);
+             super.setVisible(true);
+             paletteWindow.addTab(this);
++
++            win = SwingScilabWindow.allScilabWindows.get(getParentWindowId());
+         }
 -        if (getParentWindow() != null) {
 -            if (getParentWindow().getNbDockedObjects() == 1) {
 -                getParentWindow().setVisible(newVisibleState);
++        if (win != null) {
++            if (win.getNbDockedObjects() == 1) {
++                win.setVisible(newVisibleState);
+             } else {
+                 if (!newVisibleState) {
 -                    DockingManager.undock((Dockable) getAsSimpleTab());
 -                    setParentWindowId(-1);
++                    DockingManager.undock((Dockable) this);
++                    setParentWindowId(null);
+                 }
+             }
+         }
+     }
  }
Simple merge