add frame_borders as hidden children to allow recursive deletion 03/13903/3
Antoine ELIAS [Tue, 4 Mar 2014 19:43:30 +0000 (20:43 +0100)]
Change-Id: Ibd219b3bb157093eaa564756e03d29eebe897d31

scilab/modules/graphic_objects/src/cpp/ScilabView.cpp
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicController/GraphicController.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicModel/GraphicModel.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/XmlLoader.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlSaver.java
scilab/modules/graphics/src/c/getHandleProperty/set_borders_property.c
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/window/SwingScilabStaticWindow.java

index c522b9e..d92d3f1 100644 (file)
@@ -296,6 +296,7 @@ void ScilabView::updateObject(int iUID, int iProperty)
                 PathItem* item = (*it).second;
                 item->parent = iParent;
             }
+            break;
         }
         case __GO_TAG__ :
         {
index d318def..8cee541 100644 (file)
@@ -222,7 +222,7 @@ public class GraphicController {
             return 0;
         }
     }
-    
+
     /**
      * Ask the model to clone an object
      * @param id : the ID of the object to clone.
@@ -235,7 +235,7 @@ public class GraphicController {
     public Integer askObject(Type type) {
         return askObject(type, true);
     }
-    
+
     /**
      * Deletes an object
      * @param id the deleted object's id
index 5220567..02086f8 100644 (file)
@@ -43,8 +43,8 @@ import org.scilab.modules.graphic_objects.uicontrol.checkbox.CheckBox;
 import org.scilab.modules.graphic_objects.uicontrol.edit.Edit;
 import org.scilab.modules.graphic_objects.uicontrol.edit.Spinner;
 import org.scilab.modules.graphic_objects.uicontrol.frame.Frame;
-import org.scilab.modules.graphic_objects.uicontrol.layer.Layer;
 import org.scilab.modules.graphic_objects.uicontrol.frame.border.FrameBorder;
+import org.scilab.modules.graphic_objects.uicontrol.layer.Layer;
 import org.scilab.modules.graphic_objects.uicontrol.listbox.ListBox;
 import org.scilab.modules.graphic_objects.uicontrol.popupmenu.PopupMenu;
 import org.scilab.modules.graphic_objects.uicontrol.pushbutton.PushButton;
index 5675709..1d5b569 100644 (file)
@@ -1,16 +1,14 @@
 package org.scilab.modules.graphic_objects.xmlloader;
 
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SPINNER__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_FIGURE__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_CHECKED__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LABEL__;
 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_DOCKABLE__;
+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_HIDDEN__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_INFOBAR_VISIBLE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LAYOUT__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LINE_THICKNESS__;
@@ -30,6 +28,7 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_BORDER_POSITION__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_BORDER_PREFERREDSIZE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_CHECKBOX__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_CHECKED__;
 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__;
@@ -60,6 +59,7 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 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_LABEL__;
 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__;
@@ -67,6 +67,7 @@ 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_SCROLLABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SPINNER__;
 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__;
@@ -367,6 +368,7 @@ 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");
@@ -648,6 +650,7 @@ public class GOBuilder {
     private static Integer createBorder(GraphicController controller, Integer uic, FrameBorderType borderType, Map<String, String> map) {
         Integer border = controller.askObject(GraphicObject.getTypeFromName(__GO_UI_FRAME_BORDER__));
         controller.setProperty(border, __GO_UI_FRAME_BORDER_STYLE__, borderType.ordinal());
+        controller.setProperty(border, __GO_HIDDEN__, true);
 
         switch (borderType) {
             case SOFTBEVEL:
@@ -670,7 +673,10 @@ 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;
             }
@@ -732,6 +738,7 @@ 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);
index f18552c..569a210 100644 (file)
@@ -358,12 +358,7 @@ public class XmlLoader extends DefaultHandler {
     }
 
     private void deleteObject(Integer root) {
-        Integer[] children = (Integer[]) controller.getProperty(root, __GO_CHILDREN__);
-        for (int i = 0; i < children.length; i++) {
-            deleteObject(children[i]);
-        }
-
-        controller.deleteObject(root);
+        controller.removeRelationShipAndDelete(root);
     }
 
     private Integer getTypeFromName(String localName) {
index 9e9318f..fb53847 100644 (file)
@@ -40,8 +40,6 @@ import org.w3c.dom.Node;
 
 
 public class XmlSaver {
-    static private Uicontrol defaultUi = null;
-    static private Uimenu defaultMenu = null;
     static private Figure defaultFig = null;
     static private FrameBorder defaultBorder = null;
 
@@ -94,7 +92,6 @@ public class XmlSaver {
         }
 
         defaultFig = null;
-        defaultUi = null;
         defaultBorder = null;
         return ""; //all good
     }
@@ -303,7 +300,7 @@ public class XmlSaver {
     private static Element createUicontrol(Document doc, Integer id, boolean reverseChildren) {
         GraphicController controller = GraphicController.getController();
         Uicontrol uic = (Uicontrol)controller.getObjectFromId(id);
-        initDefaultui(uic.getStyle());
+        Uicontrol defaultUi = initDefaultui(uic.getStyle());
         Element elemUi = doc.createElement(uic.getStyleAsEnum().toString().toLowerCase());
 
         //BackgroundColor
@@ -410,6 +407,7 @@ public class XmlSaver {
             }
         }
 
+        controller.deleteObject(defaultUi.getIdentifier());
         //children
         Integer[] children = uic.getChildren();
         if (reverseChildren) {
@@ -432,7 +430,7 @@ public class XmlSaver {
             return null;
         }
 
-        initDefaultMenu();
+        Uimenu defaultMenu = initDefaultMenu();
         Element elemMenu = doc.createElement("menu");
 
         //enable
@@ -582,14 +580,14 @@ public class XmlSaver {
         elem.setAttribute(property, value);
     }
 
-    private static void initDefaultui(Integer uicontrolStyle) {
+    private static Uicontrol initDefaultui(Integer uicontrolStyle) {
         Integer uic = GraphicController.getController().askObject(GraphicObject.getTypeFromName(uicontrolStyle));
-        defaultUi = (Uicontrol) GraphicController.getController().getObjectFromId(uic);
+        return (Uicontrol) GraphicController.getController().getObjectFromId(uic);
     }
 
-    private static void initDefaultMenu() {
+    private static Uimenu initDefaultMenu() {
         Integer uic = GraphicController.getController().askObject(GraphicObject.getTypeFromName(__GO_UIMENU__));
-        defaultMenu = (Uimenu) GraphicController.getController().getObjectFromId(uic);
+        return (Uimenu) GraphicController.getController().getObjectFromId(uic);
     }
 
 }
index c5649a3..9f7fc76 100644 (file)
@@ -52,6 +52,7 @@ int set_borders_property(void* _pvCtx, int iObjUID, void* _pvData, int valueType
     }
     else
     {
+        int iHidden = 1;
         int* piAddrList = (int*)_pvData;
 
         int iBorder = createBorder(_pvCtx, piAddrList, iObjUID);
@@ -61,6 +62,8 @@ int set_borders_property(void* _pvCtx, int iObjUID, void* _pvData, int valueType
         }
 
         setGraphicObjectProperty(iObjUID, __GO_UI_FRAME_BORDER__, &iBorder, jni_int, 1);
+        setGraphicObjectProperty(iBorder, __GO_HIDDEN__, &iHidden, jni_bool, 1);
+        setGraphicObjectRelationship(iObjUID, iBorder);
         return SET_PROPERTY_SUCCEED;
     }
 }
@@ -781,6 +784,7 @@ int createTitledBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
     {
         if (isTListType(_pvCtx, piAddr2))
         {
+            int iHidden = 1;
             iChildBorder = createBorder(_pvCtx, piAddr2, iBorder);
             if (iChildBorder == 0)
             {
@@ -788,7 +792,8 @@ int createTitledBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
             }
 
             setGraphicObjectProperty(iBorder, __GO_UI_FRAME_BORDER_TITLE__, &iChildBorder, jni_int, 1);
-
+            setGraphicObjectProperty(iChildBorder, __GO_HIDDEN__, &iHidden, jni_bool, 1);
+            setGraphicObjectRelationship(iBorder, iChildBorder);
         }
         else //title
         {
@@ -1012,8 +1017,14 @@ int createCompoundBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
 
     if (iCount > 1)
     {
+        int iHidden = 1;
         setGraphicObjectProperty(iBorder, __GO_UI_FRAME_BORDER_OUT_BORDER__, &iChildBorderOut, jni_int, 1);
+        setGraphicObjectProperty(iChildBorderOut, __GO_HIDDEN__, &iHidden, jni_bool, 1);
+        setGraphicObjectRelationship(iBorder, iChildBorderOut);
+
         setGraphicObjectProperty(iBorder, __GO_UI_FRAME_BORDER_IN_BORDER__, &iChildBorderIn, jni_int, 1);
+        setGraphicObjectProperty(iChildBorderIn, __GO_HIDDEN__, &iHidden, jni_bool, 1);
+        setGraphicObjectRelationship(iBorder, iChildBorderIn);
     }
 
     return iBorder;
index c4be084..5c937da 100644 (file)
@@ -40,7 +40,8 @@ public class SwingScilabStaticWindow extends SwingScilabWindow {
                                           + ";if exists(\"%oldgcbo\") then gcbo = %oldgcbo; else clear gcbo; end;";
                     InterpreterManagement.putCommandInScilabQueue(closeCommand);
                 } else {
-                    GraphicController.getController().deleteObject(panel.getId());
+                    //GraphicController.getController().deleteObject(panel.getId());
+                    GraphicController.getController().removeRelationShipAndDelete(panel.getId());
                 }
             }
         });