changeset 7818:9627f50ee3fe

make BatchSelectionJob extends BatchDocumentJob
author slions
date Wed, 27 Aug 2014 12:22:49 +0200
parents 850d81afb10f
children a707fa9c9186
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/BatchDocumentJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/BatchSelectionJob.java
diffstat 2 files changed, 8 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/BatchDocumentJob.java	Wed Aug 27 12:15:23 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/BatchDocumentJob.java	Wed Aug 27 12:22:49 2014 +0200
@@ -65,7 +65,7 @@
     }
 
     @Override
-    public final void execute() {
+    public void execute() {
         final FXOMDocument fxomDocument
                 = getEditorController().getFxomDocument();
         fxomDocument.beginUpdate();
@@ -76,7 +76,7 @@
     }
 
     @Override
-    public final void undo() {
+    public void undo() {
         final FXOMDocument fxomDocument
                 = getEditorController().getFxomDocument();
         fxomDocument.beginUpdate();
@@ -87,7 +87,7 @@
     }
 
     @Override
-    public final void redo() {
+    public void redo() {
         final FXOMDocument fxomDocument
                 = getEditorController().getFxomDocument();
         fxomDocument.beginUpdate();
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/BatchSelectionJob.java	Wed Aug 27 12:15:23 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/BatchSelectionJob.java	Wed Aug 27 12:22:49 2014 +0200
@@ -34,8 +34,6 @@
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
 import com.oracle.javafx.scenebuilder.kit.editor.selection.AbstractSelectionGroup;
 import com.oracle.javafx.scenebuilder.kit.editor.selection.Selection;
-import com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument;
-import java.util.Collections;
 import java.util.List;
 
 /**
@@ -43,9 +41,8 @@
  *
  * The sub jobs are FIRST all created, THEN executed.
  */
-public abstract class BatchSelectionJob extends CompositeJob2 {
+public abstract class BatchSelectionJob extends BatchDocumentJob {
 
-    private List<Job> subJobs;
     private AbstractSelectionGroup oldSelectionGroup;
     private AbstractSelectionGroup newSelectionGroup;
 
@@ -60,36 +57,16 @@
     protected abstract AbstractSelectionGroup getNewSelectionGroup();
 
     @Override
-    public final List<Job> getSubJobs() {
-        if (subJobs == null) {
-            subJobs = makeSubJobs();
-            assert subJobs != null;
-            subJobs = Collections.unmodifiableList(subJobs);
-        }
-        return subJobs;
-    }
-
-    @Override
-    public final boolean isExecutable() {
-        return getSubJobs().isEmpty() == false;
-    }
-
-    @Override
     public final void execute() {
         final Selection selection = getEditorController().getSelection();
-        final FXOMDocument fxomDocument = getEditorController().getFxomDocument();
         try {
-            fxomDocument.beginUpdate();
             selection.beginUpdate();
             oldSelectionGroup = selection.getGroup() == null ? null
                     : selection.getGroup().clone();
-            for (Job subJob : getSubJobs()) {
-                subJob.execute();
-            }
+            super.execute();
             newSelectionGroup = getNewSelectionGroup();
             selection.select(newSelectionGroup);
             selection.endUpdate();
-            fxomDocument.endUpdate();
 
         } catch (CloneNotSupportedException x) {
             // Emergency code
@@ -100,30 +77,21 @@
     @Override
     public final void undo() {
         final Selection selection = getEditorController().getSelection();
-        final FXOMDocument fxomDocument = getEditorController().getFxomDocument();
-        fxomDocument.beginUpdate();
         selection.beginUpdate();
-        for (int i = getSubJobs().size() - 1; i >= 0; i--) {
-            getSubJobs().get(i).undo();
-        }
+        super.undo();
         selection.select(oldSelectionGroup);
         selection.endUpdate();
-        fxomDocument.endUpdate();
     }
 
     @Override
     public final void redo() {
         final Selection selection = getEditorController().getSelection();
-        final FXOMDocument fxomDocument = getEditorController().getFxomDocument();
-        fxomDocument.beginUpdate();
         selection.beginUpdate();
-        for (Job subJob : getSubJobs()) {
-            subJob.redo();
-        }
+        super.redo();
         selection.select(newSelectionGroup);
         selection.endUpdate();
-        fxomDocument.endUpdate();
     }
 
+    @Override
     protected abstract List<Job> makeSubJobs();
 }