changeset 7953:bcd84f2065ae

[SCENEBUILDER] Fix DTL-6734 : Using fx:include crashes hierarchy/controller view in scenebuilder 2.0
author slions
date Wed, 03 Sep 2014 12:14:13 +0200
parents dc9971d9268f
children 6f74aae81004
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/metadata/util/DesignHierarchyMask.java
diffstat 1 files changed, 17 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/metadata/util/DesignHierarchyMask.java	Wed Sep 03 12:11:22 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/metadata/util/DesignHierarchyMask.java	Wed Sep 03 12:14:13 2014 +0200
@@ -42,6 +42,7 @@
 import com.oracle.javafx.scenebuilder.kit.metadata.klass.ComponentClassMetadata;
 import com.oracle.javafx.scenebuilder.kit.metadata.property.ComponentPropertyMetadata;
 import com.oracle.javafx.scenebuilder.kit.metadata.property.ValuePropertyMetadata;
+import com.oracle.javafx.scenebuilder.kit.util.Deprecation;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -763,26 +764,15 @@
      * @return the number of columns
      */
     public int getColumnsSize() {
-        assert fxomObject instanceof FXOMInstance;
-        final FXOMInstance fxomInstance = (FXOMInstance) fxomObject;
-        assert fxomInstance.getSceneGraphObject() instanceof GridPane;
-
-        // Retrieve the column constraints size
-        final int constraintsSize = getColumnsConstraintsSize();
-
-        // Retrieve the max column index
-        int maxColumnIndex = -1;
-        for (int i = 0, count = getSubComponentCount(); i < count; i++) {
-            final FXOMObject childObject = getSubComponentAtIndex(i);
-            if (childObject.getSceneGraphObject() != null) {
-                final DesignHierarchyMask childMask = new DesignHierarchyMask(childObject);
-                if (maxColumnIndex < childMask.getColumnIndex()) {
-                    maxColumnIndex = childMask.getColumnIndex();
-                }
-            }
+        final Object sceneGraphObject;
+        // For FXOMIntrinsic, we use the source sceneGraphObject
+        if (fxomObject instanceof FXOMIntrinsic) {
+            sceneGraphObject = ((FXOMIntrinsic) fxomObject).getSourceSceneGraphObject();
+        } else {
+            sceneGraphObject = fxomObject.getSceneGraphObject();
         }
-
-        return Math.max(constraintsSize, maxColumnIndex + 1);
+        assert sceneGraphObject instanceof GridPane;
+        return Deprecation.getGridPaneColumnCount((GridPane) sceneGraphObject);
     }
 
     /**
@@ -794,26 +784,15 @@
      * @return the number of rows
      */
     public int getRowsSize() {
-        assert fxomObject instanceof FXOMInstance;
-        final FXOMInstance fxomInstance = (FXOMInstance) fxomObject;
-        assert fxomInstance.getSceneGraphObject() instanceof GridPane;
-
-        // Retrieve the row constraints size
-        final int constraintsSize = getRowsConstraintsSize();
-
-        // Retrieve the max row index
-        int maxRowIndex = -1;
-        for (int i = 0, count = getSubComponentCount(); i < count; i++) {
-            final FXOMObject childObject = getSubComponentAtIndex(i);
-            if (childObject.getSceneGraphObject() != null) {
-                final DesignHierarchyMask childMask = new DesignHierarchyMask(childObject);
-                if (maxRowIndex < childMask.getRowIndex()) {
-                    maxRowIndex = childMask.getRowIndex();
-                }
-            }
+        final Object sceneGraphObject;
+        // For FXOMIntrinsic, we use the source sceneGraphObject
+        if (fxomObject instanceof FXOMIntrinsic) {
+            sceneGraphObject = ((FXOMIntrinsic) fxomObject).getSourceSceneGraphObject();
+        } else {
+            sceneGraphObject = fxomObject.getSceneGraphObject();
         }
-
-        return Math.max(constraintsSize, maxRowIndex + 1);
+        assert sceneGraphObject instanceof GridPane;
+        return Deprecation.getGridPaneRowCount((GridPane) sceneGraphObject);
     }
     
     public List<FXOMObject> getColumnContentAtIndex(int index) {