changeset 7717:2ec456a947bf

[SCENEBUILDER] Fix DTL-6814: Wrap in commands may keep unused properties
author slions
date Tue, 19 Aug 2014 09:34:59 +0200
parents 36a242b77366
children e74cd136a22d
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/AbstractWrapInContentJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/AbstractWrapInJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/AbstractWrapInSubComponentJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/UnwrapJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInAnchorPaneJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInFlowPaneJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInGridPaneJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInGroupJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInHBoxJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInPaneJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInScrollPaneJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInSplitPaneJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInStackPaneJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInTabPaneJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInTilePaneJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInTitledPaneJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInToolBarJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInVBoxJob.java
diffstat 18 files changed, 131 insertions(+), 301 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/AbstractWrapInContentJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/AbstractWrapInContentJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -55,7 +55,7 @@
     }
 
     @Override
-    protected List<Job> wrapInJobs(final List<FXOMObject> children) {
+    protected List<Job> wrapChildrenJobs(final List<FXOMObject> children) {
 
         final List<Job> jobs = new ArrayList<>();
 
@@ -73,12 +73,12 @@
         //------------------------------------------------------------------
         // The selection is multiple :
         // - we set the new container CONTENT property to a new AnchorPane sub container
-        // - we update the children bounds and add them to the new AnchorPane sub container
+        // - we add the children to the new AnchorPane sub container
         //------------------------------------------------------------------
         if (children.size() > 1) {
 
             // Create the AnchorPane sub container
-            final FXOMInstance subContainer = makeContainerInstance(AnchorPane.class);
+            final FXOMInstance subContainer = makeNewContainerInstance(AnchorPane.class);
             final DesignHierarchyMask subContainerMask
                     = new DesignHierarchyMask(subContainer);
 
@@ -97,16 +97,11 @@
                     getEditorController());
             jobs.add(addValueJob);
 
-            // Update children bounds before adding them to the sub container
-            assert subContainerMask.isFreeChildPositioning();
-            final List<Job> modifyChildrenLayoutJobs
-                    = modifyChildrenLayoutJobs(children);
-            jobs.addAll(modifyChildrenLayoutJobs);
+            // Update children before adding them to the sub container
+            jobs.addAll(modifyChildrenJobs(subContainer, children));
 
             // Add the children to the sub container
-            final List<Job> addChildrenJobs
-                    = addChildrenToPropertyJobs(subContainerProperty, children);
-            jobs.addAll(addChildrenJobs);
+            jobs.addAll(addChildrenJobs(subContainerProperty, children));
 
             // Add the sub container property to the sub container instance
             assert subContainerProperty.getParentInstance() == null;
@@ -122,13 +117,10 @@
         //------------------------------------------------------------------
         else {
             // Update children before adding them to the new container
-            final List<Job> modifyChildrenJobs = modifyChildrenJobs(children);
-            jobs.addAll(modifyChildrenJobs);
+            jobs.addAll(modifyChildrenJobs(newContainer, children));
 
             // Add the children to the new container
-            final List<Job> addChildrenJobs
-                    = addChildrenToPropertyJobs(newContainerProperty, children);
-            jobs.addAll(addChildrenJobs);
+            jobs.addAll(addChildrenJobs(newContainerProperty, children));
         }
 
         // Add the new container property to the new container instance
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/AbstractWrapInJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/AbstractWrapInJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -33,7 +33,6 @@
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
 import com.oracle.javafx.scenebuilder.kit.editor.job.BatchJob;
-import com.oracle.javafx.scenebuilder.kit.editor.job.DeleteObjectJob;
 import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
 import com.oracle.javafx.scenebuilder.kit.editor.job.JobUtils;
 import com.oracle.javafx.scenebuilder.kit.editor.job.ModifyFxControllerJob;
@@ -41,6 +40,7 @@
 import com.oracle.javafx.scenebuilder.kit.editor.job.SetDocumentRootJob;
 import com.oracle.javafx.scenebuilder.kit.editor.job.ToggleFxRootJob;
 import com.oracle.javafx.scenebuilder.kit.editor.job.v2.AddPropertyValueJob;
+import com.oracle.javafx.scenebuilder.kit.editor.job.v2.RemovePropertyValueJob;
 import com.oracle.javafx.scenebuilder.kit.editor.selection.AbstractSelectionGroup;
 import com.oracle.javafx.scenebuilder.kit.editor.selection.ObjectSelectionGroup;
 import com.oracle.javafx.scenebuilder.kit.editor.selection.Selection;
@@ -58,7 +58,6 @@
 import javafx.geometry.Point2D;
 import javafx.scene.Node;
 import javafx.scene.Parent;
-import javafx.scene.layout.Region;
 
 /**
  * Main class used for the wrap jobs.
@@ -187,43 +186,36 @@
         assert asg instanceof ObjectSelectionGroup; // Because of (1)
         final ObjectSelectionGroup osg = (ObjectSelectionGroup) asg;
 
-        // Retrieve the current container
+        // Retrieve the old container
         oldContainer = (FXOMInstance) osg.getAncestor();
 
         // Retrieve the children to be wrapped
         final List<FXOMObject> children = osg.getSortedItems();
 
         // Create the new container
-        newContainer = makeContainerInstance();
+        newContainer = makeNewContainerInstance();
+        // Update the new container
+        modifyNewContainer(children);
 
         //==================================================================
-        // STEP #1 UPDATE THE NEW CONTAINER
+        // STEP #1
         //==================================================================
         // If the target object is NOT the FXOM root :
-        // - we update the new container bounds and add it to the current container
-        // - we remove the children from the current container
+        // - we add the new container to the old container
+        // - we remove the children from the old container
         //------------------------------------------------------------------
         if (oldContainer != null) {
 
-            // Retrieve the current container property name in use
+            // Retrieve the old container property name in use
             final PropertyName oldContainerPropertyName
                     = WrapJobUtils.getContainerPropertyName(oldContainer, children);
-            // Retrieve the current container property (already defined and not null)
+            // Retrieve the old container property (already defined and not null)
             final FXOMPropertyC oldContainerProperty
                     = (FXOMPropertyC) oldContainer.getProperties().get(oldContainerPropertyName);
             assert oldContainerProperty != null
                     && oldContainerProperty.getParentInstance() != null;
 
-            // Update the new container before adding it to the old container
-            final DesignHierarchyMask oldContainerMask
-                    = new DesignHierarchyMask(oldContainer);
-            if (oldContainerMask.isFreeChildPositioning()
-                    && Region.class.isAssignableFrom(newContainer.getDeclaredClass())) { // Do not include Group new container
-                modifyContainerLayout(children);
-            }
-            modifyContainer(children);
-
-            // Add the new container to the current container
+            // Add the new container to the old container
             final int newContainerIndex = getIndex(oldContainer, children);
             final Job newContainerAddValueJob = new AddPropertyValueJob(
                     newContainer,
@@ -231,9 +223,9 @@
                     newContainerIndex, getEditorController());
             batchJob.addSubJob(newContainerAddValueJob);
 
-            // Remove children from the current container
-            final List<Job> deleteChildrenJobs = deleteChildrenJobs(children);
-            batchJob.addSubJobs(deleteChildrenJobs);
+            // Remove children from the old container
+            final List<Job> removeChildrenJobs = removeChildrenJobs(oldContainerProperty, children);
+            batchJob.addSubJobs(removeChildrenJobs);
         } //
         //------------------------------------------------------------------
         // If the target object is the FXOM root :
@@ -272,15 +264,24 @@
         }
 
         //==================================================================
-        // STEP #2 UPDATE THE NEW CONTAINER CHILDREN
+        // STEP #2
         //==================================================================
         // This step depends on the new container property 
         // (either either the SUB COMPONENT or the CONTENT property)
         //------------------------------------------------------------------
-        batchJob.addSubJobs(wrapInJobs(children));
+        batchJob.addSubJobs(wrapChildrenJobs(children));
     }
 
-    protected List<Job> addChildrenToPropertyJobs(
+    /**
+     * Used to wrap the specified children in the new container. May use either
+     * the SUB COMPONENT or the CONTENT property.
+     *
+     * @param children The children to be wrapped.
+     * @return A list of jobs.
+     */
+    protected abstract List<Job> wrapChildrenJobs(final List<FXOMObject> children);
+
+    protected List<Job> addChildrenJobs(
             final FXOMPropertyC containerProperty,
             final Collection<FXOMObject> children) {
 
@@ -298,91 +299,89 @@
         return jobs;
     }
 
-    protected List<Job> deleteChildrenJobs(final List<FXOMObject> children) {
+    protected List<Job> removeChildrenJobs(
+            final FXOMPropertyC containerProperty,
+            final List<FXOMObject> children) {
 
         final List<Job> jobs = new ArrayList<>();
         for (FXOMObject child : children) {
             assert child instanceof FXOMInstance;
-            final Job deleteObjectJob = new DeleteObjectJob(
-                    child, getEditorController());
-            jobs.add(deleteObjectJob);
+            final Job removeValueJob = new RemovePropertyValueJob(
+                    child,
+                    getEditorController());
+            jobs.add(removeValueJob);
         }
         return jobs;
     }
 
     /**
-     * Used to wrap the children in the new container.
-     * May use either the SUB COMPONENT or the CONTENT property.
+     * Used to modify the specified children.
      *
-     * @param children
-     * @return
-     */
-    protected abstract List<Job> wrapInJobs(final List<FXOMObject> children);
-
-    /**
-     * Used to modify the children before adding them to this container.
-     *
+     * @param container
      * @param children The children to be modified.
      * @return A list of jobs.
      */
-    protected abstract List<Job> modifyChildrenJobs(final List<FXOMObject> children);
-
-    /**
-     * Used to modify this container before adding it to the specified container.
-     *
-     * Note that unlike the modifyChildrenJobs method, we must not use any job
-     * here but directly set the properties.
-     * Indeed, the new container is not yet part of the model.
-     *
-     * @param children The children of this container.
-     */
-    protected abstract void modifyContainer(final List<FXOMObject> children);
-
-    /**
-     * Used to modify the children layout properties.
-     *
-     * @param children The children.
-     * @return
-     */
-    protected List<Job> modifyChildrenLayoutJobs(final List<FXOMObject> children) {
+    protected List<Job> modifyChildrenJobs(final FXOMInstance container, final List<FXOMObject> children) {
 
         final List<Job> jobs = new ArrayList<>();
-        final Bounds unionOfBounds = WrapJobUtils.getUnionOfBounds(children);
+        final DesignHierarchyMask newContainerMask = new DesignHierarchyMask(container);
 
-        for (FXOMObject child : children) {
-            assert child.getSceneGraphObject() instanceof Node;
-            final Node childNode = (Node) child.getSceneGraphObject();
-            final Bounds childBounds = childNode.getLayoutBounds();
+        if (newContainerMask.isFreeChildPositioning()) {
+            final Bounds unionOfBounds = WrapJobUtils.getUnionOfBounds(children);
 
-            final Point2D point = childNode.localToParent(
-                    childBounds.getMinX(), childBounds.getMinY());
-            double layoutX = point.getX() - unionOfBounds.getMinX();
-            double layoutY = point.getY() - unionOfBounds.getMinY();
-            final ModifyObjectJob modifyLayoutX = WrapJobUtils.modifyObjectJob(
-                    (FXOMInstance) child, "layoutX", layoutX, getEditorController());
-            jobs.add(modifyLayoutX);
-            final ModifyObjectJob modifyLayoutY = WrapJobUtils.modifyObjectJob(
-                    (FXOMInstance) child, "layoutY", layoutY, getEditorController());
-            jobs.add(modifyLayoutY);
+            for (FXOMObject child : children) {
+                assert child.getSceneGraphObject() instanceof Node;
+                final Node childNode = (Node) child.getSceneGraphObject();
+                final Bounds childBounds = childNode.getLayoutBounds();
+
+                final Point2D point = childNode.localToParent(
+                        childBounds.getMinX(), childBounds.getMinY());
+                double layoutX = point.getX() - unionOfBounds.getMinX();
+                double layoutY = point.getY() - unionOfBounds.getMinY();
+                final ModifyObjectJob modifyLayoutX = WrapJobUtils.modifyObjectJob(
+                        (FXOMInstance) child, "layoutX", layoutX, getEditorController());
+                jobs.add(modifyLayoutX);
+                final ModifyObjectJob modifyLayoutY = WrapJobUtils.modifyObjectJob(
+                        (FXOMInstance) child, "layoutY", layoutY, getEditorController());
+                jobs.add(modifyLayoutY);
+            }
+        } else {
+            for (FXOMObject child : children) {
+                assert child.getSceneGraphObject() instanceof Node;
+
+                final ModifyObjectJob modifyLayoutX = WrapJobUtils.modifyObjectJob(
+                        (FXOMInstance) child, "layoutX", 0.0, getEditorController());
+                jobs.add(modifyLayoutX);
+                final ModifyObjectJob modifyLayoutY = WrapJobUtils.modifyObjectJob(
+                        (FXOMInstance) child, "layoutY", 0.0, getEditorController());
+                jobs.add(modifyLayoutY);
+            }
         }
         return jobs;
     }
 
     /**
-     * Used to modify the container layout properties.
+     * Used to modify the new container.
+     *
+     * Note that unlike the modifyChildrenJobs method, we do not use any job
+     * here but directly set the properties.
      *
      * @param children The children.
      */
-    protected void modifyContainerLayout(final List<FXOMObject> children) {
-
-        final Bounds unionOfBounds = WrapJobUtils.getUnionOfBounds(children);
-        JobUtils.setLayoutX(newContainer, Node.class, unionOfBounds.getMinX());
-        JobUtils.setLayoutY(newContainer, Node.class, unionOfBounds.getMinY());
+    protected void modifyNewContainer(final List<FXOMObject> children) {
+        if (oldContainer != null) {
+            final DesignHierarchyMask oldContainerMask = new DesignHierarchyMask(oldContainer);
+            if (oldContainerMask.isFreeChildPositioning()) {
+                final Bounds unionOfBounds = WrapJobUtils.getUnionOfBounds(children);
+                JobUtils.setLayoutX(newContainer, Node.class, unionOfBounds.getMinX());
+                JobUtils.setLayoutY(newContainer, Node.class, unionOfBounds.getMinY());
 //            JobUtils.setMinHeight(newContainer, Region.class, unionOfBounds.getHeight());
 //            JobUtils.setMinWidth(newContainer, Region.class, unionOfBounds.getMinY());
+            }
+        }
     }
 
-    protected FXOMInstance makeContainerInstance(final Class<?> containerClass) {
+    protected FXOMInstance makeNewContainerInstance(final Class<?> containerClass) {
         // Create new container instance
         final FXOMDocument newDocument = new FXOMDocument();
         final FXOMInstance result = new FXOMInstance(newDocument, containerClass);
@@ -392,13 +391,13 @@
         return result;
     }
 
-    private FXOMInstance makeContainerInstance() {
-        return makeContainerInstance(newContainerClass);
+    private FXOMInstance makeNewContainerInstance() {
+        return AbstractWrapInJob.this.makeNewContainerInstance(newContainerClass);
     }
 
     /**
-     * Returns the index to be used in order to add the new container
-     * to the current container.
+     * Returns the index to be used in order to add the new container to the old
+     * container.
      *
      * @param container
      * @param fxomObjects
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/AbstractWrapInSubComponentJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/AbstractWrapInSubComponentJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -43,7 +43,8 @@
 import java.util.List;
 
 /**
- * Main class used for the wrap jobs using the new container SUB COMPONENT property.
+ * Main class used for the wrap jobs using the new container SUB COMPONENT
+ * property.
  */
 public abstract class AbstractWrapInSubComponentJob extends AbstractWrapInJob {
 
@@ -52,7 +53,7 @@
     }
 
     @Override
-    protected List<Job> wrapInJobs(final List<FXOMObject> children) {
+    protected List<Job> wrapChildrenJobs(final List<FXOMObject> children) {
 
         final List<Job> jobs = new ArrayList<>();
 
@@ -68,15 +69,12 @@
                 newContainer.getFxomDocument(), newContainerPropertyName);
 
         // Update children before adding them to the new container
-        final List<Job> modifyChildrenJobs = modifyChildrenJobs(children);
-        jobs.addAll(modifyChildrenJobs);
+        jobs.addAll(modifyChildrenJobs(newContainer, children));
 
         // Sort the children before adding them to their new container
         final Collection<FXOMObject> sorted = sortChildren(children);
         // Add the children to the new container
-        final List<Job> addChildrenJobs
-                = addChildrenToPropertyJobs(newContainerProperty, sorted);
-        jobs.addAll(addChildrenJobs);
+        jobs.addAll(addChildrenJobs(newContainerProperty, sorted));
 
         // Add the new container property to the new container instance
         assert newContainerProperty.getParentInstance() == null;
@@ -88,7 +86,7 @@
 
         return jobs;
     }
-    
+
     protected Collection<FXOMObject> sortChildren(List<FXOMObject> children) {
         return children;
     }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/UnwrapJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/UnwrapJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -170,13 +170,13 @@
 
         // Remove the children from the old container property
         final List<Job> removeChildrenJobs
-                = removeChildrenFromPropertyJobs(oldContainerProperty, oldContainerChildren);
+                = removeChildrenJobs(oldContainerProperty, oldContainerChildren);
         batchJob.addSubJobs(removeChildrenJobs);
 
         //------------------------------------------------------------------
         // If the target object is NOT the FXOM root :
-        // - we update the new container bounds and add it to the current container
-        // - we update the children bounds and remove them from the current container
+        // - we update the new container bounds and add it to the old container
+        // - we update the children bounds and remove them from the old container
         //------------------------------------------------------------------
         if (newContainer != null) {
 
@@ -196,14 +196,14 @@
                     = new DesignHierarchyMask(newContainer);
             if (newContainerMask.isFreeChildPositioning()) {
                 final List<Job> modifyChildrenLayoutJobs
-                        = modifyChildrenLayoutJobs(oldContainerChildren);
+                        = modifyChildrenJobs(oldContainerChildren);
                 batchJob.addSubJobs(modifyChildrenLayoutJobs);
             }
 
             // Add the children to the new container
             int index = oldContainer.getIndexInParentProperty();
             final List<Job> addChildrenJobs
-                    = addChildrenToPropertyJobs(newContainerProperty, index, oldContainerChildren);
+                    = addChildrenJobs(newContainerProperty, index, oldContainerChildren);
             batchJob.addSubJobs(addChildrenJobs);
 
             // Remove the old container from the new container property
@@ -248,7 +248,7 @@
         }
     }
 
-    protected List<Job> addChildrenToPropertyJobs(
+    protected List<Job> addChildrenJobs(
             final FXOMPropertyC containerProperty,
             final int start,
             final List<FXOMObject> children) {
@@ -267,7 +267,7 @@
         return jobs;
     }
 
-    protected List<Job> removeChildrenFromPropertyJobs(
+    protected List<Job> removeChildrenJobs(
             final FXOMPropertyC containerProperty,
             final List<FXOMObject> children) {
 
@@ -283,12 +283,12 @@
     }
 
     /**
-     * Used to modify the children layout properties.
+     * Used to modify the specified children.
      *
      * @param children The children.
-     * @return
+     * @return A list of jobs.
      */
-    protected List<Job> modifyChildrenLayoutJobs(final List<FXOMObject> children) {
+    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
 
         final List<Job> jobs = new ArrayList<>();
 
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInAnchorPaneJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInAnchorPaneJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -32,9 +32,6 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.wrap;
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
-import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
-import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
-import java.util.List;
 import javafx.scene.layout.AnchorPane;
 
 /**
@@ -46,16 +43,4 @@
         super(editorController);
         newContainerClass = AnchorPane.class;
     }
-
-    @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-
-        // We can position the children in the AnchorPane container
-        // => we update the children layout properties
-        return modifyChildrenLayoutJobs(children);
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
-    }
 }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInFlowPaneJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInFlowPaneJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -32,10 +32,6 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.wrap;
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
-import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
-import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
-import java.util.Collections;
-import java.util.List;
 import javafx.scene.layout.FlowPane;
 
 /**
@@ -47,13 +43,4 @@
         super(editorController);
         newContainerClass = FlowPane.class;
     }
-
-    @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-        return Collections.emptyList();
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
-    }
 }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInGridPaneJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInGridPaneJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -70,14 +70,9 @@
     }
 
     @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
+    protected List<Job> modifyChildrenJobs(final FXOMInstance container, final List<FXOMObject> children) {
+        final List<Job> jobs = super.modifyChildrenJobs(container, children);
 
-        final List<Job> jobs = new ArrayList<>();
-        // When wrapping the root node, indices are not yet initialized
-        // (modifyContainer method not called)
-        if (indices.isEmpty()) {
-            modifyContainer(children);
-        }
         for (FXOMObject child : children) {
             int[] childIndices = indices.get(child);
 
@@ -99,7 +94,8 @@
     }
 
     @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
+    protected void modifyNewContainer(final List<FXOMObject> children) {
+        super.modifyNewContainer(children);
 
         final FXOMDocument fxomDocument = getEditorController().getFxomDocument();
 
@@ -140,14 +136,13 @@
     }
 
     /**
-     * This method computes either the ROW index or COLUMN index of each element,
-     * by running through a would-be grid according to a given course.
+     * This method computes either the ROW index or COLUMN index of each
+     * element, by running through a would-be grid according to a given course.
      * For instance, when course==ROW_BY_ROW, this method first order the
-     * elements row by row, and then sets their ROW index inside the indices map.
-     * When course==COL_BY_COL, this method orders the
-     * elements column by column, and then sets their COLUMN index inside the
-     * indices map.
-     * Note that this method leaves the original elements and children list
+     * elements row by row, and then sets their ROW index inside the indices
+     * map. When course==COL_BY_COL, this method orders the elements column by
+     * column, and then sets their COLUMN index inside the indices map. Note
+     * that this method leaves the original elements and children list
      * unchanged. All it does is populating the indices map.
      *
      * @param fxomObjects The children of the would-be grid.
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInGroupJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInGroupJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -32,10 +32,6 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.wrap;
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
-import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
-import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
-import java.util.Collections;
-import java.util.List;
 import javafx.scene.Group;
 
 /**
@@ -47,19 +43,4 @@
         super(editorController);
         newContainerClass = Group.class;
     }
-
-    /**
-     * Used to modify the children before adding them to this container.
-     *
-     * @param children The children to be modified.
-     * @return
-     */
-    @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-        return Collections.emptyList();
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
-    }
 }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInHBoxJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInHBoxJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -32,7 +32,6 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.wrap;
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
-import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
 import com.oracle.javafx.scenebuilder.kit.editor.job.wrap.FXOMObjectCourseComparator.UnidimensionalComparator;
 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
 import java.util.ArrayList;
@@ -53,15 +52,6 @@
     }
 
     @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-        return Collections.emptyList();
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
-    }
-
-    @Override
     protected Collection<FXOMObject> sortChildren(List<FXOMObject> children) {
         final List<FXOMObject> sorted = new ArrayList<>(children);
         Collections.sort(sorted, UnidimensionalComparator.of(Orientation.HORIZONTAL));
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInPaneJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInPaneJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -32,9 +32,6 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.wrap;
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
-import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
-import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
-import java.util.List;
 import javafx.scene.layout.Pane;
 
 /**
@@ -46,16 +43,4 @@
         super(editorController);
         newContainerClass = Pane.class;
     }
-
-    @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-
-        // We can position the children in the Pane container
-        // => we update the children layout properties
-        return modifyChildrenLayoutJobs(children);
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
-    }
 }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInScrollPaneJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInScrollPaneJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -32,10 +32,8 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.wrap;
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
-import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
 import com.oracle.javafx.scenebuilder.kit.editor.job.JobUtils;
 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
-import java.util.Collections;
 import java.util.List;
 import javafx.geometry.Bounds;
 import javafx.scene.control.ScrollPane;
@@ -51,12 +49,9 @@
     }
 
     @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-        return Collections.emptyList();
-    }
+    protected void modifyNewContainer(final List<FXOMObject> children) {
+        super.modifyNewContainer(children);
 
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
         final Bounds unionOfBounds = WrapJobUtils.getUnionOfBounds(children);
         JobUtils.setPrefViewportHeight(newContainer, ScrollPane.class, unionOfBounds.getHeight());
         JobUtils.setPrefViewportWidth(newContainer, ScrollPane.class, unionOfBounds.getWidth());
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInSplitPaneJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInSplitPaneJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -58,12 +58,8 @@
     }
 
     @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-        return Collections.emptyList();
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
+    protected void modifyNewContainer(final List<FXOMObject> children) {
+        super.modifyNewContainer(children);
 
         // Update the SplitPane orientation depending on its children positionning
         final Orientation orientation = getOrientation(children);
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInStackPaneJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInStackPaneJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -32,10 +32,6 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.wrap;
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
-import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
-import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
-import java.util.Collections;
-import java.util.List;
 import javafx.scene.layout.StackPane;
 
 /**
@@ -47,13 +43,4 @@
         super(editorController);
         newContainerClass = StackPane.class;
     }
-
-    @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-        return Collections.emptyList();
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
-    }
 }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInTabPaneJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInTabPaneJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -42,7 +42,6 @@
 import com.oracle.javafx.scenebuilder.kit.metadata.util.DesignHierarchyMask.Accessory;
 import com.oracle.javafx.scenebuilder.kit.metadata.util.PropertyName;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import javafx.scene.control.Tab;
 import javafx.scene.control.TabPane;
@@ -59,7 +58,7 @@
     }
 
     @Override
-    protected List<Job> wrapInJobs(final List<FXOMObject> children) {
+    protected List<Job> wrapChildrenJobs(final List<FXOMObject> children) {
 
         final List<Job> jobs = new ArrayList<>();
 
@@ -75,7 +74,7 @@
                 newContainer.getFxomDocument(), newContainerPropertyName);
 
         // Create the Tab sub container
-        final FXOMInstance tabContainer = makeContainerInstance(Tab.class);
+        final FXOMInstance tabContainer = makeNewContainerInstance(Tab.class);
         final DesignHierarchyMask tabContainerMask
                 = new DesignHierarchyMask(tabContainer);
         assert tabContainerMask.isAcceptingAccessory(Accessory.CONTENT);
@@ -98,12 +97,12 @@
         //------------------------------------------------------------------
         // The selection is multiple :
         // - we set the tab container CONTENT property to a new AnchorPane sub container
-        // - we update the children bounds and add them to the new AnchorPane sub container
+        // - we add the children to the new AnchorPane sub container
         //------------------------------------------------------------------
         if (children.size() > 1) {
 
             // Create the AnchorPane sub container
-            final FXOMInstance subContainer = makeContainerInstance(AnchorPane.class);
+            final FXOMInstance subContainer = makeNewContainerInstance(AnchorPane.class);
             final DesignHierarchyMask subContainerMask
                     = new DesignHierarchyMask(subContainer);
 
@@ -122,15 +121,12 @@
                     getEditorController());
             jobs.add(addValueJob);
 
-            // Update children bounds before adding them to the sub container
-            assert subContainerMask.isFreeChildPositioning();
-            final List<Job> modifyChildrenLayoutJobs
-                    = modifyChildrenLayoutJobs(children);
-            jobs.addAll(modifyChildrenLayoutJobs);
+            // Update children before adding them to the sub container
+            jobs.addAll(modifyChildrenJobs(subContainer, children));
 
             // Add the children to the sub container
             final List<Job> addChildrenJobs
-                    = addChildrenToPropertyJobs(subContainerProperty, children);
+                    = addChildrenJobs(subContainerProperty, children);
             jobs.addAll(addChildrenJobs);
 
             // Add the sub container property to the sub container instance
@@ -147,12 +143,11 @@
         //------------------------------------------------------------------
         else {
             // Update children before adding them to the new container
-            final List<Job> modifyChildrenJobs = modifyChildrenJobs(children);
-            jobs.addAll(modifyChildrenJobs);
+            jobs.addAll(modifyChildrenJobs(newContainer, children));
 
             // Add the children to the Tab sub container
             final List<Job> addChildrenJobs
-                    = addChildrenToPropertyJobs(tabContainerProperty, children);
+                    = addChildrenJobs(tabContainerProperty, children);
             jobs.addAll(addChildrenJobs);
         }
 
@@ -174,13 +169,4 @@
 
         return jobs;
     }
-
-    @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-        return Collections.emptyList();
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
-    }
 }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInTilePaneJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInTilePaneJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -32,10 +32,6 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.wrap;
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
-import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
-import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
-import java.util.Collections;
-import java.util.List;
 import javafx.scene.layout.TilePane;
 
 /**
@@ -47,13 +43,4 @@
         super(editorController);
         newContainerClass = TilePane.class;
     }
-
-    @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-        return Collections.emptyList();
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
-    }
 }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInTitledPaneJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInTitledPaneJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -32,10 +32,6 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.wrap;
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
-import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
-import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
-import java.util.Collections;
-import java.util.List;
 import javafx.scene.control.TitledPane;
 
 /**
@@ -47,13 +43,4 @@
         super(editorController);
         newContainerClass = TitledPane.class;
     }
-
-    @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-        return Collections.emptyList();
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
-    }
 }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInToolBarJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInToolBarJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -32,7 +32,6 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.wrap;
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
-import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
 import com.oracle.javafx.scenebuilder.kit.editor.job.wrap.FXOMObjectCourseComparator.UnidimensionalComparator;
 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
 import java.util.ArrayList;
@@ -53,15 +52,6 @@
     }
 
     @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-        return Collections.emptyList();
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
-    }
-
-    @Override
     protected Collection<FXOMObject> sortChildren(List<FXOMObject> children) {
         final List<FXOMObject> sorted = new ArrayList<>(children);
         Collections.sort(sorted, UnidimensionalComparator.of(Orientation.HORIZONTAL));
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInVBoxJob.java	Tue Aug 19 08:37:43 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapInVBoxJob.java	Tue Aug 19 09:34:59 2014 +0200
@@ -32,7 +32,6 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.wrap;
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
-import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
 import com.oracle.javafx.scenebuilder.kit.editor.job.wrap.FXOMObjectCourseComparator.UnidimensionalComparator;
 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
 import java.util.ArrayList;
@@ -53,15 +52,6 @@
     }
 
     @Override
-    protected List<Job> modifyChildrenJobs(final List<FXOMObject> children) {
-        return Collections.emptyList();
-    }
-
-    @Override
-    protected void modifyContainer(final List<FXOMObject> children) {
-    }
-
-    @Override
     protected Collection<FXOMObject> sortChildren(List<FXOMObject> children) {
         final List<FXOMObject> sorted = new ArrayList<>(children);
         Collections.sort(sorted, UnidimensionalComparator.of(Orientation.VERTICAL));