changeset 7808:b12c2b162ef1

[SCENEBUILDER] Going on fixing DTL-6783: Rationalize job implementation between Hierarchy and Content Panels => Adapt Include File job
author slions
date Wed, 27 Aug 2014 10:07:00 +0200
parents d83e0326080c
children 586ea960003a
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/IncludeFileJob.java
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/IncludeFileJob.java	Wed Aug 27 10:06:11 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/IncludeFileJob.java	Wed Aug 27 10:07:00 2014 +0200
@@ -33,8 +33,9 @@
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
 import com.oracle.javafx.scenebuilder.kit.editor.i18n.I18N;
-import com.oracle.javafx.scenebuilder.kit.editor.job.v2.CompositeJob;
 import com.oracle.javafx.scenebuilder.kit.editor.job.v2.UpdateSelectionJob;
+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;
 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument;
 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMIntrinsic;
@@ -51,13 +52,14 @@
 /**
  *
  */
-public class IncludeFileJob extends CompositeJob {
+public class IncludeFileJob extends BatchSelectionJob {
 
     private final File file;
     private FXOMObject targetObject;
+    private FXOMIntrinsic newInclude;
 
     public IncludeFileJob(File file, EditorController editorController) {
-        super(editorController, true /* shouldRefreshSceneGraph */, false /* shouldUpdateSelection */);
+        super(editorController);
 
         assert file != null;
         this.file = file;
@@ -67,9 +69,6 @@
         return targetObject;
     }
 
-    /*
-     * CompositeJob
-     */
     @Override
     protected List<Job> makeSubJobs() {
         final List<Job> result = new ArrayList<>();
@@ -82,7 +81,7 @@
             // Cannot include in non saved document
             // Cannot include same file as document one which will create cyclic reference
             if (documentURL != null && URLUtils.equals(documentURL, fileURL) == false) {
-                final FXOMIntrinsic newInclude = FXOMNodes.newInclude(targetDocument, file);
+                newInclude = FXOMNodes.newInclude(targetDocument, file);
 
                 // newInclude is null when file is empty
                 if (newInclude != null) {
@@ -125,4 +124,11 @@
     protected String makeDescription() {
         return I18N.getString("include.file", file.getName());
     }
+
+    @Override
+    protected AbstractSelectionGroup getNewSelectionGroup() {
+        final List<FXOMObject> fxomObjects = new ArrayList<>();
+        fxomObjects.add(newInclude);
+        return new ObjectSelectionGroup(fxomObjects, newInclude, null);
+    }
 }