changeset 7893:f43dd33a649f

[SCENEBUILDER] Going on fixing DTL-6783: Rationalize job implementation between Hierarchy and Content Panels => Adapt CutSelection job
author slions
date Thu, 28 Aug 2014 08:55:45 +0200
parents 5e4ce148e333
children b259507d839f
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/CutSelectionJob.java
diffstat 1 files changed, 24 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/CutSelectionJob.java	Thu Aug 28 11:16:55 2014 +1200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/CutSelectionJob.java	Thu Aug 28 08:55:45 2014 +0200
@@ -33,45 +33,47 @@
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController.ControlAction;
+import com.oracle.javafx.scenebuilder.kit.editor.selection.AbstractSelectionGroup;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  *
  */
-public class CutSelectionJob extends Job {
+public class CutSelectionJob extends BatchSelectionJob {
 
-    private final DeleteSelectionJob deleteSelectionSubJob;
+    private DeleteSelectionJob deleteSelectionSubJob;
 
     public CutSelectionJob(EditorController editorController) {
         super(editorController);
-        deleteSelectionSubJob = new DeleteSelectionJob(editorController);
     }
 
     @Override
-    public boolean isExecutable() {
-        return deleteSelectionSubJob.isExecutable()
-                && getEditorController().canPerformControlAction(ControlAction.COPY);
+    protected AbstractSelectionGroup getNewSelectionGroup() {
+        // Selection emptied
+        return null;
     }
 
     @Override
-    public void execute() {
-        // Update clipboard with current selection BEFORE EXECUTING DELETE job
-        assert getEditorController().canPerformControlAction(ControlAction.COPY);
-        getEditorController().performControlAction(ControlAction.COPY);
-        deleteSelectionSubJob.execute();
+    protected List<Job> makeSubJobs() {
+
+        final List<Job> result = new ArrayList<>();
+        if (getEditorController().canPerformControlAction(ControlAction.COPY)) {
+            // Update clipboard with current selection BEFORE EXECUTING DELETE job
+            assert getEditorController().canPerformControlAction(ControlAction.COPY);
+            getEditorController().performControlAction(ControlAction.COPY);
+
+            deleteSelectionSubJob = new DeleteSelectionJob(getEditorController());
+            if (deleteSelectionSubJob.isExecutable()) {
+                result.add(deleteSelectionSubJob);
+            }
+        }
+        return result;
     }
 
     @Override
-    public void undo() {
-        deleteSelectionSubJob.undo();
-    }
-
-    @Override
-    public void redo() {
-        deleteSelectionSubJob.redo();
-    }
-
-    @Override
-    public String getDescription() {
+    protected String makeDescription() {
+        assert deleteSelectionSubJob != null;
         return deleteSelectionSubJob.getDescription();
     }
 }