during clone recursion on frameborder set new uid in parent ( frame or frameborder ) 04/13904/3
Antoine ELIAS [Tue, 4 Mar 2014 21:23:00 +0000 (22:23 +0100)]
Change-Id: Iad64e8520994f1d1c86f093abccbde4e1c5925b0

scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicView/TreeView.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/XMLDomLoader.java
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

index 12716ac..6da3263 100644 (file)
@@ -31,6 +31,7 @@ import javax.swing.tree.TreeSelectionModel;
 import org.scilab.modules.graphic_objects.contouredObject.ContouredObject;
 import org.scilab.modules.graphic_objects.graphicObject.GraphicObject;
 import org.scilab.modules.graphic_objects.uicontrol.Uicontrol;
+import org.scilab.modules.graphic_objects.uicontrol.frame.border.FrameBorder;
 
 public abstract class TreeView implements GraphicView, TreeSelectionListener {
 
@@ -172,6 +173,12 @@ public abstract class TreeView implements GraphicView, TreeSelectionListener {
                 strBuff.append("<tr><td>STYLE</td><td>" + typeToString(uiControl.getStyle()) + "</td>");
                 strBuff.append("<tr><td>LAYOUT</td><td>" + uiControl.getLayoutAsEnum() + "</td>");
                 strBuff.append("<tr><td>GROUP NAME</td><td>" + uiControl.getGroupName() + "</td>");
+                strBuff.append("<tr><td>FRAME_BORDER</td><td>" + uiControl.getFrameBorder() + "</td>");
+            }
+
+            if (graphicObject instanceof FrameBorder) {
+                FrameBorder frameBorder = (FrameBorder) graphicObject;
+                strBuff.append("<tr><td>STYLE</td><td>" + frameBorder.getStyleAsEnum().toString() + "</td>");
             }
 
             strBuff.append("</table>");
index 1d5b569..8dbbc3a 100644 (file)
@@ -368,7 +368,6 @@ public class GOBuilder {
                     FrameBorderType borderType = FrameBorderType.stringToEnum(XmlTools.getFromMap(map, "name", "none"));
                     Integer border = createBorder(controller, uic, borderType, map);
                     controller.setProperty(uic, __GO_UI_FRAME_BORDER__, border);
-                    controller.setGraphicObjectRelationship(uic, border);
 
                     String[] text = new String[1];
                     text[0] = xmlAttributes.get("tab-title");
@@ -673,10 +672,8 @@ public class GOBuilder {
                 Integer in = createBorder(controller, border, borderIn, map);
 
                 controller.setProperty(border, __GO_UI_FRAME_BORDER_OUT_BORDER__, out);
-                controller.setGraphicObjectRelationship(border, out);
 
                 controller.setProperty(border, __GO_UI_FRAME_BORDER_IN_BORDER__, in);
-                controller.setGraphicObjectRelationship(border, in);
 
                 break;
             }
@@ -738,7 +735,6 @@ public class GOBuilder {
                 if (borderOut != null) {
                     Integer out = createBorder(controller, border, borderOut, map);
                     controller.setProperty(border, __GO_UI_FRAME_BORDER_TITLE__, out);
-                    controller.setGraphicObjectRelationship(border, out);
                 }
 
                 controller.setProperty(border, __GO_TITLE__, title);
@@ -757,6 +753,7 @@ public class GOBuilder {
                 break;
         }
 
+        controller.setGraphicObjectRelationship(uic, border);
         return border;
     }
 
index ba7ddf7..b5cd905 100644 (file)
@@ -263,7 +263,6 @@ public class XMLDomLoader {
         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) {
@@ -299,30 +298,20 @@ public class XMLDomLoader {
                     }
 
                     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;
                     }
 
@@ -354,7 +343,7 @@ public class XMLDomLoader {
                     }
                 }
 
-                if (makeRelationShip && parent != 0 && child != 0) {
+                if (parent != 0 && child != 0) {
                     GraphicController.getController().setGraphicObjectRelationship(parent, child);
                 }
 
@@ -379,6 +368,9 @@ public class XMLDomLoader {
             attr.removeNamedItem("style");
         }
 
+        //frame borders are always hidden
+        controller.setProperty(uib,  __GO_HIDDEN__, true);
+
         for (int i = 0 ; i < attr.getLength() ; i++) {
             Node prop = attr.item(i);
             Pair<Integer, ModelType> pair = BorderPropToGO.get(prop.getNodeName());
@@ -425,10 +417,13 @@ public class XMLDomLoader {
                     String nodeName = childNode.getNodeName();
                     if (nodeName.equals("title")) {
                         GraphicController.getController().setProperty(uib, __GO_UI_FRAME_BORDER_TITLE__, child);
+                        GraphicController.getController().setGraphicObjectRelationship(uib, child);
                     } else if (nodeName.equals("out")) {
                         GraphicController.getController().setProperty(uib, __GO_UI_FRAME_BORDER_OUT_BORDER__, child);
+                        GraphicController.getController().setGraphicObjectRelationship(uib, child);
                     } else if (nodeName.equals("in")) {
                         GraphicController.getController().setProperty(uib, __GO_UI_FRAME_BORDER_IN_BORDER__, child);
+                        GraphicController.getController().setGraphicObjectRelationship(uib, child);
                     }
                 }
             }
index 569a210..7cbb701 100644 (file)
 
 package org.scilab.modules.graphic_objects.xmlloader;
 
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_ENABLE__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TAG__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CHILDREN__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXES__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UICONTROL__;
 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_TYPE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UIMENU__;
 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_FRAME_BORDER__;
+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_IN_BORDER__;
+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__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_IMAGE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LAYER__;
@@ -336,7 +338,8 @@ public class XmlLoader extends DefaultHandler {
         Integer newGo = controller.cloneObject(root);
         Integer[] children = (Integer[]) controller.getProperty(root, __GO_CHILDREN__);
         for (int i = children.length - 1; i >= 0 ; i--) {
-            if ((Integer)controller.getProperty(children[i], __GO_TYPE__) == __GO_AXES__) {
+            Integer childType = (Integer)controller.getProperty(children[i], __GO_TYPE__);
+            if (childType == __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__);
@@ -348,6 +351,29 @@ public class XmlLoader extends DefaultHandler {
 
                 ScilabNativeView.ScilabNativeView__setCurrentSubWin(go);
                 ScilabNativeView.ScilabNativeView__setCurrentObject(go);
+            } else if (childType == __GO_UI_FRAME_BORDER__) {
+                Integer newChild = cloneObject(children[i]);
+                controller.setGraphicObjectRelationship(newGo, newChild);
+
+                Integer rootType = (Integer)controller.getProperty(root, __GO_TYPE__);
+                if (rootType == __GO_UICONTROL__) {
+                    controller.setProperty(newGo, __GO_UI_FRAME_BORDER__, newChild);
+                } else { //__GO_UI_FRAME_BORDER__
+                    Integer border = (Integer) controller.getProperty(root, __GO_UI_FRAME_BORDER_TITLE__);
+                    if (border == children[i]) {
+                        controller.setProperty(newGo, __GO_UI_FRAME_BORDER_TITLE__, newChild);
+                    } else {
+                        border = (Integer) controller.getProperty(root, __GO_UI_FRAME_BORDER_OUT_BORDER__);
+                        if (border == children[i]) {
+                            controller.setProperty(newGo, __GO_UI_FRAME_BORDER_OUT_BORDER__, newChild);
+                        } else {
+                            border = (Integer) controller.getProperty(root, __GO_UI_FRAME_BORDER_OUT_BORDER__);
+                            if (border == children[i]) {
+                                controller.setProperty(newGo, __GO_UI_FRAME_BORDER_OUT_BORDER__, newChild);
+                            }
+                        }
+                    }
+                }
             } else {
                 Integer newChild = cloneObject(children[i]);
                 controller.setGraphicObjectRelationship(newGo, newChild);
index fb53847..fe37950 100644 (file)
@@ -1,7 +1,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_LAYOUT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXES__;
 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__;
@@ -412,11 +413,15 @@ public class XmlSaver {
         Integer[] children = uic.getChildren();
         if (reverseChildren) {
             for (int i = children.length - 1 ; i >= 0 ; i--) {
-                appendChild(elemUi, createElement(doc, children[i], reverseChildren));
+                if ((Integer)controller.getProperty(children[i], __GO_TYPE__) != __GO_UI_FRAME_BORDER__) {
+                    appendChild(elemUi, createElement(doc, children[i], reverseChildren));
+                }
             }
         } else {
             for (int i = 0 ; i < children.length ; i++) {
-                appendChild(elemUi, createElement(doc, children[i], reverseChildren));
+                if ((Integer)controller.getProperty(children[i], __GO_TYPE__) != __GO_UI_FRAME_BORDER__) {
+                    appendChild(elemUi, createElement(doc, children[i], reverseChildren));
+                }
             }
         }
         return elemUi;