add savegui as xml file, change xml format to manage all figure/uicontrol properties 56/13756/8
Antoine ELIAS [Fri, 14 Feb 2014 19:31:29 +0000 (20:31 +0100)]
Change-Id: Iffe705aea25b79832ce97fd21331f0db2cb22274

41 files changed:
scilab/modules/graphic_objects/includes/createGraphicObject.h
scilab/modules/graphic_objects/includes/graphicObjectProperties.h
scilab/modules/graphic_objects/src/cpp/createGraphicObject.cpp
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/CallXmlLoader.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/builder/Builder.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicObject/GraphicObjectProperties.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/uicontrol/Uicontrol.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/uicontrol/layer/Layer.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/uicontrol/tab/Tab.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/GOBuilder.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/Pair.java [new file with mode: 0644]
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XMLDomLoader.java [new file with mode: 0644]
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlLoader.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlSaver.java [new file with mode: 0644]
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlTools.java
scilab/modules/graphic_objects/src/jni/CallXmlLoader.cpp
scilab/modules/graphic_objects/src/jni/CallXmlLoader.hxx
scilab/modules/graphic_objects/src/jni/graphic_objects.giws.xml
scilab/modules/graphic_objects/src/scripts/propertiesMap.properties
scilab/modules/graphics/macros/%GridBagC_p.sci
scilab/modules/graphics/macros/createConstraints.sci
scilab/modules/graphics/sci_gateway/c/sci_set.c
scilab/modules/graphics/src/c/getHandleProperty/get_constraints_property.c
scilab/modules/graphics/src/c/getHandleProperty/set_constraints_property.c
scilab/modules/gui/Makefile.am
scilab/modules/gui/Makefile.in
scilab/modules/gui/includes/gw_gui.h
scilab/modules/gui/sci_gateway/c/gw_gui.c
scilab/modules/gui/sci_gateway/cpp/sci_loadGui.cpp [new file with mode: 0644]
scilab/modules/gui/sci_gateway/cpp/sci_saveGui.cpp [new file with mode: 0644]
scilab/modules/gui/sci_gateway/gui_gateway.xml
scilab/modules/gui/src/c/gui.vcxproj
scilab/modules/gui/src/c/gui.vcxproj.filters
scilab/modules/gui/src/java/org/scilab/modules/gui/SwingViewWidget.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/editbox/SwingScilabEditBox.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/frame/SwingScilabFrame.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/frame/SwingScilabLayer.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/frame/SwingScilabScrollableFrame.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/label/SwingScilabLabel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabCommonPanel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/utils/BorderConvertor.java

index 6e45435..a859f8e 100644 (file)
@@ -72,4 +72,6 @@ GRAPHIC_OBJECTS_IMPEXP void initSubWinTo3d(int subwin, char* legend, int* flag,
         double* ebox, double* x, int xSize, double* y, int ySize, double* z, int zSize);
 
 GRAPHIC_OBJECTS_IMPEXP int xmlload(char* xmlfile);
+GRAPHIC_OBJECTS_IMPEXP int xmldomload(char* xmlfile);
+GRAPHIC_OBJECTS_IMPEXP char* xmlsave(int id, char* xmlfile);
 #endif /* !__CREATEGRAPHICOBJECT_H__ */
index e69fe3b..c63e75d 100755 (executable)
 #define __GO_UI_GRIDBAG_FILL__ 351
 #define __GO_UI_GRIDBAG_ANCHOR__ 352
 #define __GO_UI_GRIDBAG_PADDING__ 353
-#define __GO_UI_GRID_GRID__ 354
-#define __GO_UI_GRID_PADDING__ 355
-#define __GO_UI_BORDER_POSITION__ 356
-#define __GO_GRID_OPT_GRID__ 357
-#define __GO_GRID_OPT_PADDING__ 358
-#define __GO_BORDER_OPT_PADDING__ 359
-#define __GO_UI_FRAME_BORDER__ 360
-#define __GO_UI_FRAME_BORDER_COLOR__ 361
-#define __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__ 362
-#define __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__ 363
-#define __GO_UI_FRAME_BORDER_IN_BORDER__ 364
-#define __GO_UI_FRAME_BORDER_JUSTIFICATION__ 365
-#define __GO_UI_FRAME_BORDER_OUT_BORDER__ 366
-#define __GO_UI_FRAME_BORDER_ROUNDED__ 367
-#define __GO_UI_FRAME_BORDER_SHADOW_IN__ 368
-#define __GO_UI_FRAME_BORDER_SHADOW_OUT__ 369
-#define __GO_UI_FRAME_BORDER_TITLE__ 370
-#define __GO_UI_FRAME_BORDER_POSITION__ 371
-#define __GO_UI_FRAME_BORDER_STYLE__ 372
-#define __GO_UI_GROUP_NAME__ 373
-#define __GO_UI_TITLE_POSITION__ 374
-#define __GO_UI_TITLE_SCROLL__ 375
-#define __GO_UI_FRAME_BORDER_TYPE__ 376
-#define __GO_UI_SCROLLABLE__ 377
+#define __GO_UI_GRIDBAG_PREFERREDSIZE__ 354
+#define __GO_UI_GRID_GRID__ 355
+#define __GO_UI_GRID_PADDING__ 356
+#define __GO_UI_BORDER_POSITION__ 357
+#define __GO_GRID_OPT_GRID__ 358
+#define __GO_GRID_OPT_PADDING__ 359
+#define __GO_BORDER_OPT_PADDING__ 360
+#define __GO_UI_FRAME_BORDER__ 361
+#define __GO_UI_FRAME_BORDER_COLOR__ 362
+#define __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__ 363
+#define __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__ 364
+#define __GO_UI_FRAME_BORDER_IN_BORDER__ 365
+#define __GO_UI_FRAME_BORDER_JUSTIFICATION__ 366
+#define __GO_UI_FRAME_BORDER_OUT_BORDER__ 367
+#define __GO_UI_FRAME_BORDER_ROUNDED__ 368
+#define __GO_UI_FRAME_BORDER_SHADOW_IN__ 369
+#define __GO_UI_FRAME_BORDER_SHADOW_OUT__ 370
+#define __GO_UI_FRAME_BORDER_TITLE__ 371
+#define __GO_UI_FRAME_BORDER_POSITION__ 372
+#define __GO_UI_FRAME_BORDER_STYLE__ 373
+#define __GO_UI_GROUP_NAME__ 374
+#define __GO_UI_TITLE_POSITION__ 375
+#define __GO_UI_TITLE_SCROLL__ 376
+#define __GO_UI_FRAME_BORDER_TYPE__ 377
+#define __GO_UI_SCROLLABLE__ 378
 
 #endif /* !__GRAPHIC_OBJECT_PROPERTIES_H__ */
index 31e677a..fbbe346 100644 (file)
@@ -200,3 +200,13 @@ int xmlload(char* xmlfile)
 {
     return CallXmlLoader::Load(getScilabJavaVM(), xmlfile);
 }
+
+int xmldomload(char* xmlfile)
+{
+    return CallXmlLoader::DomLoad(getScilabJavaVM(), xmlfile);
+}
+
+char* xmlsave(int id, char* xmlfile)
+{
+    return CallXmlLoader::Save(getScilabJavaVM(), id, xmlfile);
+}
index 65037b3..170a6ae 100644 (file)
@@ -1,19 +1,23 @@
 package org.scilab.modules.graphic_objects;
 
+import org.scilab.modules.graphic_objects.xmlloader.XMLDomLoader;
 import org.scilab.modules.graphic_objects.xmlloader.XmlLoader;
+import org.scilab.modules.graphic_objects.xmlloader.XmlSaver;
 import org.xml.sax.SAXException;
 
 public class CallXmlLoader {
 
-    public static int Load(String xmlFile) {
-        XmlLoader loader = new XmlLoader(xmlFile);
-        try {
-            return loader.parse();
-        } catch (SAXException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
+    public static int Load(String filename) throws SAXException {
+        XmlLoader loader = new XmlLoader(filename);
+        return loader.parse();
+    }
+
+    public static int DomLoad(String filename) throws SAXException {
+        XMLDomLoader loader = new XMLDomLoader(filename);
+        return loader.parse();
+    }
 
-        return 0;
+    public static String Save(int figure, String filename) {
+        return XmlSaver.save(figure, filename);
     }
 }
index 1988499..39f7a99 100644 (file)
@@ -314,7 +314,7 @@ public final class Builder {
             }
         }
     }
-        
+
     public final static int createFigure(boolean dockable, int menubarType, int toolbarType, boolean defaultAxes, boolean visible) {
         GraphicController controller =  GraphicController.getController();
         Integer figModel = GraphicModel.getFigureModel().getIdentifier();
@@ -324,14 +324,15 @@ public final class Builder {
         figure.setMenubar(menubarType);
         figure.setToolbar(toolbarType);
         figure.setVisible(visible);
-        
+        figure.setDefaultAxes(defaultAxes);
+
         controller.objectCreated(figId);
         ScilabNativeView.ScilabNativeView__setCurrentFigure(figId);
-        
+
         if (menubarType == BarType.FIGURE.ordinal()) {
             cloneMenus(figModel, figId);
         }
-        
+
         if (defaultAxes) {
             //clone default axes
             cloneAxesModel(figId);
@@ -339,7 +340,7 @@ public final class Builder {
 
         return figId;
     }
-    
+
     public final static int createNewFigureWithAxes() {
         GraphicController controller = GraphicController.getController();
         Integer figModel  = GraphicModel.getFigureModel().getIdentifier();
index 052ef2c..d42fed6 100755 (executable)
@@ -374,29 +374,30 @@ public class GraphicObjectProperties {
     public static final int __GO_UI_GRIDBAG_FILL__ = 351;
     public static final int __GO_UI_GRIDBAG_ANCHOR__ = 352;
     public static final int __GO_UI_GRIDBAG_PADDING__ = 353;
-    public static final int __GO_UI_GRID_GRID__ = 354;
-    public static final int __GO_UI_GRID_PADDING__ = 355;
-    public static final int __GO_UI_BORDER_POSITION__ = 356;
-    public static final int __GO_GRID_OPT_GRID__ = 357;
-    public static final int __GO_GRID_OPT_PADDING__ = 358;
-    public static final int __GO_BORDER_OPT_PADDING__ = 359;
-    public static final int __GO_UI_FRAME_BORDER__ = 360;
-    public static final int __GO_UI_FRAME_BORDER_COLOR__ = 361;
-    public static final int __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__ = 362;
-    public static final int __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__ = 363;
-    public static final int __GO_UI_FRAME_BORDER_IN_BORDER__ = 364;
-    public static final int __GO_UI_FRAME_BORDER_JUSTIFICATION__ = 365;
-    public static final int __GO_UI_FRAME_BORDER_OUT_BORDER__ = 366;
-    public static final int __GO_UI_FRAME_BORDER_ROUNDED__ = 367;
-    public static final int __GO_UI_FRAME_BORDER_SHADOW_IN__ = 368;
-    public static final int __GO_UI_FRAME_BORDER_SHADOW_OUT__ = 369;
-    public static final int __GO_UI_FRAME_BORDER_TITLE__ = 370;
-    public static final int __GO_UI_FRAME_BORDER_POSITION__ = 371;
-    public static final int __GO_UI_FRAME_BORDER_STYLE__ = 372;
-    public static final int __GO_UI_GROUP_NAME__ = 373;
-    public static final int __GO_UI_TITLE_POSITION__ = 374;
-    public static final int __GO_UI_TITLE_SCROLL__ = 375;
-    public static final int __GO_UI_FRAME_BORDER_TYPE__ = 376;
-    public static final int __GO_UI_SCROLLABLE__ = 377;
+    public static final int __GO_UI_GRIDBAG_PREFERREDSIZE__ = 354;
+    public static final int __GO_UI_GRID_GRID__ = 355;
+    public static final int __GO_UI_GRID_PADDING__ = 356;
+    public static final int __GO_UI_BORDER_POSITION__ = 357;
+    public static final int __GO_GRID_OPT_GRID__ = 358;
+    public static final int __GO_GRID_OPT_PADDING__ = 359;
+    public static final int __GO_BORDER_OPT_PADDING__ = 360;
+    public static final int __GO_UI_FRAME_BORDER__ = 361;
+    public static final int __GO_UI_FRAME_BORDER_COLOR__ = 362;
+    public static final int __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__ = 363;
+    public static final int __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__ = 364;
+    public static final int __GO_UI_FRAME_BORDER_IN_BORDER__ = 365;
+    public static final int __GO_UI_FRAME_BORDER_JUSTIFICATION__ = 366;
+    public static final int __GO_UI_FRAME_BORDER_OUT_BORDER__ = 367;
+    public static final int __GO_UI_FRAME_BORDER_ROUNDED__ = 368;
+    public static final int __GO_UI_FRAME_BORDER_SHADOW_IN__ = 369;
+    public static final int __GO_UI_FRAME_BORDER_SHADOW_OUT__ = 370;
+    public static final int __GO_UI_FRAME_BORDER_TITLE__ = 371;
+    public static final int __GO_UI_FRAME_BORDER_POSITION__ = 372;
+    public static final int __GO_UI_FRAME_BORDER_STYLE__ = 373;
+    public static final int __GO_UI_GROUP_NAME__ = 374;
+    public static final int __GO_UI_TITLE_POSITION__ = 375;
+    public static final int __GO_UI_TITLE_SCROLL__ = 376;
+    public static final int __GO_UI_FRAME_BORDER_TYPE__ = 377;
+    public static final int __GO_UI_SCROLLABLE__ = 378;
 
 }
index 9930b71..dbbcf50 100644 (file)
@@ -2,6 +2,7 @@
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2011 - DIGITEO - Bruno JOFRET
  * Copyright (C) 2011 - DIGITEO - Vincent COUVERT
+ * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -39,9 +40,11 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_FILL__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_GRID__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_PADDING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_PREFERREDSIZE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_WEIGHT__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GROUP_NAME__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_HORIZONTALALIGNMENT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_ICON__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_IMAGE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LAYER__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LISTBOXTOP_SIZE__;
@@ -70,7 +73,6 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_VALUE_SIZE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_VALUE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_VERTICALALIGNMENT__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_ICON__;
 
 import java.awt.Font;
 import java.util.Arrays;
@@ -312,6 +314,7 @@ public class Uicontrol extends GraphicObject {
     private FillType gridbagFill = FillType.NONE;
     private AnchorType gridbagAnchor = AnchorType.CENTER;
     private Integer[] gridbagPadding = new Integer[] {0, 0};
+    private Integer[] gridbagPreferredSize = new Integer[] { -1, -1};
     private BorderLayoutType borderPosition = BorderLayoutType.CENTER;
     private String icon = "";
 
@@ -371,6 +374,7 @@ public class Uicontrol extends GraphicObject {
         GRIDBAG_FILL,
         GRIDBAG_ANCHOR,
         GRIDBAG_PADDING,
+        GRIDBAG_PREFERREDSIZE,
         BORDER_POSITION,
         GRIDOPT_GRID,
         GRIDOPT_PADDING,
@@ -386,7 +390,7 @@ public class Uicontrol extends GraphicObject {
     /**
      * All uicontrol styles
      */
-    private enum UicontrolStyle {
+    public enum UicontrolStyle {
         CHECKBOX,
         EDIT,
         FRAME,
@@ -587,6 +591,8 @@ public class Uicontrol extends GraphicObject {
                 return UicontrolProperty.GRIDBAG_ANCHOR;
             case __GO_UI_GRIDBAG_PADDING__:
                 return UicontrolProperty.GRIDBAG_PADDING;
+            case __GO_UI_GRIDBAG_PREFERREDSIZE__:
+                return UicontrolProperty.GRIDBAG_PREFERREDSIZE;
             case __GO_UI_BORDER_POSITION__:
                 return UicontrolProperty.BORDER_POSITION;
             case __GO_GRID_OPT_GRID__:
@@ -686,6 +692,8 @@ public class Uicontrol extends GraphicObject {
             return getGridBagAnchor();
         } else if (property == UicontrolProperty.GRIDBAG_PADDING) {
             return getGridBagPadding();
+        } else if (property == UicontrolProperty.GRIDBAG_PREFERREDSIZE) {
+            return getGridBagPreferredSize();
         } else if (property == UicontrolProperty.BORDER_POSITION) {
             return getBorderPosition();
         } else if (property == UicontrolProperty.GRIDOPT_GRID) {
@@ -782,6 +790,8 @@ public class Uicontrol extends GraphicObject {
                 return setGridBagAnchor((Integer) value);
             case GRIDBAG_PADDING:
                 return setGridBagPadding((Integer[]) value);
+            case GRIDBAG_PREFERREDSIZE:
+                return setGridBagPreferredSize((Integer[]) value);
             case BORDER_POSITION:
                 return setBorderPosition((Integer) value);
             case GRIDOPT_GRID:
@@ -812,7 +822,11 @@ public class Uicontrol extends GraphicObject {
          * @return the style
          */
     public Integer getStyle() {
-        return styleEnumToInt(this.style);
+        return styleEnumToInt(style);
+    }
+
+    public UicontrolStyle getStyleAsEnum() {
+        return style;
     }
 
     /**
@@ -1233,6 +1247,26 @@ public class Uicontrol extends GraphicObject {
         return status;
     }
 
+    public Integer[] getGridBagPreferredSize() {
+        return gridbagPreferredSize;
+    }
+
+    public UpdateStatus setGridBagPreferredSize(Integer[] value) {
+        UpdateStatus status = UpdateStatus.NoChange;
+        if (gridbagPreferredSize.length != value.length) {
+            return UpdateStatus.Fail;
+        }
+
+        for (int i = 0 ; i < value.length ; i++) {
+            if (gridbagPreferredSize[i] != value[i]) {
+                gridbagPreferredSize[i] = value[i];
+                status = UpdateStatus.Success;
+            }
+        }
+
+        return status;
+    }
+
     public Integer getGridBagAnchor() {
         return gridbagAnchor.ordinal();
     }
index abe9a62..e03894d 100644 (file)
@@ -18,6 +18,7 @@ import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 
 import org.scilab.modules.graphic_objects.uicontrol.Uicontrol;
+import org.scilab.modules.graphic_objects.utils.LayoutType;
 
 /**
  * @author Vincent COUVERT
@@ -40,5 +41,8 @@ public class Layer extends Uicontrol {
 
         //v-alignement
         setVerticalAlignment("middle");
+
+        //layout
+        setLayout(LayoutType.BORDER);
     }
 }
index 5b3b5fa..f5ac9df 100644 (file)
@@ -19,6 +19,7 @@ import javax.swing.UIManager;
 
 import org.scilab.modules.graphic_objects.console.Console;
 import org.scilab.modules.graphic_objects.uicontrol.Uicontrol;
+import org.scilab.modules.graphic_objects.utils.LayoutType;
 
 /**
  * @author Vincent COUVERT
@@ -44,6 +45,9 @@ public class Tab extends Uicontrol {
 
             //v-alignement
             setVerticalAlignment("middle");
+
+            //layout
+            setLayout(LayoutType.BORDER);
         }
     }
 
index e1b1f0a..75010f9 100644 (file)
@@ -1,7 +1,9 @@
 package org.scilab.modules.graphic_objects.xmlloader;
 
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BORDER_OPT_PADDING__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DOCKABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CALLBACK__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CALLBACKTYPE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BORDER_OPT_PADDING__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_GRID__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_PADDING__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_INFOBAR_VISIBLE__;
@@ -45,19 +47,25 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_FILL__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_GRID__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_PADDING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_PREFERREDSIZE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_WEIGHT__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_HORIZONTALALIGNMENT__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_ICON__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_MAX__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_MIN__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_PUSHBUTTON__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SCROLLABLE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_STRING__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TAB__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TEXT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_EDIT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_POPUPMENU__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LISTBOX__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_RADIOBUTTON__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GROUP_NAME__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_VISIBLE__;
 
 import java.awt.Color;
-import java.io.File;
 import java.lang.reflect.Field;
 import java.util.Map;
 
@@ -262,11 +270,20 @@ public class GOBuilder {
                         padding[0] = Integer.parseInt(XmlTools.getFromMap(map, "ipadx", "0"));
                         padding[1] = Integer.parseInt(XmlTools.getFromMap(map, "ipady", "0"));
 
+                        Integer[] preferredsize = new Integer[] { -1, -1};
+                        item = attributes.getValue("preferred-size");
+                        if (item != null) {
+                            String[] pref = item.split(",");
+                            for (int i = 0; i < pref.length && i < 4; i++) {
+                                preferredsize[i] = Integer.parseInt(pref[i]);
+                            }
+                        }
                         controller.setProperty(uic, __GO_UI_GRIDBAG_GRID__, grid);
                         controller.setProperty(uic, __GO_UI_GRIDBAG_WEIGHT__, weight);
                         controller.setProperty(uic, __GO_UI_GRIDBAG_FILL__, fill);
                         controller.setProperty(uic, __GO_UI_GRIDBAG_ANCHOR__, anchor);
                         controller.setProperty(uic, __GO_UI_GRIDBAG_PADDING__, padding);
+                        controller.setProperty(uic, __GO_UI_GRIDBAG_PREFERREDSIZE__, preferredsize);
                         break;
                     }
                     default:
@@ -276,9 +293,9 @@ public class GOBuilder {
                 // insets -> marging
                 String insets = XmlTools.getFromMap(map, "insets", "0,0,0,0");
                 Double[] margins = new Double[] { 0.0, 0.0, 0.0, 0.0 };
-                String[] insert = insets.split(",");
-                for (int i = 0; i < insert.length && i < 4; i++) {
-                    margins[i] = Double.parseDouble(insert[i]);
+                String[] inset = insets.split(",");
+                for (int i = 0; i < inset.length && i < 4; i++) {
+                    margins[i] = Double.parseDouble(inset[i]);
                 }
 
                 controller.setProperty(uic, __GO_MARGINS__, margins);
@@ -337,13 +354,47 @@ public class GOBuilder {
                     break;
                 }
                 case __GO_UI_CHECKBOX__: {
-                    controller.setProperty(uic, __GO_UI_HORIZONTALALIGNMENT__, "left");
+                    String[] text = new String[1];
+                    text[0] = attributes.getValue("text");
+                    if (text[0] != null) {
+                        controller.setProperty(uic, __GO_UI_STRING__, text);
+                    }
+
+                    //callback
+                    item = attributes.getValue("onclick");
+                    if (item != null && item.equals("") == false) {
+                        controller.setProperty(uic, __GO_CALLBACK__, item);
+                        controller.setProperty(uic, __GO_CALLBACKTYPE__, 0);
+                    }
+
+                    //groupname
+                    item = attributes.getValue("button-group");
+                    if (item != null && item.equals("") == false) {
+                        controller.setProperty(uic, __GO_UI_GROUP_NAME__, item);
+                    }
 
+                    break;
+                }
+                case __GO_UI_RADIOBUTTON__: {
                     String[] text = new String[1];
                     text[0] = attributes.getValue("text");
                     if (text[0] != null) {
                         controller.setProperty(uic, __GO_UI_STRING__, text);
                     }
+
+                    //callback
+                    item = attributes.getValue("onclick");
+                    if (item != null && item.equals("") == false) {
+                        controller.setProperty(uic, __GO_CALLBACK__, item);
+                        controller.setProperty(uic, __GO_CALLBACKTYPE__, 0);
+                    }
+
+                    //groupname
+                    item = attributes.getValue("button-group");
+                    if (item != null && item.equals("") == false) {
+                        controller.setProperty(uic, __GO_UI_GROUP_NAME__, item);
+                    }
+
                     break;
                 }
                 case __GO_UI_PUSHBUTTON__: {
@@ -362,9 +413,16 @@ public class GOBuilder {
                         controller.setProperty(uic, __GO_UI_ICON__, item);
                     }
 
+                    //callback
+                    item = attributes.getValue("onclick");
+                    if (item != null && item.equals("") == false) {
+                        controller.setProperty(uic, __GO_CALLBACK__, item);
+                        controller.setProperty(uic, __GO_CALLBACKTYPE__, 0);
+                    }
+
                     break;
                 }
-                case __GO_UI_TEXT__:
+                case __GO_UI_TEXT__: { //label
                     controller.setProperty(uic, __GO_UI_HORIZONTALALIGNMENT__, "left");
                     String[] text = new String[1];
                     text[0] = attributes.getValue("text");
@@ -372,17 +430,55 @@ public class GOBuilder {
                         controller.setProperty(uic, __GO_UI_STRING__, text);
                     }
 
-                    String columns = attributes.getValue("columns");
-                    if (columns != null) {
-                        controller.setProperty(uic, __GO_UI_MAX__, Double.parseDouble(columns));
-                    }
-
                     //icon
                     item = attributes.getValue("icon");
                     if (item != null) {
                         controller.setProperty(uic, __GO_UI_ICON__, item);
                     }
+
+                    break;
+                }
+                case __GO_UI_EDIT__ : {
+                    //callback
+                    item = attributes.getValue("onenter");
+                    if (item != null && item.equals("") == false) {
+                        controller.setProperty(uic, __GO_CALLBACK__, item);
+                        controller.setProperty(uic, __GO_CALLBACKTYPE__, 0);
+                    }
+
+                    item = attributes.getValue("columns");
+                    if (item != null) {
+                        controller.setProperty(uic, __GO_UI_MAX__, Double.parseDouble(item));
+                    }
+
+                    break;
+                }
+                case __GO_UI_POPUPMENU__ : {
+                    //callback
+                    item = attributes.getValue("onchange");
+                    if (item != null && item.equals("") == false) {
+                        controller.setProperty(uic, __GO_CALLBACK__, item);
+                        controller.setProperty(uic, __GO_CALLBACKTYPE__, 0);
+                    }
+
                     break;
+                }
+                case __GO_UI_LISTBOX__ : {
+                    //callback
+                    item = attributes.getValue("onclick");
+                    if (item != null && item.equals("") == false) {
+                        controller.setProperty(uic, __GO_CALLBACK__, item);
+                        controller.setProperty(uic, __GO_CALLBACKTYPE__, 0);
+                    }
+
+                    item = attributes.getValue("multiple");
+                    if (item != null && item.equals("true")) {
+                        controller.setProperty(uic, __GO_UI_MIN__, 0.0);
+                        controller.setProperty(uic, __GO_UI_MAX__, 2.0);
+                    }
+
+                    break;
+                }
             }
 
         } catch (CSSParserException e) {
@@ -507,8 +603,6 @@ public class GOBuilder {
             }
             case TITLED: {
 
-                FrameBorderType borderOut = FrameBorderType.stringToEnum(XmlTools.getFromMap(map, "border", "none"));
-                Integer out = createBorder(controller, border, borderOut, map);
                 String title = XmlTools.getFromMap(map, "title", "");
                 FrameBorder.JustificationType justify = FrameBorder.JustificationType.stringToEnum(XmlTools.getFromMap(map, "justify", "leading"));
                 String fontName = XmlTools.getFromMap(map, "font-name", "");
@@ -520,7 +614,8 @@ public class GOBuilder {
 
                 String color = XmlTools.getFromMap(map, "color", "black");
 
-                controller.setProperty(border, __GO_UI_FRAME_BORDER_OUT_BORDER__, out);
+                FrameBorderType borderOut = FrameBorderType.stringToEnum(XmlTools.getFromMap(map, "border", "none"));
+                Integer out = createBorder(controller, border, borderOut, map);
 
                 controller.setProperty(border, __GO_UI_FRAME_BORDER_TITLE__, out);
                 controller.setProperty(border, __GO_TITLE__, title);
diff --git a/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/Pair.java b/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/Pair.java
new file mode 100644 (file)
index 0000000..b346191
--- /dev/null
@@ -0,0 +1,62 @@
+package org.scilab.modules.graphic_objects.xmlloader;
+
+
+public class Pair<First, Second> {
+    private First first;
+    private Second second;
+
+    public Pair(First first, Second second) {
+        this.first = first;
+        this.second = second;
+    }
+
+    public void setFirst(First first) {
+        this.first = first;
+    }
+
+    public void setSecond(Second second) {
+        this.second = second;
+    }
+
+    public First getFirst() {
+        return first;
+    }
+
+    public Second getSecond() {
+        return second;
+    }
+
+    public void set(First first, Second second) {
+        setFirst(first);
+        setSecond(second);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        Pair <? , ? > pair = (Pair <? , ? >) o;
+
+        if (first != null ? !first.equals(pair.first) : pair.first != null) {
+            return false;
+        }
+        if (second != null ? !second.equals(pair.second) : pair.second != null) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = first != null ? first.hashCode() : 0;
+        result = 31 * result + (second != null ? second.hashCode() : 0);
+        return result;
+    }
+
+}
diff --git a/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XMLDomLoader.java b/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XMLDomLoader.java
new file mode 100644 (file)
index 0000000..40200ce
--- /dev/null
@@ -0,0 +1,733 @@
+package org.scilab.modules.graphic_objects.xmlloader;
+
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_ANTIALIASING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AUTORESIZE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXES_SIZE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BACKGROUND__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BORDER_OPT_PADDING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CALLBACKTYPE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CALLBACK__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CLOSEREQUESTFCN__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DEFAULT_AXES__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DOCKABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_EVENTHANDLER_ENABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_EVENTHANDLER_NAME__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_FIGURE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_GRID__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_PADDING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_ID__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_IMMEDIATE_DRAWING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_INFOBAR_VISIBLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_INFO_MESSAGE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LAYOUT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LINE_THICKNESS__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_MARGINS__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_MENUBAR_VISIBLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_MENUBAR__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_NAME__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_PIXEL_DRAWING_MODE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_POSITION__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_RESIZEFCN__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_RESIZE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_ROTATION_TYPE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_SIZE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TAG__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TITLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TOOLBAR_VISIBLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TOOLBAR__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UICONTEXTMENU__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UIMENU__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_BACKGROUNDCOLOR__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_BORDER_POSITION__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_CHECKBOX__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_EDIT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_ENABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTANGLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTNAME__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTSIZE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTUNITS__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTWEIGHT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FOREGROUNDCOLOR__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_COLOR__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_HIGHLIGHT_IN__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_IN_BORDER__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_JUSTIFICATION__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_OUT_BORDER__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_POSITION__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_ROUNDED__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_SHADOW_IN__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_SHADOW_OUT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_STYLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_TITLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_TYPE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_SCROLLABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_ANCHOR__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_FILL__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_GRID__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_PADDING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_PREFERREDSIZE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_WEIGHT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GROUP_NAME__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_HORIZONTALALIGNMENT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_ICON__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_IMAGE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LAYER__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LISTBOXTOP__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LISTBOX__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_MAX__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_MIN__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_POPUPMENU__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_PUSHBUTTON__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_RADIOBUTTON__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_RELIEF__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SCROLLABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SLIDERSTEP__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SLIDER__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_STRING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TAB__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TEXT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TOOLTIPSTRING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_UNITS__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_VALUE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_VERTICALALIGNMENT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_USEDEPRECATEDLF__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_VIEWPORT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_VISIBLE__;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.scilab.modules.commons.gui.FindIconHelper;
+import org.scilab.modules.graphic_objects.builder.Builder;
+import org.scilab.modules.graphic_objects.console.Console;
+import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+import org.scilab.modules.graphic_objects.graphicObject.GraphicObject;
+import org.scilab.modules.graphic_objects.uicontrol.frame.border.FrameBorderType;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class XMLDomLoader {
+
+    private enum ModelType {
+        BOOLEAN, BOOLEAN_ARRAY, DOUBLE, DOUBLE_ARRAY, STRING, STRING_ARRAY, INTEGER, INTEGER_ARRAY;
+    };
+
+    private static final int __NODE_SCILABGUI__ = -10;
+    private static final int __NODE_OUT__       = -20;
+    private static final int __NODE_IN__        = -30;
+    private static final int __NODE_TITLE__     = -40;
+
+    private static HashMap<String, Integer> nameToGO = new HashMap<String, Integer>();
+
+    private static HashMap<String, Pair<Integer, ModelType>> figPropToGO = new HashMap<String, Pair<Integer, ModelType>>();
+    private static HashMap<String, Pair<Integer, ModelType>> UiPropToGO = new HashMap<String, Pair<Integer, ModelType>>();
+    private static HashMap<String, Pair<Integer, ModelType>> BorderPropToGO = new HashMap<String, Pair<Integer, ModelType>>();
+
+
+    static {
+        // init map to convert control name to id
+        nameToGO.put("figure", __GO_FIGURE__);
+        nameToGO.put("frame", __GO_UI_FRAME__);
+        nameToGO.put("layer", __GO_UI_LAYER__);
+        nameToGO.put("pushbutton", __GO_UI_PUSHBUTTON__);
+        nameToGO.put("text", __GO_UI_TEXT__);
+        nameToGO.put("checkbox", __GO_UI_CHECKBOX__);
+        nameToGO.put("textfield", __GO_UI_EDIT__);
+        nameToGO.put("edit", __GO_UI_EDIT__);
+        nameToGO.put("image", __GO_UI_IMAGE__);
+        nameToGO.put("picture", __GO_UI_IMAGE__);
+        nameToGO.put("listbox", __GO_UI_LISTBOX__);
+        nameToGO.put("popupmenu", __GO_UI_POPUPMENU__);
+        nameToGO.put("radiobutton", __GO_UI_RADIOBUTTON__);
+        nameToGO.put("slider", __GO_UI_SLIDER__);
+        nameToGO.put("table", __GO_UI_TABLE__);
+        nameToGO.put("tab", __GO_UI_TAB__);
+
+        nameToGO.put("menu", __GO_UIMENU__);
+        nameToGO.put("contextmenu", __GO_UICONTEXTMENU__);
+
+        nameToGO.put("borders", __GO_UI_FRAME_BORDER__);
+        nameToGO.put("out", __NODE_OUT__);
+        nameToGO.put("in", __NODE_IN__);
+        nameToGO.put("title", __NODE_TITLE__);
+
+        /* system */
+        nameToGO.put("scilabgui", __NODE_SCILABGUI__);
+
+        //fill map of property -> {GO, ModelType}
+
+        //figure property list
+        figPropToGO.put("figure_position", new Pair<Integer, ModelType>(__GO_POSITION__, ModelType.INTEGER_ARRAY));
+        figPropToGO.put("figure_size", new Pair<Integer, ModelType>(__GO_SIZE__, ModelType.INTEGER_ARRAY));
+        figPropToGO.put("axes_size", new Pair<Integer, ModelType>(__GO_AXES_SIZE__, ModelType.INTEGER_ARRAY));
+        figPropToGO.put("auto_resize", new Pair<Integer, ModelType>(__GO_AUTORESIZE__, ModelType.BOOLEAN));
+        figPropToGO.put("view_port", new Pair<Integer, ModelType>(__GO_VIEWPORT__, ModelType.INTEGER_ARRAY));
+        figPropToGO.put("figure_name", new Pair<Integer, ModelType>(__GO_NAME__, ModelType.STRING));
+        figPropToGO.put("figure_id", new Pair<Integer, ModelType>(__GO_ID__, ModelType.INTEGER));
+        figPropToGO.put("info_message", new Pair<Integer, ModelType>(__GO_INFO_MESSAGE__, ModelType.STRING));
+        figPropToGO.put("pixel_drawing_mode", new Pair<Integer, ModelType>(__GO_PIXEL_DRAWING_MODE__, ModelType.STRING));
+        figPropToGO.put("anti_aliasing", new Pair<Integer, ModelType>(__GO_ANTIALIASING__, ModelType.BOOLEAN));
+        figPropToGO.put("immediate_drawing", new Pair<Integer, ModelType>(__GO_IMMEDIATE_DRAWING__, ModelType.BOOLEAN));
+        figPropToGO.put("background", new Pair<Integer, ModelType>(__GO_BACKGROUND__, ModelType.INTEGER));
+        figPropToGO.put("visible", new Pair<Integer, ModelType>(__GO_VISIBLE__, ModelType.BOOLEAN));
+        figPropToGO.put("rotation_style", new Pair<Integer, ModelType>(__GO_ROTATION_TYPE__, ModelType.STRING));
+        figPropToGO.put("event_handler", new Pair<Integer, ModelType>(__GO_EVENTHANDLER_NAME__, ModelType.STRING));
+        figPropToGO.put("event_handler_enable", new Pair<Integer, ModelType>(__GO_EVENTHANDLER_ENABLE__, ModelType.BOOLEAN));
+        figPropToGO.put("resizefcn", new Pair<Integer, ModelType>(__GO_RESIZEFCN__, ModelType.STRING));
+        figPropToGO.put("closerequestfcn", new Pair<Integer, ModelType>(__GO_CLOSEREQUESTFCN__, ModelType.STRING));
+        figPropToGO.put("resize", new Pair<Integer, ModelType>(__GO_RESIZE__, ModelType.BOOLEAN));
+        figPropToGO.put("toolbar", new Pair<Integer, ModelType>(__GO_TOOLBAR__, ModelType.INTEGER));
+        figPropToGO.put("toolbar_visible", new Pair<Integer, ModelType>(__GO_TOOLBAR_VISIBLE__, ModelType.BOOLEAN));
+        figPropToGO.put("menubar", new Pair<Integer, ModelType>(__GO_MENUBAR__, ModelType.INTEGER));
+        figPropToGO.put("menubar_visible", new Pair<Integer, ModelType>(__GO_MENUBAR_VISIBLE__, ModelType.BOOLEAN));
+        figPropToGO.put("infobar_visible", new Pair<Integer, ModelType>(__GO_INFOBAR_VISIBLE__, ModelType.BOOLEAN));
+        figPropToGO.put("dockable", new Pair<Integer, ModelType>(__GO_DOCKABLE__, ModelType.BOOLEAN));
+        figPropToGO.put("layout", new Pair<Integer, ModelType>(__GO_LAYOUT__, ModelType.INTEGER));
+        figPropToGO.put("default_axes", new Pair<Integer, ModelType>(__GO_DEFAULT_AXES__, ModelType.BOOLEAN));
+        figPropToGO.put("icon", new Pair<Integer, ModelType>(__GO_UI_ICON__, ModelType.STRING));
+        figPropToGO.put("tag", new Pair<Integer, ModelType>(__GO_TAG__, ModelType.STRING));
+        figPropToGO.put("grid_opt_grid", new Pair<Integer, ModelType>(__GO_GRID_OPT_GRID__, ModelType.INTEGER_ARRAY));
+        figPropToGO.put("grid_opt_padding", new Pair<Integer, ModelType>(__GO_GRID_OPT_PADDING__, ModelType.INTEGER_ARRAY));
+        figPropToGO.put("border_opt_padding", new Pair<Integer, ModelType>(__GO_BORDER_OPT_PADDING__, ModelType.INTEGER_ARRAY));
+
+        //uicontrol property list
+        UiPropToGO.put("position", new Pair<Integer, ModelType>(__GO_POSITION__, ModelType.INTEGER));
+        UiPropToGO.put("backgroundcolor", new Pair<Integer, ModelType>(__GO_UI_BACKGROUNDCOLOR__, ModelType.INTEGER_ARRAY));
+        UiPropToGO.put("enable", new Pair<Integer, ModelType>(__GO_UI_ENABLE__, ModelType.BOOLEAN));
+        UiPropToGO.put("fontangle", new Pair<Integer, ModelType>(__GO_UI_FONTANGLE__, ModelType.STRING));
+        UiPropToGO.put("fontname", new Pair<Integer, ModelType>(__GO_UI_FONTNAME__, ModelType.STRING));
+        UiPropToGO.put("fontsize", new Pair<Integer, ModelType>(__GO_UI_FONTSIZE__, ModelType.DOUBLE));
+        UiPropToGO.put("fontunits", new Pair<Integer, ModelType>(__GO_UI_FONTUNITS__, ModelType.STRING));
+        UiPropToGO.put("fontweight", new Pair<Integer, ModelType>(__GO_UI_FONTWEIGHT__, ModelType.STRING));
+        UiPropToGO.put("foregroundcolor", new Pair<Integer, ModelType>(__GO_UI_FOREGROUNDCOLOR__, ModelType.INTEGER_ARRAY));
+        UiPropToGO.put("horizontalalignment", new Pair<Integer, ModelType>(__GO_UI_HORIZONTALALIGNMENT__, ModelType.STRING));
+        UiPropToGO.put("listboxtop", new Pair<Integer, ModelType>(__GO_UI_LISTBOXTOP__, ModelType.INTEGER_ARRAY));
+        UiPropToGO.put("max", new Pair<Integer, ModelType>(__GO_UI_MAX__, ModelType.DOUBLE));
+        UiPropToGO.put("min", new Pair<Integer, ModelType>(__GO_UI_MIN__, ModelType.DOUBLE));
+        UiPropToGO.put("position", new Pair<Integer, ModelType>(__GO_POSITION__, ModelType.DOUBLE_ARRAY));
+        UiPropToGO.put("relief", new Pair<Integer, ModelType>(__GO_UI_RELIEF__, ModelType.STRING));
+        UiPropToGO.put("sliderstep", new Pair<Integer, ModelType>(__GO_UI_SLIDERSTEP__, ModelType.DOUBLE_ARRAY));
+        UiPropToGO.put("string", new Pair<Integer, ModelType>(__GO_UI_STRING__, ModelType.STRING_ARRAY));
+        UiPropToGO.put("tooltipstring", new Pair<Integer, ModelType>(__GO_UI_TOOLTIPSTRING__, ModelType.STRING_ARRAY));
+        UiPropToGO.put("units", new Pair<Integer, ModelType>(__GO_UI_UNITS__, ModelType.STRING));
+        UiPropToGO.put("value", new Pair<Integer, ModelType>(__GO_UI_VALUE__, ModelType.DOUBLE_ARRAY));
+        UiPropToGO.put("verticalalignment", new Pair<Integer, ModelType>(__GO_UI_VERTICALALIGNMENT__, ModelType.STRING));
+        UiPropToGO.put("visible", new Pair<Integer, ModelType>(__GO_VISIBLE__, ModelType.BOOLEAN));
+        UiPropToGO.put("layout", new Pair<Integer, ModelType>(__GO_LAYOUT__, ModelType.INTEGER));
+        UiPropToGO.put("callback", new Pair<Integer, ModelType>(__GO_CALLBACK__, ModelType.STRING));
+        UiPropToGO.put("callback_type", new Pair<Integer, ModelType>(__GO_CALLBACKTYPE__, ModelType.INTEGER));
+        UiPropToGO.put("gridbaggrid", new Pair<Integer, ModelType>(__GO_UI_GRIDBAG_GRID__, ModelType.INTEGER_ARRAY));
+        UiPropToGO.put("gridbagweight", new Pair<Integer, ModelType>(__GO_UI_GRIDBAG_WEIGHT__, ModelType.DOUBLE_ARRAY));
+        UiPropToGO.put("gridbagfill", new Pair<Integer, ModelType>(__GO_UI_GRIDBAG_FILL__, ModelType.INTEGER));
+        UiPropToGO.put("gridbaganchor", new Pair<Integer, ModelType>(__GO_UI_GRIDBAG_ANCHOR__, ModelType.INTEGER));
+        UiPropToGO.put("gridbagpadding", new Pair<Integer, ModelType>(__GO_UI_GRIDBAG_PADDING__, ModelType.INTEGER_ARRAY));
+        UiPropToGO.put("gridbagpreferredsize", new Pair<Integer, ModelType>(__GO_UI_GRIDBAG_PREFERREDSIZE__, ModelType.INTEGER_ARRAY));
+        UiPropToGO.put("borderposition", new Pair<Integer, ModelType>(__GO_UI_BORDER_POSITION__, ModelType.INTEGER));
+        UiPropToGO.put("margins", new Pair<Integer, ModelType>(__GO_MARGINS__, ModelType.DOUBLE_ARRAY));
+        UiPropToGO.put("groupname", new Pair<Integer, ModelType>(__GO_UI_GROUP_NAME__, ModelType.STRING));
+        UiPropToGO.put("icon", new Pair<Integer, ModelType>(__GO_UI_ICON__, ModelType.STRING));
+        UiPropToGO.put("scrollable", new Pair<Integer, ModelType>(__GO_UI_SCROLLABLE__, ModelType.BOOLEAN));
+        UiPropToGO.put("gridoptgrid", new Pair<Integer, ModelType>(__GO_GRID_OPT_GRID__, ModelType.INTEGER_ARRAY));
+        UiPropToGO.put("gridoptpadding", new Pair<Integer, ModelType>(__GO_GRID_OPT_PADDING__, ModelType.INTEGER_ARRAY));
+        UiPropToGO.put("borderoptpadding", new Pair<Integer, ModelType>(__GO_BORDER_OPT_PADDING__, ModelType.INTEGER_ARRAY));
+        UiPropToGO.put("tag", new Pair<Integer, ModelType>(__GO_TAG__, ModelType.STRING));
+
+        //border property list
+        BorderPropToGO.put("style", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_STYLE__, ModelType.INTEGER));
+        BorderPropToGO.put("type", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_TYPE__, ModelType.INTEGER));
+        BorderPropToGO.put("position", new Pair<Integer, ModelType>(__GO_POSITION__, ModelType.DOUBLE_ARRAY));
+        BorderPropToGO.put("hlout", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, ModelType.STRING));
+        BorderPropToGO.put("hlin", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_HIGHLIGHT_IN__, ModelType.STRING));
+        BorderPropToGO.put("shadowout", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_SHADOW_OUT__, ModelType.STRING));
+        BorderPropToGO.put("shadowin", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_SHADOW_IN__, ModelType.STRING));
+        BorderPropToGO.put("titleposition", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_POSITION__, ModelType.DOUBLE_ARRAY));
+        BorderPropToGO.put("hl", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, ModelType.STRING));
+        BorderPropToGO.put("shadow", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_SHADOW_OUT__, ModelType.STRING));
+        BorderPropToGO.put("color", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_COLOR__, ModelType.STRING));
+        BorderPropToGO.put("thickness", new Pair<Integer, ModelType>(__GO_LINE_THICKNESS__, ModelType.INTEGER));
+        BorderPropToGO.put("rounded", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_ROUNDED__, ModelType.BOOLEAN));
+        BorderPropToGO.put("title", new Pair<Integer, ModelType>(__GO_TITLE__, ModelType.STRING));
+        BorderPropToGO.put("justification", new Pair<Integer, ModelType>(__GO_UI_FRAME_BORDER_JUSTIFICATION__, ModelType.INTEGER));
+        BorderPropToGO.put("fontangle", new Pair<Integer, ModelType>(__GO_UI_FONTANGLE__, ModelType.STRING));
+        BorderPropToGO.put("fontname", new Pair<Integer, ModelType>(__GO_UI_FONTNAME__, ModelType.STRING));
+        BorderPropToGO.put("fontsize", new Pair<Integer, ModelType>(__GO_UI_FONTSIZE__, ModelType.INTEGER));
+        BorderPropToGO.put("fontweight", new Pair<Integer, ModelType>(__GO_UI_FONTWEIGHT__, ModelType.STRING));
+    }
+
+    private String filename = "";
+    private Integer figure = 0;
+    private Boolean figVisible = true;
+
+    public XMLDomLoader(String filename) {
+        this.filename = filename;
+    }
+
+    public int parse() {
+        return parse(filename);
+    }
+
+    public int parse(String filename) {
+        try {
+            this.filename = filename;
+            File file = new File(filename);
+
+            if (file.exists()) {
+                //add filename filepath in FindIconHelper paths
+                String absoluteFilePath = file.getAbsolutePath();
+                String path = absoluteFilePath.substring(0, absoluteFilePath.lastIndexOf(File.separator));
+                FindIconHelper.addThemePath(path);
+            } else {
+                return 1;
+            }
+
+            DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+            Document doc = dBuilder.parse(file);
+            doc.getDocumentElement().normalize();
+
+            if (doc.hasChildNodes()) {
+                parseNode(0, doc.getChildNodes());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        //update visible property of main window
+        GraphicController.getController().setProperty(figure, __GO_VISIBLE__, figVisible);
+        return figure;
+    }
+
+    private void parseNode(Integer parent, NodeList nodes) {
+        for (int i = nodes.getLength() - 1 ; i >= 0;  i--) {
+            Node childNode = nodes.item(i);
+            Integer child = 0;
+            boolean makeRelationShip = true;
+
+            // make sure it's element node.
+            if (childNode.getNodeType() == Node.ELEMENT_NODE) {
+                // get node name and value
+                int nodeType = nameToGO.get(childNode.getNodeName());
+                switch (nodeType) {
+                    case __GO_FIGURE__: {
+                        child = createFigure(childNode);
+                        figure = child;
+                        break;
+                    }
+
+                    case __GO_UI_CHECKBOX__:
+                    case __GO_UI_EDIT__:
+                    case __GO_UI_FRAME__:
+                    case __GO_UI_IMAGE__:
+                    case __GO_UI_LAYER__:
+                    case __GO_UI_LISTBOX__:
+                    case __GO_UI_POPUPMENU__:
+                    case __GO_UI_PUSHBUTTON__:
+                    case __GO_UI_RADIOBUTTON__:
+                    case __GO_UI_SLIDER__:
+                    case __GO_UI_TABLE__:
+                    case __GO_UI_TAB__:
+                    case __GO_UI_TEXT__: {
+                        child = createUiControl(nodeType, parent, childNode);
+                        break;
+                    }
+
+                    case __GO_UI_FRAME_BORDER__: {
+                        makeRelationShip = false;
+                        child = createBorder(childNode);
+                        GraphicController.getController().setProperty(parent, __GO_UI_FRAME_BORDER__, child);
+                        break;
+                    }
+
+                    case __NODE_OUT__: {
+                        makeRelationShip = false;
+                        //                        child = createBorder(childNode);
+                        //                        GraphicController.getController().setProperty(parent, __GO_UI_FRAME_BORDER_OUT_BORDER__, child);
+                        break;
+                    }
+
+                    case __NODE_IN__: {
+                        makeRelationShip = false;
+                        //                        child = createBorder(childNode);
+                        //                        GraphicController.getController().setProperty(parent, __GO_UI_FRAME_BORDER_IN_BORDER__, child);
+                        break;
+                    }
+
+                    case __NODE_TITLE__: {
+                        makeRelationShip = false;
+                        //                        child = createBorder(childNode);
+                        //                        GraphicController.getController().setProperty(parent, __GO_UI_FRAME_BORDER_TITLE__, child);
+                        break;
+                    }
+
+                    case __NODE_SCILABGUI__ : {
+                        //check version
+                        Node nodeVersion = childNode.getAttributes().getNamedItem("version");
+                        double version = Double.parseDouble(nodeVersion.getNodeValue());
+                        if (version > 1.0) {
+                            //call version manager ^^
+                        }
+
+                        Integer console = Console.getConsole().getIdentifier();
+                        //set usedeprecatedskin flag
+                        setBooleanAttribute(console, __GO_USEDEPRECATEDLF__, childNode.getAttributes(), "usedeprecatedskin");
+                        break;
+                    }
+
+                    case __GO_UICONTEXTMENU__:
+                    case __GO_UIMENU__: {
+                        break;
+                    }
+
+
+                    default: {
+                        break;
+                    }
+                }
+
+                if (makeRelationShip && parent != 0 && child != 0) {
+                    GraphicController.getController().setGraphicObjectRelationship(parent, child);
+                }
+
+                if (childNode.hasChildNodes()) {
+                    parseNode(child, childNode.getChildNodes());
+                }
+
+            }
+        }
+    }
+
+    private Integer createBorder(Node node) {
+        GraphicController controller = GraphicController.getController();
+        Integer uib = controller.askObject(GraphicObject.getTypeFromName(__GO_UI_FRAME_BORDER__));
+
+        NamedNodeMap attr = node.getAttributes();
+
+        Node styleNode = attr.getNamedItem("style");
+        if (styleNode != null) {
+            Integer style = FrameBorderType.stringToEnum(styleNode.getNodeValue()).ordinal();
+            controller.setProperty(uib, __GO_UI_FRAME_BORDER_STYLE__, style);
+            attr.removeNamedItem("style");
+        }
+
+        for (int i = 0 ; i < attr.getLength() ; i++) {
+            Node prop = attr.item(i);
+            Pair<Integer, ModelType> pair = BorderPropToGO.get(prop.getNodeName());
+
+            ModelType modelType = pair.getSecond();
+            switch (modelType) {
+                case BOOLEAN:
+                    controller.setProperty(uib, pair.getFirst(), getAttributeAsBoolean(prop.getNodeValue()));
+                    break;
+                case BOOLEAN_ARRAY :
+                    controller.setProperty(uib, pair.getFirst(), getAttributeAsBooleanArray(prop.getNodeValue()));
+                    break;
+                case DOUBLE:
+                    controller.setProperty(uib, pair.getFirst(), getAttributeAsDouble(prop.getNodeValue()));
+                    break;
+                case DOUBLE_ARRAY:
+                    controller.setProperty(uib, pair.getFirst(), getAttributeAsDoubleArray(prop.getNodeValue()));
+                    break;
+                case INTEGER:
+                    controller.setProperty(uib, pair.getFirst(), getAttributeAsInteger(prop.getNodeValue()));
+                    break;
+                case INTEGER_ARRAY:
+                    controller.setProperty(uib, pair.getFirst(), getAttributeAsIntegerArray(prop.getNodeValue()));
+                    break;
+                case STRING:
+                    controller.setProperty(uib, pair.getFirst(), getAttributeAsString(prop.getNodeValue()));
+                    break;
+                case STRING_ARRAY:
+                    controller.setProperty(uib, pair.getFirst(), getAttributeAsStringArray(prop.getNodeValue()));
+                    break;
+                default:
+                    System.out.println("missing type");
+                    break;
+            }
+        }
+
+        //manage children here to avoid trouble on draw without children in SwingView
+        if (node.hasChildNodes()) {
+            NodeList list = node.getChildNodes();
+            for (int i = 0 ; i < list.getLength() ; i++) {
+                Node childNode = list.item(i);
+                if (childNode.getNodeType() == Node.ELEMENT_NODE) {
+                    Integer child = createBorder(childNode);
+                    String nodeName = childNode.getNodeName();
+                    if (nodeName.equals("title")) {
+                        GraphicController.getController().setProperty(uib, __GO_UI_FRAME_BORDER_TITLE__, child);
+                    } else if (nodeName.equals("out")) {
+                        GraphicController.getController().setProperty(uib, __GO_UI_FRAME_BORDER_OUT_BORDER__, child);
+                    } else if (nodeName.equals("in")) {
+                        GraphicController.getController().setProperty(uib, __GO_UI_FRAME_BORDER_IN_BORDER__, child);
+                    }
+                }
+            }
+        }
+        return uib;
+    }
+
+    private Integer createFigure(Node node) {
+        GraphicController controller = GraphicController.getController();
+        Boolean dockable = true;
+        Integer menubar = 1;
+        Integer toolbar = 1;
+        Boolean default_axes = true;
+
+        NamedNodeMap attr = node.getAttributes();
+        //dockable
+        Node tempnode = attr.getNamedItem("dockable");
+        if (tempnode != null) {
+            dockable = getAttributeAsBoolean(tempnode.getNodeValue());
+            attr.removeNamedItem("dockable");
+        }
+        //menubar
+        tempnode = attr.getNamedItem("menubar");
+        if (tempnode != null) {
+            menubar = getAttributeAsInteger(tempnode.getNodeValue());
+            attr.removeNamedItem("menubar");
+        }
+        //toolbar
+        tempnode = attr.getNamedItem("toolbar");
+        if (tempnode != null) {
+            toolbar = getAttributeAsInteger(tempnode.getNodeValue());
+            attr.removeNamedItem("toolbar");
+        }
+        //default_axes
+        tempnode = attr.getNamedItem("default_axes");
+        if (tempnode != null) {
+            default_axes = getAttributeAsBoolean(tempnode.getNodeValue());
+            attr.removeNamedItem("default_axes");
+        }
+        //visible
+        tempnode = attr.getNamedItem("visible");
+        if (tempnode != null) {
+            figVisible = getAttributeAsBoolean(tempnode.getNodeValue());
+            attr.removeNamedItem("visible");
+        }
+
+        System.out.println("default_axes : " + default_axes);
+        Integer fig = Builder.createFigure(dockable, menubar, toolbar, default_axes, false);
+
+        for (int i = 0 ; i < attr.getLength() ; i++) {
+            Node prop = attr.item(i);
+            Pair<Integer, ModelType> pair = figPropToGO.get(prop.getNodeName());
+
+            ModelType type = pair.getSecond();
+            switch (type) {
+                case BOOLEAN:
+                    controller.setProperty(fig, pair.getFirst(), getAttributeAsBoolean(prop.getNodeValue()));
+                    break;
+                case BOOLEAN_ARRAY:
+                    controller.setProperty(fig, pair.getFirst(), getAttributeAsBooleanArray(prop.getNodeValue()));
+                    break;
+                case DOUBLE:
+                    controller.setProperty(fig, pair.getFirst(), getAttributeAsDouble(prop.getNodeValue()));
+                    break;
+                case DOUBLE_ARRAY:
+                    controller.setProperty(fig, pair.getFirst(), getAttributeAsDoubleArray(prop.getNodeValue()));
+                    break;
+                case INTEGER:
+                    controller.setProperty(fig, pair.getFirst(), getAttributeAsInteger(prop.getNodeValue()));
+                    break;
+                case INTEGER_ARRAY:
+                    controller.setProperty(fig, pair.getFirst(), getAttributeAsIntegerArray(prop.getNodeValue()));
+                    break;
+                case STRING:
+                    controller.setProperty(fig, pair.getFirst(), getAttributeAsString(prop.getNodeValue()));
+                    break;
+                case STRING_ARRAY:
+                    controller.setProperty(fig, pair.getFirst(), getAttributeAsStringArray(prop.getNodeValue()));
+                    break;
+                default:
+                    System.out.println("missing type");
+                    break;
+            }
+        }
+
+        return fig;
+    }
+
+    private Integer createUiControl(Integer type, Integer parent, Node node) {
+        GraphicController controller = GraphicController.getController();
+        NamedNodeMap attr = node.getAttributes();
+
+        /*for frame we have to take care of scrollable property*/
+        if (type == __GO_UI_FRAME__) {
+            Node item = attr.getNamedItem("scrollable");
+            if (item != null && item.getNodeValue().equals("on")) {
+                type = __GO_UI_FRAME_SCROLLABLE__;
+            }
+        }
+
+        Integer uic = GraphicController.getController().askObject(GraphicObject.getTypeFromName(type));
+        controller.setProperty(uic, __GO_VISIBLE__, true);
+
+        for (int i = 0 ; i < attr.getLength() ; i++) {
+            Node prop = attr.item(i);
+            Pair<Integer, ModelType> pair = UiPropToGO.get(prop.getNodeName());
+
+            ModelType modelType = pair.getSecond();
+            switch (modelType) {
+                case BOOLEAN:
+                    controller.setProperty(uic, pair.getFirst(), getAttributeAsBoolean(prop.getNodeValue()));
+                    break;
+                case BOOLEAN_ARRAY :
+                    controller.setProperty(uic, pair.getFirst(), getAttributeAsBooleanArray(prop.getNodeValue()));
+                    break;
+                case DOUBLE:
+                    controller.setProperty(uic, pair.getFirst(), getAttributeAsDouble(prop.getNodeValue()));
+                    break;
+                case DOUBLE_ARRAY:
+                    controller.setProperty(uic, pair.getFirst(), getAttributeAsDoubleArray(prop.getNodeValue()));
+                    break;
+                case INTEGER:
+                    controller.setProperty(uic, pair.getFirst(), getAttributeAsInteger(prop.getNodeValue()));
+                    break;
+                case INTEGER_ARRAY:
+                    controller.setProperty(uic, pair.getFirst(), getAttributeAsIntegerArray(prop.getNodeValue()));
+                    break;
+                case STRING:
+                    controller.setProperty(uic, pair.getFirst(), getAttributeAsString(prop.getNodeValue()));
+                    break;
+                case STRING_ARRAY:
+                    controller.setProperty(uic, pair.getFirst(), getAttributeAsStringArray(prop.getNodeValue()));
+                    break;
+                default:
+                    System.out.println("missing type");
+                    break;
+            }
+        }
+
+        return uic;
+    }
+
+    private Boolean getAttributeAsBoolean(String val) {
+        if (val == null) {
+            return null;
+        }
+
+        if (val.equals("on")) {
+            return true;
+        }
+
+        if (val.equals("off")) {
+            return false;
+        }
+
+        return false;
+    }
+
+    private void setBooleanAttribute(Integer id, int property, NamedNodeMap attributes, String attr) {
+        Node node = attributes.getNamedItem(attr);
+        if (node != null) {
+            Boolean b = getAttributeAsBoolean(node.getNodeValue());
+            if (b != null) {
+                GraphicController.getController().setProperty(id, property, b);
+            }
+        }
+    }
+
+    private Double getAttributeAsDouble(String val) {
+        if (val == null) {
+            return null;
+        }
+
+        return Double.parseDouble(val);
+    }
+
+    private Integer getAttributeAsInteger(String val) {
+        if (val == null) {
+            return null;
+        }
+
+        return Integer.parseInt(val);
+    }
+
+    private String getAttributeAsString(String val) {
+        return val;
+    }
+
+    private Boolean[] getAttributeAsBooleanArray(String val) {
+
+        if (val == null) {
+            return new Boolean[] {};
+        }
+
+        StringTokenizer token = new StringTokenizer(val, ",");
+
+        Boolean[] b = new Boolean[token.countTokens()];
+        int i = 0;
+        while (token.hasMoreElements()) {
+            String s = token.nextToken();
+            if (s.equals("on")) {
+                b[i++] = true;
+            } else {
+                b[i++] = false;
+            }
+        }
+
+        return b;
+    }
+
+    private Double[] getAttributeAsDoubleArray(String val) {
+
+        if (val == null) {
+            return new Double[] {};
+        }
+
+        StringTokenizer token = new StringTokenizer(val, ",");
+
+        Double[] d = new Double[token.countTokens()];
+        int i = 0;
+        while (token.hasMoreElements()) {
+            String s = token.nextToken();
+            d[i++] = Double.parseDouble(s);
+        }
+
+        return d;
+    }
+
+    private Integer[] getAttributeAsIntegerArray(String val) {
+
+        if (val == null) {
+            return new Integer[] {};
+        }
+
+        StringTokenizer token = new StringTokenizer(val, ",");
+
+        Integer[] integer = new Integer[token.countTokens()];
+        int i = 0;
+        while (token.hasMoreElements()) {
+            String s = token.nextToken();
+            integer[i++] = Integer.parseInt(s);
+        }
+
+        return integer;
+    }
+
+    private String[] getAttributeAsStringArray(String val) {
+
+        if (val == null) {
+            return null;
+        }
+
+        StringTokenizer token = new StringTokenizer(val, ",");
+
+        String[] s = new String[token.countTokens()];
+        int i = 0;
+        while (token.hasMoreElements()) {
+            s[i++] = token.nextToken();
+        }
+
+        return s;
+    }
+}
index c4727e6..155ab82 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.scilab.modules.graphic_objects.xmlloader;
 
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXES__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TYPE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CHILDREN__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_FIGURE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_CHECKBOX__;
@@ -24,7 +26,6 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_PUSHBUTTON__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_RADIOBUTTON__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SLIDER__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TABLE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TAB__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TEXT__;
 
@@ -43,7 +44,13 @@ import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
 import org.scilab.modules.commons.gui.FindIconHelper;
+import org.scilab.modules.graphic_objects.ScilabNativeView;
+import org.scilab.modules.graphic_objects.builder.Builder;
 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+import org.scilab.modules.graphic_objects.graphicModel.GraphicModel;
+import org.scilab.modules.graphic_objects.graphicObject.GraphicObject;
+import org.scilab.modules.graphic_objects.graphicObject.GraphicObject.Type;
+import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
@@ -69,63 +76,24 @@ public class XmlLoader extends DefaultHandler {
     static {
         // init map to convert control name to id
         nameToGO.put("UIScilabWindow", __GO_FIGURE__);
-        nameToGO.put("Figure", __GO_FIGURE__);
 
         nameToGO.put("UIPanel", __GO_UI_FRAME__);
         nameToGO.put("UIFrame", __GO_UI_FRAME__);
-        nameToGO.put("Panel", __GO_UI_FRAME__);
-        nameToGO.put("Frame", __GO_UI_FRAME__);
-
         nameToGO.put("UILayer", __GO_UI_LAYER__);
-        nameToGO.put("Layer", __GO_UI_LAYER__);
-
         nameToGO.put("UIButton", __GO_UI_PUSHBUTTON__);
-        nameToGO.put("PushButton", __GO_UI_PUSHBUTTON__);
-        nameToGO.put("Button", __GO_UI_PUSHBUTTON__);
-
         nameToGO.put("UILabel", __GO_UI_TEXT__);
-        nameToGO.put("Label", __GO_UI_TEXT__);
-        nameToGO.put("Text", __GO_UI_TEXT__);
-
         nameToGO.put("UICheckbox", __GO_UI_CHECKBOX__);
-        nameToGO.put("CheckBox", __GO_UI_CHECKBOX__);
-
         nameToGO.put("UITextfield", __GO_UI_EDIT__);
-        nameToGO.put("Textfield", __GO_UI_EDIT__);
-        nameToGO.put("EditBox", __GO_UI_EDIT__);
-        nameToGO.put("Edit", __GO_UI_EDIT__);
-
         nameToGO.put("UISplashScreen", __GO_UI_IMAGE__);
-        nameToGO.put("Image", __GO_UI_IMAGE__);
-        nameToGO.put("Picture", __GO_UI_IMAGE__);
-
         nameToGO.put("UIList", __GO_UI_LISTBOX__);
-        nameToGO.put("List", __GO_UI_LISTBOX__);
-        nameToGO.put("ListBox", __GO_UI_LISTBOX__);
-
         nameToGO.put("UIComboBox", __GO_UI_POPUPMENU__);
-        nameToGO.put("ComboBox", __GO_UI_POPUPMENU__);
-        nameToGO.put("PopupMenu", __GO_UI_POPUPMENU__);
-
         nameToGO.put("UIRadio", __GO_UI_RADIOBUTTON__);
-        nameToGO.put("RadioButton", __GO_UI_RADIOBUTTON__);
-        nameToGO.put("Radio", __GO_UI_RADIOBUTTON__);
-
         nameToGO.put("UISlider", __GO_UI_SLIDER__);
-        nameToGO.put("Slider", __GO_UI_SLIDER__);
-
-        nameToGO.put("Table", __GO_UI_TABLE__);
-
-        nameToGO.put("UILabel", __GO_UI_TEXT__);
-        nameToGO.put("Text", __GO_UI_TEXT__);
-        nameToGO.put("Label", __GO_UI_TEXT__);
-
         nameToGO.put("UITab", __GO_UI_TAB__);
-
+        nameToGO.put("UIScilabPlot", __GO_AXES__);
 
         /** sdsdf*/
         nameToGO.put("UITextarea", __GO_UI_PUSHBUTTON__);
-        nameToGO.put("UIScilabPlot", __GO_UI_FRAME__);
         nameToGO.put("UIComboColor", __GO_UI_POPUPMENU__);
 
     }
@@ -240,6 +208,7 @@ public class XmlLoader extends DefaultHandler {
             if (go == null) {
             } else if (stackGO.size() > 0) {
                 Integer parent = stackGO.peek();
+
                 controller.setGraphicObjectRelationship(parent, go);
                 //controller.setProperty(go, __GO_VISIBLE__, true);
             } else {
@@ -276,6 +245,8 @@ public class XmlLoader extends DefaultHandler {
                 if (uitype == __GO_FIGURE__) {
                     // never create a new figure, clone figure model !
                     go = GOBuilder.figureBuilder(controller, attributes);
+                } else if (uitype == __GO_AXES__) {
+                    go = GraphicController.getController().askObject(Type.AXES);
                 } else {
                     int parent = 0;
                     if (stackGO.isEmpty() == false) {
@@ -336,8 +307,22 @@ public class XmlLoader extends DefaultHandler {
         Integer newGo = controller.cloneObject(root);
         Integer[] children = (Integer[]) controller.getProperty(root, __GO_CHILDREN__);
         for (int i = 0; i < children.length; i++) {
-            Integer newChild = cloneObject(children[i]);
-            controller.setGraphicObjectRelationship(newGo, newChild);
+            if ((Integer)controller.getProperty(children[i], __GO_TYPE__) == __GO_AXES__) {
+                Integer go = controller.cloneObject(GraphicModel.getAxesModel().getIdentifier());
+                Builder.createLabel(go, GraphicObjectProperties.__GO_X_AXIS_LABEL__);
+                Builder.createLabel(go, GraphicObjectProperties.__GO_Y_AXIS_LABEL__);
+                Builder.createLabel(go, GraphicObjectProperties.__GO_Z_AXIS_LABEL__);
+                Builder.createLabel(go, GraphicObjectProperties.__GO_TITLE__);
+
+                controller.setGraphicObjectRelationship(newGo, go);
+                controller.setProperty(newGo, GraphicObjectProperties.__GO_SELECTED_CHILD__, go);
+
+                ScilabNativeView.ScilabNativeView__setCurrentSubWin(go);
+                ScilabNativeView.ScilabNativeView__setCurrentObject(go);
+            } else {
+                Integer newChild = cloneObject(children[i]);
+                controller.setGraphicObjectRelationship(newGo, newChild);
+            }
         }
 
         return newGo;
diff --git a/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlSaver.java b/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlSaver.java
new file mode 100644 (file)
index 0000000..3427835
--- /dev/null
@@ -0,0 +1,518 @@
+package org.scilab.modules.graphic_objects.xmlloader;
+
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXES__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LAYOUT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_PARENT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TYPE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UICONTEXTMENU__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UICONTROL__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UIMENU__;
+
+import java.io.File;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.scilab.modules.graphic_objects.console.Console;
+import org.scilab.modules.graphic_objects.figure.Figure;
+import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+import org.scilab.modules.graphic_objects.graphicModel.GraphicModel;
+import org.scilab.modules.graphic_objects.graphicObject.GraphicObject;
+import org.scilab.modules.graphic_objects.uicontrol.Uicontrol;
+import org.scilab.modules.graphic_objects.uicontrol.Uicontrol.UicontrolStyle;
+import org.scilab.modules.graphic_objects.uicontrol.frame.border.FrameBorder;
+import org.scilab.modules.graphic_objects.uicontrol.frame.border.FrameBorderType;
+import org.scilab.modules.graphic_objects.utils.LayoutType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+
+public class XmlSaver {
+    static private Uicontrol defaultUi = null;
+    static private Figure defaultFig = null;
+    static private FrameBorder defaultBorder = null;
+
+    public static String save(int figure, String filename) {
+        try {
+            //init default values
+            defaultFig = GraphicModel.getFigureModel();
+            defaultBorder = new FrameBorder();
+
+            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+
+            //root elements
+            Document doc = docBuilder.newDocument();
+            //standalone="yes"
+            doc.setXmlStandalone(true);
+
+            //scilab header
+            Element header = doc.createElement("scilabgui");
+            setAttribute(header, "version", "1.0", "");
+            setAttribute(header, "usedeprecatedskin", createAttribute(Console.getConsole().getUseDeprecatedLF()), "");
+
+            //figure
+            Element figureElement = createFigure(doc, figure);
+            header.appendChild(figureElement);
+            doc.appendChild(header);
+
+            //write the content into xml file
+            TransformerFactory transformerFactory = TransformerFactory.newInstance();
+            Transformer transformer = transformerFactory.newTransformer();
+            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+            transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
+            doc.getDocumentElement().normalize();
+            DOMSource source = new DOMSource(doc);
+
+            StreamResult result =  new StreamResult(new File(filename));
+            transformer.transform(source, result);
+        } catch (ParserConfigurationException pce) {
+            return pce.getMessage();
+        } catch (TransformerException tfe) {
+            return tfe.getMessage();
+        }
+
+        defaultFig = null;
+        defaultUi = null;
+        defaultBorder = null;
+        return ""; //all good
+    }
+
+    private static Element createFigure(Document doc, int figure) {
+        GraphicController controller = GraphicController.getController();
+        Figure fig = (Figure)controller.getObjectFromId(figure);
+        Element elemFig = doc.createElement("figure");
+
+        //figure_position
+        setAttribute(elemFig, "figure_position", createAttribute(fig.getPosition()), createAttribute(defaultFig.getPosition()));
+        //figure_size
+        setAttribute(elemFig, "figure_size", createAttribute(fig.getSize()), createAttribute(defaultFig.getSize()));
+        //axes_size
+        setAttribute(elemFig, "axes_size", createAttribute(fig.getAxesSize()), createAttribute(defaultFig.getAxesSize()));
+        //auto_resize
+        setAttribute(elemFig, "auto_resize", createAttribute(fig.getAutoResize()), createAttribute(defaultFig.getAutoResize()));
+        //view_port
+        setAttribute(elemFig, "view_port", createAttribute(fig.getViewport()), createAttribute(defaultFig.getViewport()));
+        //figure_name
+        setAttribute(elemFig, "figure_name", createAttribute(fig.getName()), createAttribute(defaultFig.getName()));
+        //figure_id
+        setAttribute(elemFig, "figure_id", createAttribute(fig.getId()), createAttribute(defaultFig.getId()));
+        //info_message
+        setAttribute(elemFig, "info_message", createAttribute(fig.getInfoMessage()), createAttribute(defaultFig.getInfoMessage()));
+        //pixel_drawing_mode
+        setAttribute(elemFig, "pixel_drawing_mode", createAttribute(fig.getPixelDrawingMode()), createAttribute(defaultFig.getPixelDrawingMode()));
+        //anti_aliasing
+        setAttribute(elemFig, "anti_aliasing", createAttribute(fig.getAntialiasing()), createAttribute(defaultFig.getAntialiasing()));
+        //immediate_drawing
+        setAttribute(elemFig, "immediate_drawing", createAttribute(fig.getImmediateDrawing()), createAttribute(defaultFig.getImmediateDrawing()));
+        //background
+        setAttribute(elemFig, "background", createAttribute(fig.getBackground()), createAttribute(defaultFig.getBackground()));
+        //visible
+        setAttribute(elemFig, "visible", createAttribute(fig.getVisible()), createAttribute(defaultFig.getVisible()));
+        //rotation_style
+        setAttribute(elemFig, "rotation_style", createAttribute(fig.getRotation()), createAttribute(defaultFig.getRotation()));
+        //event_handler
+        setAttribute(elemFig, "event_handler", createAttribute(fig.getEventHandlerString()), createAttribute(defaultFig.getEventHandlerString()));
+        //event_handler_enable
+        setAttribute(elemFig, "event_handler_enable", createAttribute(fig.getEventHandlerEnable()), createAttribute(defaultFig.getEventHandlerEnable()));
+        //resizefcn
+        setAttribute(elemFig, "resizefcn", createAttribute(fig.getResizeFcn()), createAttribute(defaultFig.getResizeFcn()));
+        //closerequestfcn
+        setAttribute(elemFig, "closerequestfcn", createAttribute(fig.getCloseRequestFcn()), createAttribute(defaultFig.getCloseRequestFcn()));
+        //resize
+        setAttribute(elemFig, "resize", createAttribute(fig.getResize()), createAttribute(defaultFig.getResize()));
+        //toolbar
+        setAttribute(elemFig, "toolbar", createAttribute(fig.getToolbar()), createAttribute(defaultFig.getToolbar()));
+        //toolbar_visible
+        setAttribute(elemFig, "toolbar_visible", createAttribute(fig.getToolbarVisible()), createAttribute(defaultFig.getToolbarVisible()));
+        //menubar
+        setAttribute(elemFig, "menubar", createAttribute(fig.getMenubar()), createAttribute(defaultFig.getMenubar()));
+        //menubar_visible
+        setAttribute(elemFig, "menubar_visible", createAttribute(fig.getMenubarVisible()), createAttribute(defaultFig.getMenubarVisible()));
+        //infobar_visible
+        setAttribute(elemFig, "infobar_visible", createAttribute(fig.getInfobarVisible()), createAttribute(defaultFig.getInfobarVisible()));
+        //dockable
+        setAttribute(elemFig, "dockable", createAttribute(fig.getDockable()), createAttribute(defaultFig.getDockable()));
+        //layout
+        setAttribute(elemFig, "layout", createAttribute(fig.getLayout()), createAttribute(defaultFig.getLayout()));
+
+        //default_axes
+        setAttribute(elemFig, "default_axes", createAttribute(fig.hasDefaultAxes()), createAttribute(defaultFig.hasDefaultAxes()));
+        //icon
+        setAttribute(elemFig, "icon", createAttribute(fig.getIcon()), createAttribute(defaultFig.getIcon()));
+        //tag
+        setAttribute(elemFig, "tag", createAttribute(fig.getTag()), createAttribute(defaultFig.getTag()));
+
+        //layout_options
+        if (fig.getLayoutAsEnum() == LayoutType.GRID) {
+            setAttribute(elemFig, "grid_opt_grid", createAttribute(fig.getGridOptGrid()), createAttribute(defaultFig.getGridOptGrid()));
+            setAttribute(elemFig, "grid_opt_padding", createAttribute(fig.getGridOptPadding()), createAttribute(defaultFig.getGridOptPadding()));
+        } else if (fig.getLayoutAsEnum() == LayoutType.BORDER) {
+            setAttribute(elemFig, "border_opt_padding", createAttribute(fig.getBorderOptPadding()), createAttribute(defaultFig.getBorderOptPadding()));
+        }
+
+        //children
+        Integer[] children = fig.getChildren();
+        for (int i = 0 ; i < children.length ; i++) {
+            elemFig.appendChild(createElement(doc, children[i]));
+        }
+
+        return elemFig;
+    }
+
+    private static Element createElement(Document doc, int id) {
+        GraphicController controller = GraphicController.getController();
+        Integer type = (Integer)controller.getProperty(id, __GO_TYPE__);
+
+        switch (type) {
+            case __GO_UICONTROL__ : {
+                return createUicontrol(doc, id);
+            }
+            case __GO_UIMENU__ : {
+                //Uimenu uim = (Uimenu)controller.getObjectFromId(id);
+                return doc.createElement("menu");
+            }
+            case __GO_UICONTEXTMENU__ : {
+                //Uicontextmenu uicm = (Uicontextmenu)controller.getObjectFromId(id);
+                return doc.createElement("contextmenu");
+            }
+            case __GO_AXES__ : {
+                //Axes axes = (Axes)controller.getObjectFromId(id);
+                return doc.createElement("axes");
+            }
+        }
+
+        return doc.createElement("fake");
+    }
+
+    private static Element createBorders(Document doc, Integer id) {
+        return createBorders(doc, id, "borders");
+    }
+
+    private static Element createBorders(Document doc, Integer id, String borderName) {
+        GraphicController controller = GraphicController.getController();
+        FrameBorder border = (FrameBorder)controller.getObjectFromId(id);
+
+        if (border == null || border.getStyleAsEnum() == FrameBorderType.NONE) {
+            return null;
+        }
+
+        Element elemBorders = doc.createElement(borderName);
+
+        setAttribute(elemBorders, "style", createAttribute(border.getStyleAsEnum().toString().toLowerCase()), "");
+
+        switch (border.getStyleAsEnum()) {
+            case BEVEL: {
+                setAttribute(elemBorders, "type", createAttribute(border.getBorderType()), createAttribute(defaultBorder.getBorderType()));
+                setAttribute(elemBorders, "hlout", createAttribute(border.getHlOut()), createAttribute(defaultBorder.getHlOut()));
+                setAttribute(elemBorders, "hlin", createAttribute(border.getHlIn()), createAttribute(defaultBorder.getHlIn()));
+                setAttribute(elemBorders, "shadowout", createAttribute(border.getShadowOut()), createAttribute(defaultBorder.getShadowOut()));
+                setAttribute(elemBorders, "shadowin", createAttribute(border.getShadowIn()), createAttribute(defaultBorder.getShadowIn()));
+                break;
+            }
+            case COMPOUND: {
+                Element out = createBorders(doc, border.getOutBorder(), "out");
+                if (out != null) {
+                    elemBorders.appendChild(out);
+                }
+
+                Element in = createBorders(doc, border.getInBorder(), "in");
+                if (in != null) {
+                    elemBorders.appendChild(in);
+                }
+                break;
+            }
+            case EMPTY: {
+                setAttribute(elemBorders, "position", createAttribute(border.getPosition()), createAttribute(defaultBorder.getPosition()));
+                break;
+            }
+            case ETCHED: {
+                setAttribute(elemBorders, "type", createAttribute(border.getBorderType()), createAttribute(defaultBorder.getBorderType()));
+                setAttribute(elemBorders, "hl", createAttribute(border.getHlOut()), createAttribute(defaultBorder.getHlOut()));
+                setAttribute(elemBorders, "shadow", createAttribute(border.getShadowOut()), createAttribute(defaultBorder.getShadowOut()));
+                break;
+            }
+            case LINE: {
+                setAttribute(elemBorders, "color", createAttribute(border.getColor()), createAttribute(defaultBorder.getColor()));
+                setAttribute(elemBorders, "thickness", createAttribute(border.getThickness()), createAttribute(defaultBorder.getThickness()));
+                setAttribute(elemBorders, "rounded", createAttribute(border.getRounded()), createAttribute(defaultBorder.getRounded()));
+                break;
+            }
+            case MATTE: {
+                setAttribute(elemBorders, "position", createAttribute(border.getPosition()), createAttribute(defaultBorder.getPosition()));
+                setAttribute(elemBorders, "color", createAttribute(border.getColor()), createAttribute(defaultBorder.getColor()));
+                break;
+            }
+            case SOFTBEVEL: {
+                setAttribute(elemBorders, "type", createAttribute(border.getBorderType()), createAttribute(defaultBorder.getBorderType()));
+                setAttribute(elemBorders, "hlout", createAttribute(border.getHlOut()), createAttribute(defaultBorder.getHlOut()));
+                setAttribute(elemBorders, "hlin", createAttribute(border.getHlIn()), createAttribute(defaultBorder.getHlIn()));
+                setAttribute(elemBorders, "shadowout", createAttribute(border.getShadowOut()), createAttribute(defaultBorder.getShadowOut()));
+                setAttribute(elemBorders, "shadowin", createAttribute(border.getShadowIn()), createAttribute(defaultBorder.getShadowIn()));
+                break;
+            }
+            case TITLED: {
+                setAttribute(elemBorders, "title", createAttribute(border.getTitle()), createAttribute(defaultBorder.getTitle()));
+                setAttribute(elemBorders, "justification", createAttribute(border.getJustification()), createAttribute(defaultBorder.getJustification()));
+                setAttribute(elemBorders, "titleposition", createAttribute(border.getTitlePosition()), createAttribute(defaultBorder.getTitlePosition()));
+                setAttribute(elemBorders, "fontname", createAttribute(border.getFontName()), createAttribute(defaultBorder.getFontName()));
+                setAttribute(elemBorders, "fontangle", createAttribute(border.getFontAngle()), createAttribute(defaultBorder.getFontAngle()));
+                setAttribute(elemBorders, "fontsize", createAttribute(border.getFontSize()), createAttribute(defaultBorder.getFontSize()));
+                setAttribute(elemBorders, "fontweight", createAttribute(border.getFontWeight()), createAttribute(defaultBorder.getFontWeight()));
+                setAttribute(elemBorders, "color", createAttribute(border.getColor()), createAttribute(defaultBorder.getColor()));
+                Element title = createBorders(doc, border.getTitleBorder(), "title");
+                if (title != null) {
+                    elemBorders.appendChild(title);
+                }
+                break;
+            }
+            case NONE:
+            default: {
+                break;
+            }
+        }
+        return elemBorders;
+    }
+
+    private static Element createUicontrol(Document doc, Integer id) {
+        GraphicController controller = GraphicController.getController();
+        Uicontrol uic = (Uicontrol)controller.getObjectFromId(id);
+        initDefaultui(uic.getStyle());
+        Element elemUi = doc.createElement(uic.getStyleAsEnum().toString().toLowerCase());
+
+        //BackgroundColor
+        setAttribute(elemUi, "backgroundcolor", createAttribute(uic.getBackgroundColor()), createAttribute(defaultUi.getBackgroundColor()));
+        //Enable
+        setAttribute(elemUi, "enable", createAttribute(uic.getEnable()), createAttribute(defaultUi.getEnable()));
+        //FontAngle
+        setAttribute(elemUi, "fontangle", createAttribute(uic.getFontAngle()), createAttribute(defaultUi.getFontAngle()));
+        //FontName
+        setAttribute(elemUi, "fontname", createAttribute(uic.getFontName()), createAttribute(defaultUi.getFontName()));
+        //FontSize
+        setAttribute(elemUi, "fontsize", createAttribute(uic.getFontSize()), createAttribute(defaultUi.getFontSize()));
+        //FontUnits
+        setAttribute(elemUi, "fontunits", createAttribute(uic.getFontUnits()), createAttribute(defaultUi.getFontUnits()));
+        //FontWeight
+        setAttribute(elemUi, "fontweight", createAttribute(uic.getFontWeight()), createAttribute(defaultUi.getFontWeight()));
+        //ForegroundColor
+        setAttribute(elemUi, "foregroundcolor", createAttribute(uic.getForegroundColor()), createAttribute(defaultUi.getForegroundColor()));
+        //HorizontalAlignment
+        setAttribute(elemUi, "horizontalalignment", createAttribute(uic.getHorizontalAlignment()), createAttribute(defaultUi.getHorizontalAlignment()));
+        //ListboxTop
+        setAttribute(elemUi, "listboxtop", createAttribute(uic.getListboxTop()), createAttribute(defaultUi.getListboxTop()));
+        //Max
+        setAttribute(elemUi, "max", createAttribute(uic.getMax()), createAttribute(defaultUi.getMax()));
+        //Min
+        setAttribute(elemUi, "min", createAttribute(uic.getMin()), createAttribute(defaultUi.getMin()));
+        //Relief
+        setAttribute(elemUi, "relief", createAttribute(uic.getRelief()), createAttribute(defaultUi.getRelief()));
+        //SliderStep
+        setAttribute(elemUi, "sliderstep", createAttribute(uic.getSliderStep()), createAttribute(defaultUi.getSliderStep()));
+        //String
+        setAttribute(elemUi, "string", createAttribute(uic.getString()), createAttribute(defaultUi.getString()));
+        //TooltipString
+        setAttribute(elemUi, "tooltipstring", createAttribute(uic.getTooltipString()), createAttribute(defaultUi.getTooltipString()));
+        //Units
+        setAttribute(elemUi, "units", createAttribute(uic.getUnits()), createAttribute(defaultUi.getUnits()));
+        //Value
+        setAttribute(elemUi, "value", createAttribute(uic.getUiValue()), createAttribute(defaultUi.getUiValue()));
+        //VerticalAlignment
+        setAttribute(elemUi, "verticalalignment", createAttribute(uic.getVerticalAlignment()), createAttribute(defaultUi.getVerticalAlignment()));
+        //Visible
+        setAttribute(elemUi, "visible", createAttribute(uic.getVisible()), createAttribute(!defaultUi.getVisible()));
+        //Callback
+        setAttribute(elemUi, "callback", createAttribute(uic.getCallbackString()), createAttribute(defaultUi.getCallbackString()));
+        //Callback_Type
+        setAttribute(elemUi, "callback_type", createAttribute(uic.getCallbackType()), createAttribute(defaultUi.getCallbackType()));
+
+        //Constraints
+        Integer parent = (Integer)controller.getProperty(uic.getIdentifier(), __GO_PARENT__);
+        Integer iLayout = (Integer)controller.getProperty(parent, __GO_LAYOUT__);
+        LayoutType layout = LayoutType.intToEnum(iLayout);
+
+        if (layout == LayoutType.GRIDBAG) {
+            setAttribute(elemUi, "gridbaggrid", createAttribute(uic.getGridBagGrid()), createAttribute(defaultUi.getGridBagGrid()));
+            setAttribute(elemUi, "gridbagweight", createAttribute(uic.getGridBagWeight()), createAttribute(defaultUi.getGridBagWeight()));
+            setAttribute(elemUi, "gridbagfill", createAttribute(uic.getGridBagFill()), createAttribute(defaultUi.getGridBagFill()));
+            setAttribute(elemUi, "gridbaganchor", createAttribute(uic.getGridBagAnchor()), createAttribute(defaultUi.getGridBagAnchor()));
+            setAttribute(elemUi, "gridbagpadding", createAttribute(uic.getGridBagPadding()), createAttribute(defaultUi.getGridBagPadding()));
+            setAttribute(elemUi, "gridbagpreferredsize", createAttribute(uic.getGridBagPreferredSize()), createAttribute(defaultUi.getGridBagPreferredSize()));
+        } else if (layout == LayoutType.BORDER) {
+            setAttribute(elemUi, "borderposition", createAttribute(uic.getBorderPosition()), createAttribute(defaultUi.getBorderPosition()));
+        } else if (layout == LayoutType.NONE) {
+            //Position
+            setAttribute(elemUi, "position", createAttribute(uic.getUiPosition()), createAttribute(defaultUi.getUiPosition()));
+        }
+
+        //Margins
+        setAttribute(elemUi, "margins", createAttribute(uic.getMargins()), createAttribute(defaultUi.getMargins()));
+        //Groupname
+        setAttribute(elemUi, "groupname", createAttribute(uic.getGroupName()), createAttribute(defaultUi.getGroupName()));
+
+        //icon
+        setAttribute(elemUi, "icon", createAttribute(uic.getIcon()), createAttribute(defaultUi.getIcon()));
+        //Tag
+        setAttribute(elemUi, "tag", createAttribute(uic.getTag()), createAttribute(defaultUi.getTag()));
+
+        //only for frame type
+        if (uic.getStyleAsEnum() == UicontrolStyle.FRAME) {
+            //Borders
+            Integer iBorders = uic.getFrameBorder();
+            Element borders = createBorders(doc, iBorders);
+            if (borders != null) {
+                elemUi.appendChild(createBorders(doc, iBorders));
+            }
+
+            //Scrollable
+            setAttribute(elemUi, "scrollable", createAttribute(uic.getScrollable()), createAttribute(defaultUi.getScrollable()));
+
+            //Layout
+            setAttribute(elemUi, "layout", createAttribute(uic.getLayout()), createAttribute(defaultUi.getLayout()));
+            //Layout_options
+            if (uic.getLayoutAsEnum() == LayoutType.GRID) {
+                setAttribute(elemUi, "gridoptgrid", createAttribute(uic.getGridOptGrid()), createAttribute(defaultUi.getGridOptGrid()));
+                setAttribute(elemUi, "gridoptpadding", createAttribute(uic.getGridOptPadding()), createAttribute(defaultUi.getGridOptPadding()));
+            } else if (uic.getLayoutAsEnum() == LayoutType.BORDER) {
+                setAttribute(elemUi, "borderoptpadding", createAttribute(uic.getBorderOptPadding()), createAttribute(defaultUi.getBorderOptPadding()));
+            }
+        }
+
+        //children
+        Integer[] children = uic.getChildren();
+        for (int i = 0 ; i < children.length ; i++) {
+            elemUi.appendChild(createElement(doc, children[i]));
+        }
+
+        return elemUi;
+    }
+
+    private static String createAttribute(Boolean val) {
+        if (val == null) {
+            return "off";
+        }
+
+        if (val) {
+            return "on";
+        } else {
+            return "off";
+        }
+    }
+
+    private static String createAttribute(Integer val) {
+        if (val == null) {
+            return null;
+        }
+
+        StringBuilder builder = new StringBuilder();
+        builder.append(val.intValue());
+        return builder.toString();
+    }
+
+    private static String createAttribute(String val) {
+        if (val == null) {
+            return null;
+        }
+        return val;
+    }
+
+    private static String createAttribute(Double val) {
+        if (val == null) {
+            return null;
+        }
+
+        StringBuilder builder = new StringBuilder();
+        builder.append(val.doubleValue());
+        return builder.toString();
+    }
+
+    //    private static String createAttribute(Boolean[] val) {
+    //        if(val == null || val.length == 0) {
+    //            return null;
+    //        }
+    //
+    //        StringBuilder onoff = new StringBuilder();
+    //
+    //        onoff.append(createAttribute(val[0]));
+    //
+    //        for(int i = 1 ; i < val.length; i++)
+    //        {
+    //            onoff.append(",");
+    //            onoff.append(createAttribute(val[i]));
+    //        }
+    //
+    //        return onoff.toString();
+    //    }
+
+
+    private static String createAttribute(String[] val) {
+        if (val == null || val.length == 0) {
+            return null;
+        }
+
+        StringBuilder onoff = new StringBuilder();
+
+        onoff.append(createAttribute(val[0]));
+
+        for (int i = 1 ; i < val.length; i++) {
+            onoff.append(",");
+            onoff.append(createAttribute(val[i]));
+        }
+
+        return onoff.toString();
+    }
+
+    private static String createAttribute(Double[] val) {
+        if (val == null || val.length == 0) {
+            return null;
+        }
+
+        StringBuilder onoff = new StringBuilder();
+
+        onoff.append(createAttribute(val[0]));
+
+        for (int i = 1 ; i < val.length; i++) {
+            onoff.append(",");
+            onoff.append(createAttribute(val[i]));
+        }
+
+        return onoff.toString();
+    }
+
+    private static String createAttribute(Integer[] val) {
+        if (val == null || val.length == 0) {
+            return null;
+        }
+
+        StringBuilder onoff = new StringBuilder();
+
+        onoff.append(createAttribute(val[0]));
+
+        for (int i = 1 ; i < val.length; i++) {
+            onoff.append(",");
+            onoff.append(createAttribute(val[i]));
+        }
+
+        return onoff.toString();
+    }
+
+    private static void setAttribute(Element elem, String property, String value, String ref) {
+        if (value == null || property == null || elem == null || (ref != null && value.equals(ref))) {
+            return;
+        }
+
+        elem.setAttribute(property, value);
+    }
+
+    private static void initDefaultui(Integer uicontrolStyle) {
+        Integer uic = GraphicController.getController().askObject(GraphicObject.getTypeFromName(uicontrolStyle));
+        defaultUi = (Uicontrol) GraphicController.getController().getObjectFromId(uic);
+    }
+
+}
index ac8b717..c088c06 100644 (file)
@@ -149,6 +149,7 @@ public class XmlTools {
         if (map != null) {
             String ret = map.get(field);
             if (ret != null) {
+                map.remove(field);
                 return ret;
             }
         }
index 9eb88fc..cb076b9 100644 (file)
@@ -104,6 +104,8 @@ curEnv->DeleteLocalRef(localInstance);
 
                 /* Methods ID set to NULL */
 jintLoadjstringjava_lang_StringID=NULL;
+jstringSavejintintjstringjava_lang_StringID=NULL;
+jintDomLoadjstringjava_lang_StringID=NULL;
 
 
 }
@@ -127,6 +129,8 @@ throw GiwsException::JniObjectCreationException(curEnv, this->className());
         }
         /* Methods ID set to NULL */
         jintLoadjstringjava_lang_StringID=NULL;
+jstringSavejintintjstringjava_lang_StringID=NULL;
+jintDomLoadjstringjava_lang_StringID=NULL;
 
 
 }
@@ -146,7 +150,7 @@ throw GiwsException::JniMonitorException(getCurrentEnv(), "CallXmlLoader");
 }
 // Method(s)
 
-int CallXmlLoader::Load (JavaVM * jvm_, char const* xmlFile){
+int CallXmlLoader::Load (JavaVM * jvm_, char const* filename){
 
 JNIEnv * curEnv = NULL;
 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
@@ -160,15 +164,88 @@ if (jintLoadjstringjava_lang_StringID == NULL) {
 throw GiwsException::JniMethodNotFoundException(curEnv, "Load");
 }
 
-jstring xmlFile_ = curEnv->NewStringUTF( xmlFile );
-if (xmlFile != NULL && xmlFile_ == NULL)
+jstring filename_ = curEnv->NewStringUTF( filename );
+if (filename != NULL && filename_ == NULL)
 {
 throw GiwsException::JniBadAllocException(curEnv);
 }
 
 
-                        jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintLoadjstringjava_lang_StringID ,xmlFile_));
-                        curEnv->DeleteLocalRef(xmlFile_);
+                        jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintLoadjstringjava_lang_StringID ,filename_));
+                        curEnv->DeleteLocalRef(filename_);
+if (curEnv->ExceptionCheck()) {
+throw GiwsException::JniCallMethodException(curEnv);
+}
+return res;
+
+}
+
+char* CallXmlLoader::Save (JavaVM * jvm_, int figure, char const* filename){
+
+JNIEnv * curEnv = NULL;
+jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+jclass cls = initClass(curEnv);
+if ( cls == NULL) {
+throw GiwsException::JniCallMethodException(curEnv);
+}
+
+static jmethodID jstringSavejintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "Save", "(ILjava/lang/String;)Ljava/lang/String;" ) ;
+if (jstringSavejintintjstringjava_lang_StringID == NULL) {
+throw GiwsException::JniMethodNotFoundException(curEnv, "Save");
+}
+
+jstring filename_ = curEnv->NewStringUTF( filename );
+if (filename != NULL && filename_ == NULL)
+{
+throw GiwsException::JniBadAllocException(curEnv);
+}
+
+
+                        jstring res =  static_cast<jstring>( curEnv->CallStaticObjectMethod(cls, jstringSavejintintjstringjava_lang_StringID ,figure, filename_));
+                        if (curEnv->ExceptionCheck()) {
+throw GiwsException::JniCallMethodException(curEnv);
+}if (res != NULL) { 
+
+const char *tempString = curEnv->GetStringUTFChars(res, 0);
+char * myStringBuffer = new char[strlen(tempString) + 1];
+strcpy(myStringBuffer, tempString);
+curEnv->ReleaseStringUTFChars(res, tempString);
+curEnv->DeleteLocalRef(res);
+curEnv->DeleteLocalRef(filename_);
+if (curEnv->ExceptionCheck()) {
+delete[] myStringBuffer;
+                                throw GiwsException::JniCallMethodException(curEnv);
+}
+return myStringBuffer;
+ } else { 
+curEnv->DeleteLocalRef(res);
+return NULL;
+}
+}
+
+int CallXmlLoader::DomLoad (JavaVM * jvm_, char const* filename){
+
+JNIEnv * curEnv = NULL;
+jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+jclass cls = initClass(curEnv);
+if ( cls == NULL) {
+throw GiwsException::JniCallMethodException(curEnv);
+}
+
+static jmethodID jintDomLoadjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "DomLoad", "(Ljava/lang/String;)I" ) ;
+if (jintDomLoadjstringjava_lang_StringID == NULL) {
+throw GiwsException::JniMethodNotFoundException(curEnv, "DomLoad");
+}
+
+jstring filename_ = curEnv->NewStringUTF( filename );
+if (filename != NULL && filename_ == NULL)
+{
+throw GiwsException::JniBadAllocException(curEnv);
+}
+
+
+                        jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintDomLoadjstringjava_lang_StringID ,filename_));
+                        curEnv->DeleteLocalRef(filename_);
 if (curEnv->ExceptionCheck()) {
 throw GiwsException::JniCallMethodException(curEnv);
 }
index 3dc97e5..fad4c11 100644 (file)
@@ -77,6 +77,8 @@ JavaVM * jvm;
 
 protected:
 jmethodID jintLoadjstringjava_lang_StringID; // cache method id
+jmethodID jstringSavejintintjstringjava_lang_StringID; // cache method id
+jmethodID jintDomLoadjstringjava_lang_StringID; // cache method id
 
 
 
@@ -136,7 +138,11 @@ void synchronize();
 void endSynchronize();
 
 // Methods
-static int Load(JavaVM * jvm_, char const* xmlFile);
+static int Load(JavaVM * jvm_, char const* filename);
+
+static char* Save(JavaVM * jvm_, int figure, char const* filename);
+
+static int DomLoad(JavaVM * jvm_, char const* filename);
 
 
                         /**
index 11644d0..8240309 100644 (file)
@@ -2,7 +2,14 @@
 <package name="org.scilab.modules.graphic_objects">
     <object name="CallXmlLoader">
         <method name="Load" returnType="int" modifier="static">
-            <parameter name="xmlFile" type="String"/>
+            <parameter name="filename" type="String"/>
+        </method>
+        <method name="Save" returnType="String" modifier="static">
+            <parameter name="figure" type="int"/>
+            <parameter name="filename" type="String"/>
+        </method>
+        <method name="DomLoad" returnType="int" modifier="static">
+            <parameter name="filename" type="String"/>
         </method>
     </object>
     <object name="CallGraphicController">
index df9bf69..94eea8b 100755 (executable)
@@ -399,6 +399,7 @@ __GO_UI_GRIDBAG_WEIGHT__
 __GO_UI_GRIDBAG_FILL__
 __GO_UI_GRIDBAG_ANCHOR__
 __GO_UI_GRIDBAG_PADDING__
+__GO_UI_GRIDBAG_PREFERREDSIZE__
 
 __GO_UI_GRID_GRID__
 __GO_UI_GRID_PADDING__
index 35b767b..e168ee8 100644 (file)
@@ -7,9 +7,10 @@
 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 function %GridBagC_p(t)
     printf("GridBag Layout\n");
-    printf("  Grid    : %s\n", sci2exp(t.grid));
-    printf("  Weight  : %s\n", sci2exp(t.weight));
-    printf("  Fill    : %s\n", sci2exp(t.fill));
-    printf("  Anchor  : %s\n", sci2exp(t.anchor));
-    printf("  Padding : %s\n", sci2exp(t.padding));
+    printf("  Grid          : %s\n", sci2exp(t.grid));
+    printf("  Weight        : %s\n", sci2exp(t.weight));
+    printf("  Fill          : %s\n", sci2exp(t.fill));
+    printf("  Anchor        : %s\n", sci2exp(t.anchor));
+    printf("  Padding       : %s\n", sci2exp(t.padding));
+    printf("  PreferredSize : %s\n", sci2exp(t.preferredsize));
 endfunction
index 12a194d..02b4587 100644 (file)
@@ -40,9 +40,10 @@ function ret = createConstraints(constType, varargin)
         arg3 = "none";
         arg4 = "center";
         arg5 = [0 0];
+        arg6 = [-1 -1];
 
-        if size(varargin) <> [1:5] then
-            error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."), "createConstraints", 1, 6));
+        if size(varargin) <> [1:6] then
+            error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."), "createConstraints", 2, 7));
         end
 
         arg1 = varargin(1);
@@ -78,7 +79,14 @@ function ret = createConstraints(constType, varargin)
             end
         end
 
-        ret = tlist(["GridBagConstraints","grid","weight","fill","anchor","padding"], arg1, arg2, arg3, arg4, arg5);
+        if size(varargin) > 5 then
+            arg6 = varargin(6);
+            if typeof(arg6) <> "constant" | size(arg6, "*") <> 2 then
+                error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createConstraints", 7));
+            end
+        end
+
+        ret = tlist(["GridBagConstraints","grid","weight","fill","anchor","padding","preferredsize"], arg1, arg2, arg3, arg4, arg5, arg6);
     else
         error(999, msprintf(_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "createConstraints", 1, "none/nolayout, border, grid, gridbag"));
     end
index c7452d5..a3546ee 100644 (file)
@@ -180,6 +180,7 @@ int sci_set(char *fname, unsigned long fname_len)
                     }
                     iRows2 = (int)strlen((char*)pvData);
                     iCols2 = 1;
+                    isMatrixOfString = 0;
                 }
                 break;
         }
@@ -388,6 +389,7 @@ int sci_set(char *fname, unsigned long fname_len)
                         }
                         iRows3 = (int)strlen((char*)pvData);
                         iCols3 = 1;
+                        isMatrixOfString = 0;
                     }
                     else
                     {
index 4b01ada..8ad9362 100644 (file)
@@ -107,8 +107,8 @@ int get_constraints_property(void* _pvCtx, int iObjUID)
         break;
         case LAYOUT_GRIDBAG :
         {
-            char * variable_tlist[] = {"GridBagConstraints", "grid", "weight", "fill", "anchor", "padding"};
-            returnedList * tList = createReturnedList(5, variable_tlist);
+            char * variable_tlist[] = {"GridBagConstraints", "grid", "weight", "fill", "anchor", "padding", "preferredsize"};
+            returnedList * tList = createReturnedList(6, variable_tlist);
             int* piGrid = NULL;
             double pdblGrid[4];
             double* pdblWeight = NULL;
@@ -121,6 +121,9 @@ int get_constraints_property(void* _pvCtx, int iObjUID)
             double pdblPadding[2];
             int* piPadding = NULL;
 
+            double pdblPreferredSize[2];
+            int* piPreferredSize = NULL;
+
             getGraphicObjectProperty(iObjUID, __GO_UI_GRIDBAG_GRID__, jni_int_vector, (void **)&piGrid);
             if (piGrid == NULL)
             {
@@ -156,6 +159,13 @@ int get_constraints_property(void* _pvCtx, int iObjUID)
                 return -1;
             }
 
+            getGraphicObjectProperty(iObjUID, __GO_UI_GRIDBAG_PREFERREDSIZE__, jni_int_vector, (void **)&piPreferredSize);
+            if (piPreferredSize == NULL)
+            {
+                Scierror(999, _("'%s' property does not exist for this handle.\n"), "constraints");
+                return -1;
+            }
+
             //convert to double
             pdblGrid[0] = (double)piGrid[0];
             pdblGrid[1] = (double)piGrid[1];
@@ -165,6 +175,9 @@ int get_constraints_property(void* _pvCtx, int iObjUID)
             pdblPadding[0] = (double)piPadding[0];
             pdblPadding[1] = (double)piPadding[1];
 
+            pdblPreferredSize[0] = (double)piPreferredSize[0];
+            pdblPreferredSize[1] = (double)piPreferredSize[1];
+
             addRowVectorToReturnedList(tList, pdblGrid, 4);
             addRowVectorToReturnedList(tList, pdblWeight, 2);
 
@@ -218,6 +231,7 @@ int get_constraints_property(void* _pvCtx, int iObjUID)
             }
 
             addRowVectorToReturnedList(tList, pdblPadding, 2);
+            addRowVectorToReturnedList(tList, pdblPreferredSize, 2);
             destroyReturnedList(tList);
         }
         break;
index a710771..9209c20 100644 (file)
@@ -132,6 +132,7 @@ int set_constraints_property(void* _pvCtx, int iObjUID, void* _pvData, int value
             //arg4 -> string -> int enum
             //arg5 -> string -> int enum
             //arg6 -> double 1x2 -> int 1*2
+            //arg7 -> double 1x2 -> int 1*2
 
             int* piAddr2 = NULL;
             int iRows2 = 0;
@@ -158,6 +159,12 @@ int set_constraints_property(void* _pvCtx, int iObjUID, void* _pvData, int value
             double* pdblPadding = NULL;
             int piPadding[2];
 
+            int* piAddr7 = NULL;
+            int iRows7 = 0;
+            int iCols7 = 0;
+            double* pdblPreferredSize = NULL;
+            int piPreferredSize[2];
+
             sciErr = getListItemAddress(_pvCtx, piAddrList, 2, &piAddr2);
             if (sciErr.iErr)
             {
@@ -288,6 +295,18 @@ int set_constraints_property(void* _pvCtx, int iObjUID, void* _pvData, int value
                 return SET_PROPERTY_ERROR;
             }
 
+            sciErr = getListItemAddress(_pvCtx, piAddrList, 7, &piAddr7);
+            if (sciErr.iErr)
+            {
+                return SET_PROPERTY_ERROR;
+            }
+
+            sciErr = getMatrixOfDouble(_pvCtx, piAddr7, &iRows7, &iCols7, &pdblPreferredSize);
+            if (sciErr.iErr)
+            {
+                return SET_PROPERTY_ERROR;
+            }
+
             //reassign double values in int[]
             piGrid[0] = (int)pdblGrid[0];
             piGrid[1] = (int)pdblGrid[1];
@@ -297,11 +316,15 @@ int set_constraints_property(void* _pvCtx, int iObjUID, void* _pvData, int value
             piPadding[0] = (int)pdblPadding[0];
             piPadding[1] = (int)pdblPadding[1];
 
+            piPreferredSize[0] = (int)pdblPreferredSize[0];
+            piPreferredSize[1] = (int)pdblPreferredSize[1];
+
             setGraphicObjectProperty(iObjUID, __GO_UI_GRIDBAG_GRID__, piGrid, jni_int_vector, 4);
             setGraphicObjectProperty(iObjUID, __GO_UI_GRIDBAG_WEIGHT__, pdblWeight, jni_double_vector, 2);
             setGraphicObjectProperty(iObjUID, __GO_UI_GRIDBAG_FILL__, &iFill, jni_int, 1);
             setGraphicObjectProperty(iObjUID, __GO_UI_GRIDBAG_ANCHOR__, &iAnchor, jni_int, 1);
             setGraphicObjectProperty(iObjUID, __GO_UI_GRIDBAG_PADDING__, piPadding, jni_int_vector, 2);
+            setGraphicObjectProperty(iObjUID, __GO_UI_GRIDBAG_PREFERREDSIZE__, piPreferredSize, jni_int_vector, 2);
         }
         else
         {
index 27b40fe..693083b 100755 (executable)
@@ -217,7 +217,9 @@ sci_gateway/cpp/sci_datatipmove.cpp \
 sci_gateway/cpp/sci_datatip_set_style.cpp \
 sci_gateway/cpp/sci_datatip_set_display.cpp \
 sci_gateway/cpp/sci_datatip_set_interp.cpp \
-sci_gateway/cpp/sci_datatip_set_orient.cpp
+sci_gateway/cpp/sci_datatip_set_orient.cpp \
+sci_gateway/cpp/sci_saveGui.cpp \
+sci_gateway/cpp/sci_loadGui.cpp
 
 libscigui_la_CPPFLAGS = \
                        -I$(srcdir)/includes/ \
index e9dbb70..b04c3c0 100644 (file)
@@ -330,7 +330,9 @@ am__objects_5 = sci_gateway/cpp/libscigui_la-sci_printsetupbox.lo \
        sci_gateway/cpp/libscigui_la-sci_datatip_set_style.lo \
        sci_gateway/cpp/libscigui_la-sci_datatip_set_display.lo \
        sci_gateway/cpp/libscigui_la-sci_datatip_set_interp.lo \
-       sci_gateway/cpp/libscigui_la-sci_datatip_set_orient.lo
+       sci_gateway/cpp/libscigui_la-sci_datatip_set_orient.lo \
+       sci_gateway/cpp/libscigui_la-sci_saveGui.lo \
+       sci_gateway/cpp/libscigui_la-sci_loadGui.lo
 am_libscigui_la_OBJECTS = $(am__objects_4) $(am__objects_5)
 libscigui_la_OBJECTS = $(am_libscigui_la_OBJECTS)
 @GUI_TRUE@am_libscigui_la_rpath = -rpath $(pkglibdir)
@@ -884,7 +886,9 @@ sci_gateway/cpp/sci_datatipmove.cpp \
 sci_gateway/cpp/sci_datatip_set_style.cpp \
 sci_gateway/cpp/sci_datatip_set_display.cpp \
 sci_gateway/cpp/sci_datatip_set_interp.cpp \
-sci_gateway/cpp/sci_datatip_set_orient.cpp
+sci_gateway/cpp/sci_datatip_set_orient.cpp \
+sci_gateway/cpp/sci_saveGui.cpp \
+sci_gateway/cpp/sci_loadGui.cpp
 
 libscigui_la_CPPFLAGS = \
                        -I$(srcdir)/includes/ \
@@ -1607,6 +1611,12 @@ sci_gateway/cpp/libscigui_la-sci_datatip_set_interp.lo:  \
 sci_gateway/cpp/libscigui_la-sci_datatip_set_orient.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscigui_la-sci_saveGui.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscigui_la-sci_loadGui.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libscigui.la: $(libscigui_la_OBJECTS) $(libscigui_la_DEPENDENCIES) $(EXTRA_libscigui_la_DEPENDENCIES) 
        $(AM_V_CXXLD)$(CXXLINK) $(am_libscigui_la_rpath) $(libscigui_la_OBJECTS) $(libscigui_la_LIBADD) $(LIBS)
@@ -1668,11 +1678,13 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_fire_closing_finished.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_getinstalledlookandfeels.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_getlookandfeel.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_loadGui.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_openged.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_plotbrowser.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_printfigure.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_printsetupbox.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_raise_window.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_saveGui.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_setlookandfeel.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_toprint.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_uigetdir.Plo@am__quote@
@@ -2822,6 +2834,20 @@ sci_gateway/cpp/libscigui_la-sci_datatip_set_orient.lo: sci_gateway/cpp/sci_data
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigui_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscigui_la-sci_datatip_set_orient.lo `test -f 'sci_gateway/cpp/sci_datatip_set_orient.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_datatip_set_orient.cpp
 
+sci_gateway/cpp/libscigui_la-sci_saveGui.lo: sci_gateway/cpp/sci_saveGui.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigui_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscigui_la-sci_saveGui.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_saveGui.Tpo -c -o sci_gateway/cpp/libscigui_la-sci_saveGui.lo `test -f 'sci_gateway/cpp/sci_saveGui.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_saveGui.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_saveGui.Tpo sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_saveGui.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_saveGui.cpp' object='sci_gateway/cpp/libscigui_la-sci_saveGui.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigui_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscigui_la-sci_saveGui.lo `test -f 'sci_gateway/cpp/sci_saveGui.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_saveGui.cpp
+
+sci_gateway/cpp/libscigui_la-sci_loadGui.lo: sci_gateway/cpp/sci_loadGui.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigui_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscigui_la-sci_loadGui.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_loadGui.Tpo -c -o sci_gateway/cpp/libscigui_la-sci_loadGui.lo `test -f 'sci_gateway/cpp/sci_loadGui.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_loadGui.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_loadGui.Tpo sci_gateway/cpp/$(DEPDIR)/libscigui_la-sci_loadGui.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_loadGui.cpp' object='sci_gateway/cpp/libscigui_la-sci_loadGui.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigui_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscigui_la-sci_loadGui.lo `test -f 'sci_gateway/cpp/sci_loadGui.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_loadGui.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index 004669f..10d14a4 100755 (executable)
@@ -67,6 +67,8 @@ GUI_IMPEXP int sci_datatip_set_display(char *fname, unsigned long fname_len);
 GUI_IMPEXP int sci_datatip_set_interp(char *fname, unsigned long fname_len);
 GUI_IMPEXP int sci_datatip_set_orient(char *fname, unsigned long fname_len);
 GUI_IMPEXP int sci_figure(char *fname, unsigned long fname_len);
+GUI_IMPEXP int sci_saveGui(char *fname, unsigned long fname_len);
+GUI_IMPEXP int sci_loadGui(char *fname, unsigned long fname_len);
 /*--------------------------------------------------------------------------*/
 #endif /*  __GW_GUI__ */
 /*--------------------------------------------------------------------------*/
index 01ba4df..43cae8a 100755 (executable)
@@ -11,6 +11,7 @@
  *
  */
 
+#include <stdio.h>
 #include <string.h>
 #include "gw_gui.h"
 #include "api_scilab.h"
@@ -74,7 +75,9 @@ static gw_generic_table Tab[] =
     {sci_datatip_set_display, "datatipSetDisplay"},
     {sci_datatip_set_interp, "datatipSetInterp"},
     {sci_datatip_set_orient, "datatipSetOrientation"},
-    {sci_figure, "figure"}
+    {sci_figure, "figure"},
+    {sci_saveGui, "saveGui"},
+    {sci_loadGui, "loadGui"}
 };
 /*--------------------------------------------------------------------------*/
 int gw_gui(void)
@@ -99,6 +102,7 @@ int gw_gui(void)
     if (!loadedDep && (strcmp(Tab[Fin - 1].name, "uicontrol") == 0
                        || strcmp(Tab[Fin - 1].name, "uimenu") == 0
                        || strcmp(Tab[Fin - 1].name, "usecanvas") == 0
+                       || strcmp(Tab[Fin - 1].name, "loadGui") == 0
                        || strcmp(Tab[Fin - 1].name, "figure") == 0))
     {
         loadOnUseClassPath("graphics");
diff --git a/scilab/modules/gui/sci_gateway/cpp/sci_loadGui.cpp b/scilab/modules/gui/sci_gateway/cpp/sci_loadGui.cpp
new file mode 100644 (file)
index 0000000..22323e3
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+extern "C" {
+#include "gw_gui.h"
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "createGraphicObject.h"
+#include "getGraphicObjectProperty.h"
+#include "graphicObjectProperties.h"
+#include "HandleManagement.h"
+}
+
+int sci_loadGui(char *fname, unsigned long fname_len)
+{
+    SciErr sciErr;
+    int* piAddr = NULL;
+    char* pstFile = NULL;
+
+    int iRhs = nbInputArgument(pvApiCtx);
+
+    CheckInputArgument(pvApiCtx, 1, 1);
+    CheckOutputArgument(pvApiCtx, 1, 1);
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 1;
+    }
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 1;
+    }
+
+    if (isStringType(pvApiCtx, piAddr) == 0 || isScalar(pvApiCtx, piAddr) == 0)
+    {
+        Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 1);
+        return 1;
+    }
+
+
+    if (getAllocatedSingleString(pvApiCtx, piAddr, &pstFile))
+    {
+        if (pstFile)
+        {
+            freeAllocatedSingleString(pstFile);
+        }
+
+        Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 2);
+        return 1;
+    }
+
+    int iFig = xmldomload(pstFile);
+    if (iFig < 1)
+    {
+        Scierror(999, _("%s: can not read file %s.\n"), fname, pstFile);
+        freeAllocatedSingleString(pstFile);
+        return 0;
+    }
+
+    freeAllocatedSingleString(pstFile);
+
+    long long h = (long long)getHandle(iFig);
+    createScalarHandle(pvApiCtx, iRhs + 1, h);
+    AssignOutputVariable(pvApiCtx, 1) = iRhs + 1;
+    ReturnArguments(pvApiCtx);
+    return 0;
+}
\ No newline at end of file
diff --git a/scilab/modules/gui/sci_gateway/cpp/sci_saveGui.cpp b/scilab/modules/gui/sci_gateway/cpp/sci_saveGui.cpp
new file mode 100644 (file)
index 0000000..e3fe921
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+extern "C" {
+#include "gw_gui.h"
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "createGraphicObject.h"
+#include "getGraphicObjectProperty.h"
+#include "graphicObjectProperties.h"
+#include "HandleManagement.h"
+}
+
+int sci_saveGui(char *fname, unsigned long fname_len)
+{
+    SciErr sciErr;
+    int* piAddr1 = NULL;
+    long long hFig = 0;
+    int iFig = 0;
+
+    int iType = 0;
+    int* piType = &iType;
+    int* piAddr2 = NULL;
+    char* pstFile = NULL;
+
+    int iRhs = nbInputArgument(pvApiCtx);
+
+    CheckInputArgument(pvApiCtx, 2, 2);
+    CheckOutputArgument(pvApiCtx, 1, 1);
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 1;
+    }
+
+    if (isHandleType(pvApiCtx, piAddr1) == 0 || isScalar(pvApiCtx, piAddr1) == 0)
+    {
+        Scierror(999, _("%s: Wrong size for input argument #%d: A single handle expected.\n"), fname, 1);
+        return 1;
+    }
+
+    if (getScalarHandle(pvApiCtx, piAddr1, &hFig))
+    {
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 1;
+    }
+
+    iFig = getObjectFromHandle((long)hFig);
+    if (iFig == 0)
+    {
+        Scierror(999, _("%s: The handle is not or no more valid.\n"), fname);
+        return 0;
+    }
+
+    getGraphicObjectProperty(iFig, __GO_TYPE__, jni_int, (void**)&piType);
+    if (piType == NULL || iType != __GO_FIGURE__)
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: Figure handle expected.\n"), fname, 1);
+        return 1;
+    }
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 1;
+    }
+
+    if (isStringType(pvApiCtx, piAddr2) == 0 || isScalar(pvApiCtx, piAddr2) == 0)
+    {
+        Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 1);
+        return 1;
+    }
+
+
+    if (getAllocatedSingleString(pvApiCtx, piAddr2, &pstFile))
+    {
+        if (pstFile)
+        {
+            freeAllocatedSingleString(pstFile);
+        }
+
+        Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 2);
+        return 1;
+    }
+
+    char* ret = xmlsave(iFig, pstFile);
+    freeAllocatedSingleString(pstFile);
+
+    if (ret[0] != '\0')
+    {
+        Scierror(202, _("%s: %s.\n"), fname, ret);
+        free(ret);
+        return 1;
+    }
+
+    free(ret);
+    createScalarBoolean(pvApiCtx, iRhs + 1, 1);
+    AssignOutputVariable(pvApiCtx, 1) = iRhs + 1;
+    ReturnArguments(pvApiCtx);
+    return 0;
+}
\ No newline at end of file
index d8dd2df..79f4bec 100644 (file)
@@ -81,4 +81,6 @@
     <PRIMITIVE gatewayId="25" primitiveId="48" primitiveName="datatipSetInterp" />
     <PRIMITIVE gatewayId="25" primitiveId="49" primitiveName="datatipSetOrientation" />
     <PRIMITIVE gatewayId="25" primitiveId="50" primitiveName="figure"/>
+    <PRIMITIVE gatewayId="25" primitiveId="51" primitiveName="saveGui"/>
+    <PRIMITIVE gatewayId="25" primitiveId="52" primitiveName="loadGui"/>
 </GATEWAY>
index 9ad6b1c..9d48ab2 100755 (executable)
     <ClCompile Include="..\..\sci_gateway\cpp\sci_datatip_set_style.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_datatip_toggle.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_datatip_manager_mode.cpp" />
+    <ClCompile Include="..\..\sci_gateway\cpp\sci_loadGui.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_plotbrowser.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_useeditor.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_fire_closing_finished.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_openged.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_datatipcreate.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_datatipremove.cpp" />
+    <ClCompile Include="..\..\sci_gateway\cpp\sci_saveGui.cpp" />
     <ClCompile Include="..\cpp\CreateUIControl.cpp" />
     <ClCompile Include="..\cpp\GetConsoleShowHiddenHandles.cpp" />
     <ClCompile Include="..\cpp\GetUicontrolIcon.cpp" />
index 37e1455..d2bbf36 100755 (executable)
     <ClCompile Include="..\..\sci_gateway\cpp\sci_datatip_toggle.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\sci_gateway\cpp\sci_saveGui.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="..\jni\DatatipDrag.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="..\cpp\CreateUIControl.cpp">
       <Filter>Header Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\sci_gateway\cpp\sci_loadGui.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <None Include="core_import.def">
index 19b6323..da49d85 100644 (file)
@@ -472,6 +472,10 @@ public final class SwingViewWidget {
                         uiControl.setText(((String[]) value)[0]);
                         ((SwingScilabEditBox) uiControl).setMultiLineText(false);
                     }
+                } else if (uiControl instanceof SwingScilabLayer) {
+                    SwingScilabLayer layer = (SwingScilabLayer)uiControl;
+                    //if intValue[0] is out of bounds, do not update view but let "wrong" value in model
+                    layer.setActiveLayerFromName(((String[]) value)[0]);
                 } else {
                     uiControl.setText(((String[]) value)[0]);
                 }
index 46c0955..c41c2d2 100644 (file)
 
 package org.scilab.modules.gui.bridge.editbox;
 
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_MAX__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_STRING__;
 
 import java.awt.Color;
+import java.awt.Dimension;
 import java.awt.Font;
+import java.awt.Graphics;
 import java.awt.event.ActionEvent;
 import java.awt.event.FocusEvent;
 import java.awt.event.FocusListener;
 import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
 
 import javax.swing.AbstractAction;
 import javax.swing.InputMap;
 import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
 import javax.swing.JTextPane;
 import javax.swing.KeyStroke;
 import javax.swing.ScrollPaneConstants;
@@ -68,7 +71,7 @@ import org.scilab.modules.gui.utils.Size;
  */
 public class SwingScilabEditBox extends JScrollPane implements SwingViewObject, SimpleEditBox {
 
-    private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 2048261239598753717L;
 
     private Integer uid;
 
@@ -83,7 +86,7 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
 
     private Object enterKeyAction;
     private Object tabKeyAction;
-    
+
     private class EditBoxView extends BoxView {
         public EditBoxView(Element elem, int axis) {
             super(elem, axis);
@@ -118,6 +121,8 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
     }
 
     private class EditBoxEditorKit extends StyledEditorKit {
+        private static final long serialVersionUID = -3293325523458217074L;
+
         public ViewFactory getViewFactory() {
             return new ViewFactory() {
                 public View create(Element elem) {
@@ -168,7 +173,7 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
         InputMap map = textPane.getInputMap();
         enterKeyAction = map.get(enterKey);
         tabKeyAction = map.get(tabKey);
-        
+
         if (Console.getConsole().getUseDeprecatedLF() == false) {
             setEditFont(getFont());
         }
@@ -189,7 +194,7 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
             }
         }
     }
-    
+
     /**
      * Draws a swing Scilab EditBox
      * @see org.scilab.modules.gui.uielement.UIElement#draw()
@@ -209,7 +214,8 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
     }
 
     /**
-     * Gets the position (X-coordinate and Y-coordinate) of a swing Scilab EditBox
+     * Gets the position (X-coordinate and Y-coordinate) of a swing Scilab
+     * EditBox
      * @return the position of the EditBox
      * @see org.scilab.modules.gui.uielement.UIElement#getPosition()
      */
@@ -227,7 +233,8 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
     }
 
     /**
-     * Sets the position (X-coordinate and Y-coordinate) of a swing Scilab EditBox
+     * Sets the position (X-coordinate and Y-coordinate) of a swing Scilab
+     * EditBox
      * @param newPosition the position we want to set to the EditBox
      * @see org.scilab.modules.gui.uielement.UIElement#setPosition(org.scilab.modules.gui.utils.Position)
      */
@@ -277,7 +284,10 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
         /* (Des)Activate the callback */
         if (callback != null) {
             if (status) {
-                removeFocusListener(focusListener); /* To be sure the callback is not added two times */
+                removeFocusListener(focusListener); /*
+                                                     * To be sure the callback
+                                                     * is not added two times
+                                                     */
                 //removeActionListener(actionListener); /* To be sure the callback is not added two times */
                 addFocusListener(focusListener);
                 //addActionListener(actionListener);
@@ -438,7 +448,29 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
      * @param value property value
      */
     public void update(int property, Object value) {
-        SwingViewWidget.update(this, property, value);
+        switch (property) {
+            case __GO_UI_MAX__ : {
+                Double columns = (Double)value;
+                Graphics g = textPane.getGraphics();
+                Integer width = 50;
+                if (g != null) {
+                    width = textPane.getGraphics().getFontMetrics(textPane.getFont()).charWidth('m');
+                }
+                Integer totalWidth = columns.intValue() * width;
+                Dimension current = textPane.getPreferredSize();
+                System.out.println("current : " + current.toString());
+                current.width = totalWidth;
+                textPane.setPreferredSize(current);
+                current = textPane.getPreferredSize();
+                System.out.println("new : " + current.toString());
+                break;
+            }
+
+            default : {
+                SwingViewWidget.update(this, property, value);
+                break;
+            }
+        }
     }
 
     public String getText() {
@@ -457,6 +489,8 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
         } else {
             setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
             AbstractAction validateUserInput = new AbstractAction() {
+                private static final long serialVersionUID = -5286137769378297783L;
+
                 public void actionPerformed(ActionEvent e) {
                     validateUserInput();
                 }
@@ -469,7 +503,7 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
     }
 
     public void resetBackground() {
-        Color color = (Color)UIManager.getLookAndFeelDefaults().get("TextField.background");
+        Color color = (Color) UIManager.getLookAndFeelDefaults().get("TextField.background");
         if (color != null) {
             setBackground(color);
         }
index 09187cf..3ad4379 100644 (file)
@@ -22,6 +22,7 @@ import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Container;
+import java.awt.Dimension;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.GridLayout;
@@ -269,6 +270,11 @@ public class SwingScilabFrame extends JPanel implements SwingViewObject, SimpleF
             constraints.ipadx = padding[0];
             constraints.ipady = padding[1];
 
+            Integer[] preferredSize = uicontrol.getGridBagPreferredSize();
+            if (preferredSize[0].equals(-1) == false && preferredSize[1].equals(-1) == false) {
+                ((Component) member).setPreferredSize(new Dimension(preferredSize[0], preferredSize[1]));
+            }
+
             add((Component) member, constraints);
             revalidate();
         } else if (getLayout() instanceof GridLayout) {
index 70317ed..a76a7a7 100644 (file)
@@ -4,6 +4,7 @@ package org.scilab.modules.gui.bridge.frame;
 
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_VALUE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_VISIBLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TAG__;
 
 import java.awt.CardLayout;
 import java.awt.Component;
@@ -14,38 +15,35 @@ import org.scilab.modules.gui.SwingViewObject;
 
 public class SwingScilabLayer extends SwingScilabFrame {
     private static final long serialVersionUID = 9038916804095320758L;
-    private ArrayList<String> layerName = new ArrayList<String>();
-    private CardLayout layout = new CardLayout();
+    private ArrayList<Integer> layers = new ArrayList<Integer>();
 
     public SwingScilabLayer() {
         super();
-        setLayout(layout);
+        setLayout(new CardLayout());
     }
 
     public void addMember(SwingScilabFrame member) {
         String name = member.getId().toString();
         member.setName(name);
-        layerName.add(name);
+        layers.add(member.getId());
         add(member, name);
         revalidate();
         //active the first child
         if (getActiveLayer() == -1) {
             setActiveLayer(1);
         }
-
     }
 
     public void addMember(SwingScilabScrollableFrame member) {
         String name = member.getId().toString();
         member.setName(name);
-        layerName.add(name);
+        layers.add(member.getId());
         add(member, name);
         revalidate();
         //active the first child
         if (getActiveLayer() == -1) {
             setActiveLayer(1);
         }
-
     }
 
     public Integer getActiveLayer() {
@@ -62,7 +60,7 @@ public class SwingScilabLayer extends SwingScilabFrame {
             return -1;
         }
 
-        return layerName.indexOf(card.getName()) + 1;
+        return layers.indexOf(Integer.parseInt(card.getName())) + 1;
     }
 
     private Component getLayerFromIndex(Integer layer) {
@@ -99,7 +97,7 @@ public class SwingScilabLayer extends SwingScilabFrame {
 
 
     public void removeMember(SwingScilabScrollableFrame member) {
-        layerName.remove(member.getId().toString());
+        layers.remove(member.getId());
         remove(member);
         revalidate();
 
@@ -116,7 +114,7 @@ public class SwingScilabLayer extends SwingScilabFrame {
     }
 
     public void removeMember(SwingScilabFrame member) {
-        layerName.remove(member.getId().toString());
+        layers.remove(member.getId());
         remove(member);
         revalidate();
 
@@ -133,12 +131,12 @@ public class SwingScilabLayer extends SwingScilabFrame {
     }
 
     public boolean setActiveLayer(Integer layerPos) {
-        if (layerPos < 1 || layerPos > layerName.size()) {
+        if (layerPos < 1 || layerPos > layers.size()) {
             return false;
         }
 
         Integer previous = getActiveLayer();
-        if (setActiveLayer(layerName.get(layerPos - 1)) == false) {
+        if (setActiveLayer(layers.get(layerPos - 1).toString()) == false) {
             return false;
         }
 
@@ -149,14 +147,24 @@ public class SwingScilabLayer extends SwingScilabFrame {
 
     private boolean setActiveLayer(String layer) {
         //check existing item
-        if (layerName.contains(layer)) {
-            layout.show(this, layer);
-            return true;
-        } else {
-            return false;
-        }
+        ((CardLayout)getLayout()).show(this, layer);
+        return true;
     }
 
+    public boolean setActiveLayerFromName(String name) {
+
+        //get layer's name from property "string"
+        GraphicController controller = GraphicController.getController();
+
+        for (int i = 0 ; i < layers.size() ; i++) {
+            String string = (String)controller.getProperty(layers.get(i), __GO_TAG__);
+            if (string.equals(name)) {
+                return setActiveLayer(i + 1);
+            }
+        }
+
+        return false;
+    }
     private void updateChildrenVisible(Integer previous, Integer next) {
         SwingViewObject previousFrame = (SwingViewObject)getLayerFromIndex(previous);
         SwingViewObject nextFrame = (SwingViewObject) getLayerFromIndex(next);
index a1a511b..5bc32b0 100644 (file)
@@ -21,6 +21,7 @@ import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Container;
+import java.awt.Dimension;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.GridLayout;
@@ -76,7 +77,6 @@ public class SwingScilabScrollableFrame extends JScrollPane implements SwingView
     public SwingScilabScrollableFrame() {
         super();
         setViewportView(panel);
-        // the Default layout is null so we have to set a Position and a Size of every Dockable we add to it
         panel.setLayout(null);
         setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
         setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
@@ -232,6 +232,11 @@ public class SwingScilabScrollableFrame extends JScrollPane implements SwingView
             constraints.ipadx = padding[0];
             constraints.ipady = padding[1];
 
+            Integer[] preferredSize = uicontrol.getGridBagPreferredSize();
+            if (preferredSize[0].equals(-1) == false && preferredSize[1].equals(-1) == false) {
+                ((Component) member).setPreferredSize(new Dimension(preferredSize[0], preferredSize[1]));
+            }
+
             panel.add((Component) member, constraints);
             revalidate();
         } else if (getLayout() instanceof GridLayout) {
@@ -246,7 +251,6 @@ public class SwingScilabScrollableFrame extends JScrollPane implements SwingView
 
         SwingScilabPanel win = (SwingScilabPanel)SwingUtilities.getAncestorOfClass(SwingScilabPanel.class, this);
         if (win != null) {
-            System.out.println("add member pack pack");
             SwingScilabWindow parentWindow = SwingScilabWindow.allScilabWindows.get(win.getParentWindowId());
             parentWindow.pack();
         }
index 81fda96..282198a 100644 (file)
@@ -72,7 +72,10 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
 
     private boolean isJLabel = true;
 
-    private String horizontalAlignment = "left"; /* Horizontal alignment property */
+    private String horizontalAlignment = "left"; /*
+                                                  * Horizontal alignment
+                                                  * property
+                                                  */
 
     private String verticalAlignment = "middle"; /* Vertical alignment property */
 
@@ -175,7 +178,8 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
     }
 
     /**
-     * Gets the position (X-coordinate and Y-coordinate) of a swing Scilab element
+     * Gets the position (X-coordinate and Y-coordinate) of a swing Scilab
+     * element
      * @return the position of the element
      * @see org.scilab.modules.gui.uielement.UIElement#getPosition()
      */
@@ -191,11 +195,15 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
     public void setDims(Size newSize) {
         setSize(newSize.getWidth(), newSize.getHeight());
         // Need validate to force alignement to be applyed
+        setMinimumSize(new Dimension(
+                           Math.max((int)label.getMinimumSize().getWidth(), newSize.getWidth()),
+                           (int)label.getMinimumSize().getHeight()));
         validate();
     }
 
     /**
-     * Sets the position (X-coordinate and Y-coordinate) of a swing Scilab element
+     * Sets the position (X-coordinate and Y-coordinate) of a swing Scilab
+     * element
      * @param newPosition the position to set to the element
      * @see org.scilab.modules.gui.uielement.UIElement#setPosition(org.scilab.modules.gui.utils.Position)
      */
@@ -360,9 +368,8 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
     }
 
     /**
-     * Change Label type to switch between JLabel abd JEditorPane
-     * JLabel is quicker on simple text
-     * JEditorPane can enable HyperLinks
+     * Change Label type to switch between JLabel abd JEditorPane JLabel is
+     * quicker on simple text JEditorPane can enable HyperLinks
      * @param isHtmlLabel
      */
     private void changeLabelType(boolean isJLabel) {
@@ -489,11 +496,11 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
      */
     public void update(int property, Object value) {
         switch (property) {
-            case __GO_UI_ICON__ : {
+            case __GO_UI_ICON__: {
                 if (isJLabel) {
-                    File file = new File((String)value);
+                    File file = new File((String) value);
                     if (file.exists() == false) {
-                        String filename = FindIconHelper.findImage((String)value);
+                        String filename = FindIconHelper.findImage((String) value);
                         file = new File(filename);
                     }
 
@@ -507,14 +514,14 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
                 }
                 break;
             }
-            default : {
+            default: {
                 SwingViewWidget.update(this, property, value);
             }
         }
     }
 
     public void resetBackground() {
-        Color color = (Color)UIManager.getLookAndFeelDefaults().get("Label.background");
+        Color color = (Color) UIManager.getLookAndFeelDefaults().get("Label.background");
         if (color != null) {
             setBackground(color);
         }
index c3c35f1..a8b5d95 100644 (file)
@@ -404,6 +404,11 @@ public class SwingScilabCommonPanel {
             constraints.ipadx = padding[0];
             constraints.ipady = padding[1];
 
+            Integer[] preferredSize = uicontrol.getGridBagPreferredSize();
+            if (preferredSize[0].equals(-1) == false && preferredSize[1].equals(-1) == false) {
+                ((Component) member).setPreferredSize(new Dimension(preferredSize[0], preferredSize[1]));
+            }
+
             component.getWidgetPane().add((Component) member, constraints);
             component.getWidgetPane().revalidate();
         } else {
index f3d0903..165d6a3 100644 (file)
@@ -26,7 +26,6 @@ import java.awt.Font;
 import java.lang.reflect.Field;
 
 import javax.swing.BorderFactory;
-import javax.swing.JLabel;
 import javax.swing.UIManager;
 import javax.swing.border.BevelBorder;
 import javax.swing.border.Border;
@@ -51,6 +50,9 @@ public class BorderConvertor {
     public static Border getBorder(Integer borderId) {
         GraphicController controller = GraphicController.getController();
         Integer styleInt = (Integer) controller.getProperty(borderId, __GO_UI_FRAME_BORDER_STYLE__);
+        if (styleInt == null) {
+            controller.getProperty(borderId, __GO_UI_FRAME_BORDER_STYLE__);
+        }
         Border border = null;
 
         FrameBorderType style = FrameBorderType.intToEnum(styleInt);
@@ -248,8 +250,8 @@ public class BorderConvertor {
 
                                 Font defaultFont = UIManager.getFont("Button.font");
                                 Font font = new Font(fontName.equals("") == false ? fontName : defaultFont.getFontName(),
-                                        fontStyle,
-                                        fontSize != 0 ? fontSize : defaultFont.getSize());
+                                                     fontStyle,
+                                                     fontSize != 0 ? fontSize : defaultFont.getSize());
                                 border = BorderFactory.createTitledBorder(border1, title, justify, position, font, getColor(color));
                             } else {
                                 border = BorderFactory.createTitledBorder(border1, title, justify, position);