changeset 7807:d83e0326080c

[SCENEBUILDER] Going on fixing DTL-6783: Rationalize job implementation between Hierarchy and Content Panels => Adapt Import File job
author slions
date Wed, 27 Aug 2014 10:06:11 +0200
parents 7e3f564c5a26
children b12c2b162ef1
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/ImportFileJob.java
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/ImportFileJob.java	Wed Aug 27 09:44:27 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/ImportFileJob.java	Wed Aug 27 10:06:11 2014 +0200
@@ -33,8 +33,8 @@
 
 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.FXOMNodes;
@@ -48,13 +48,13 @@
 /**
  *
  */
-public class ImportFileJob extends CompositeJob {
+public class ImportFileJob extends BatchSelectionJob {
 
     private final File file;
-    private FXOMObject targetObject;
+    private FXOMObject newObject, targetObject;
 
     public ImportFileJob(File file, EditorController editorController) {
-        super(editorController, true /* shouldRefreshSceneGraph */, false /* shouldUpdateSelection */);
+        super(editorController);
 
         assert file != null;
         this.file = file;
@@ -64,15 +64,11 @@
         return targetObject;
     }
 
-    /*
-     * CompositeJob
-     */
     @Override
     protected List<Job> makeSubJobs() {
         final List<Job> result = new ArrayList<>();
 
         final FXOMDocument targetDocument = getEditorController().getFxomDocument();
-        final FXOMObject newObject;
 
         try {
             newObject = FXOMNodes.newObject(targetDocument, file);
@@ -87,7 +83,6 @@
 
                 if (rootObject == null) {
                     result.add(new SetDocumentRootJob(newObject, getEditorController()));
-                    result.add(new UpdateSelectionJob(newObject, getEditorController()));
                 } else {
                     final Selection selection = getEditorController().getSelection();
                     if (selection.isEmpty() || selection.isSelected(rootObject)) {
@@ -106,7 +101,6 @@
                                 targetObject,
                                 targetMask.getSubComponentCount(),
                                 getEditorController()));
-                        result.add(new UpdateSelectionJob(newObject, getEditorController()));
                     }
                 }
             }
@@ -120,4 +114,11 @@
     protected String makeDescription() {
         return I18N.getString("import.from.file", file.getName());
     }
+
+    @Override
+    protected AbstractSelectionGroup getNewSelectionGroup() {
+        final List<FXOMObject> fxomObjects = new ArrayList<>();
+        fxomObjects.add(newObject);
+        return new ObjectSelectionGroup(fxomObjects, newObject, null);
+    }
 }