changeset 8005:485cc6e5a142

[SCENEBUILDER] Fix DTL-6881 : Exception and failure when trying to use Wrap In command on tab graphic
author slions
date Tue, 16 Sep 2014 15:04:33 +0200
parents 50f45648eecc
children 55914cd82ec8
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapJobUtils.java
diffstat 1 files changed, 27 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapJobUtils.java	Tue Sep 16 15:03:35 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapJobUtils.java	Tue Sep 16 15:04:33 2014 +0200
@@ -124,13 +124,34 @@
             }
         } else if (mask.isAcceptingSubComponent()) {
             result = mask.getSubComponentPropertyName();
-        } else if (mask.isAcceptingAccessory(Accessory.CONTENT)) {
-            result = mask.getPropertyNameForAccessory(Accessory.CONTENT);
-        } else if (mask.isAcceptingAccessory(Accessory.GRAPHIC)) {
-            result = mask.getPropertyNameForAccessory(Accessory.GRAPHIC);
         } else {
-            assert false;
-            result = null;
+            assert mask.isAcceptingAccessory(Accessory.CONTENT)
+                    || mask.isAcceptingAccessory(Accessory.GRAPHIC);
+            assert children != null && children.size() == 1; // wrap job is executable
+            final FXOMObject child = children.iterator().next();
+
+            if (mask.isAcceptingAccessory(Accessory.GRAPHIC) == false) {
+                // Containers accepting CONTENT only
+                assert mask.isAcceptingAccessory(Accessory.CONTENT);
+                result = mask.getPropertyNameForAccessory(Accessory.CONTENT);
+            } else if (mask.isAcceptingAccessory(Accessory.CONTENT) == false) {
+                // Containers accepting GRAPHIC only
+                assert mask.isAcceptingAccessory(Accessory.GRAPHIC);
+                result = mask.getPropertyNameForAccessory(Accessory.GRAPHIC);
+            } else {
+                // Containers accepting both CONTENT and GRAPHIC
+                final FXOMObject content = mask.getAccessory(Accessory.CONTENT);
+                final FXOMObject graphic = mask.getAccessory(Accessory.GRAPHIC);
+                // Return same accessory as the child container one
+                if (child.equals(content)) {
+                    result = mask.getPropertyNameForAccessory(Accessory.CONTENT);
+                } else if (child.equals(graphic)) {
+                    result = mask.getPropertyNameForAccessory(Accessory.GRAPHIC);
+                } else {
+                    assert false;
+                    result = null;
+                }
+            }
         }
         return result;
     }