changeset 7885:d702e4ad5227

[SCENEBUILDER] Going on fixing DTL-6783: Rationalize job implementation between Hierarchy and Content Panels => Adapt Re-index jobs to the new architecture
author slions
date Wed, 03 Sep 2014 09:09:12 +0200
parents 258d08a27dc0
children 77ee61dc5811
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/gridpane/ReIndexColumnContentJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/gridpane/ReIndexRowContentJob.java
diffstat 2 files changed, 22 insertions(+), 96 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/gridpane/ReIndexColumnContentJob.java	Wed Sep 03 12:12:43 2014 +1200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/gridpane/ReIndexColumnContentJob.java	Wed Sep 03 09:09:12 2014 +0200
@@ -32,10 +32,9 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.gridpane;
 
 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.BatchDocumentJob;
 import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
 import com.oracle.javafx.scenebuilder.kit.editor.job.atomic.ModifyObjectJob;
-import com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument;
 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMInstance;
 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
 import com.oracle.javafx.scenebuilder.kit.metadata.Metadata;
@@ -48,9 +47,8 @@
 /**
  * Job invoked when re-indexing columns content.
  */
-public class ReIndexColumnContentJob extends Job {
+public class ReIndexColumnContentJob extends BatchDocumentJob {
 
-    private BatchJob subJob;
     private final int offset;
     private final FXOMObject targetGridPane;
     private final List<Integer> targetIndexes;
@@ -64,7 +62,6 @@
         this.offset = offset;
         this.targetGridPane = targetGridPane;
         this.targetIndexes = targetIndexes;
-        buildSubJobs();
     }
 
     public ReIndexColumnContentJob(
@@ -77,52 +74,12 @@
         this.targetGridPane = targetGridPane;
         this.targetIndexes = new ArrayList<>();
         this.targetIndexes.add(targetIndex);
-        buildSubJobs();
     }
 
     @Override
-    public boolean isExecutable() {
-        // When the columns are empty, there is no content to move and the 
-        // sub job list may be empty. 
-        // => we do not invoke subJob.isExecutable() here. 
-        return subJob != null;
-    }
+    protected List<Job> makeSubJobs() {
 
-    @Override
-    public void execute() {
-        final FXOMDocument fxomDocument = getEditorController().getFxomDocument();
-        assert isExecutable();
-        fxomDocument.beginUpdate();
-        subJob.execute();
-        fxomDocument.endUpdate();
-    }
-
-    @Override
-    public void undo() {
-        final FXOMDocument fxomDocument = getEditorController().getFxomDocument();
-        fxomDocument.beginUpdate();
-        subJob.undo();
-        fxomDocument.endUpdate();
-    }
-
-    @Override
-    public void redo() {
-        final FXOMDocument fxomDocument = getEditorController().getFxomDocument();
-        fxomDocument.beginUpdate();
-        subJob.redo();
-        fxomDocument.endUpdate();
-    }
-
-    @Override
-    public String getDescription() {
-        return "ReIndex Column Content"; //NOI18N
-    }
-
-    private void buildSubJobs() {
-
-        // Create sub job
-        subJob = new BatchJob(getEditorController(),
-                true /* shouldRefreshSceneGraph */, null);
+        final List<Job> result = new ArrayList<>();
 
         assert targetIndexes.isEmpty() == false;
         final DesignHierarchyMask targetGridPaneMask
@@ -141,8 +98,14 @@
                 int newIndexValue = targetIndex + offset;
                 final Job modifyJob = new ModifyObjectJob(
                         childInstance, vpm, newIndexValue, getEditorController());
-                subJob.addSubJob(modifyJob);
+                result.add(modifyJob);
             }
         }
+        return result;
+    }
+
+    @Override
+    protected String makeDescription() {
+        return "ReIndex Column Content"; //NOI18N
     }
 }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/gridpane/ReIndexRowContentJob.java	Wed Sep 03 12:12:43 2014 +1200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/gridpane/ReIndexRowContentJob.java	Wed Sep 03 09:09:12 2014 +0200
@@ -32,10 +32,9 @@
 package com.oracle.javafx.scenebuilder.kit.editor.job.gridpane;
 
 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.BatchDocumentJob;
 import com.oracle.javafx.scenebuilder.kit.editor.job.Job;
 import com.oracle.javafx.scenebuilder.kit.editor.job.atomic.ModifyObjectJob;
-import com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument;
 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMInstance;
 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
 import com.oracle.javafx.scenebuilder.kit.metadata.Metadata;
@@ -48,9 +47,8 @@
 /**
  * Job invoked when re-indexing rows content.
  */
-public class ReIndexRowContentJob extends Job {
+public class ReIndexRowContentJob extends BatchDocumentJob {
 
-    private BatchJob subJob;
     private final int offset;
     private final FXOMObject targetGridPane;
     private final List<Integer> targetIndexes;
@@ -64,7 +62,6 @@
         this.offset = offset;
         this.targetGridPane = targetGridPane;
         this.targetIndexes = targetIndexes;
-        buildSubJobs();
     }
 
     public ReIndexRowContentJob(
@@ -77,52 +74,12 @@
         this.targetGridPane = targetGridPane;
         this.targetIndexes = new ArrayList<>();
         this.targetIndexes.add(targetIndex);
-        buildSubJobs();
     }
 
     @Override
-    public boolean isExecutable() {
-        // When the rows are empty, there is no content to move and the 
-        // sub job list may be empty. 
-        // => we do not invoke subJob.isExecutable() here. 
-        return subJob != null;
-    }
+    protected List<Job> makeSubJobs() {
 
-    @Override
-    public void execute() {
-        final FXOMDocument fxomDocument = getEditorController().getFxomDocument();
-        assert isExecutable();
-        fxomDocument.beginUpdate();
-        subJob.execute();
-        fxomDocument.endUpdate();
-    }
-
-    @Override
-    public void undo() {
-        final FXOMDocument fxomDocument = getEditorController().getFxomDocument();
-        fxomDocument.beginUpdate();
-        subJob.undo();
-        fxomDocument.endUpdate();
-    }
-
-    @Override
-    public void redo() {
-        final FXOMDocument fxomDocument = getEditorController().getFxomDocument();
-        fxomDocument.beginUpdate();
-        subJob.redo();
-        fxomDocument.endUpdate();
-    }
-
-    @Override
-    public String getDescription() {
-        return "ReIndex Row Content"; //NOI18N
-    }
-
-    private void buildSubJobs() {
-
-        // Create sub job
-        subJob = new BatchJob(getEditorController(),
-                true /* shouldRefreshSceneGraph */, null);
+        final List<Job> result = new ArrayList<>();
 
         assert targetIndexes.isEmpty() == false;
         final DesignHierarchyMask targetGridPaneMask
@@ -141,8 +98,14 @@
                 int newIndexValue = targetIndex + offset;
                 final Job modifyJob = new ModifyObjectJob(
                         childInstance, vpm, newIndexValue, getEditorController());
-                subJob.addSubJob(modifyJob);
+                result.add(modifyJob);
             }
         }
+        return result;
+    }
+
+    @Override
+    protected String makeDescription() {
+        return "ReIndex Row Content"; //NOI18N
     }
 }