changeset 7940:64c45eaad799

[SCENEBUILDER] added FXOMObject.collectReferences() method (with 'scope' parameter).
author eric.le.ponner <eric.le.ponner@oracle.com>
date Tue, 02 Sep 2014 12:53:35 +0200
parents b0a0f059cc4e
children b798513fd328
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMCollection.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMInstance.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMIntrinsic.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMObject.java
diffstat 4 files changed, 60 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMCollection.java	Mon Sep 01 19:32:54 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMCollection.java	Tue Sep 02 12:53:35 2014 +0200
@@ -181,6 +181,15 @@
     }
 
     @Override
+    protected void collectReferences(String source, FXOMObject scope, List<FXOMNode> result) {
+        if ((scope == null) || (scope != this)) {
+            for (FXOMObject i : items) {
+                i.collectReferences(source, scope, result);
+            }
+        }
+    }
+
+    @Override
     public FXOMNode lookupFirstReference(String fxId, FXOMObject scope) {
         FXOMNode result;
         
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMInstance.java	Mon Sep 01 19:32:54 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMInstance.java	Tue Sep 02 12:53:35 2014 +0200
@@ -34,6 +34,7 @@
 import com.oracle.javafx.scenebuilder.kit.fxom.glue.GlueElement;
 import com.oracle.javafx.scenebuilder.kit.metadata.util.PrefixedValue;
 import com.oracle.javafx.scenebuilder.kit.metadata.util.PropertyName;
+import com.oracle.javafx.scenebuilder.kit.util.JavaLanguage;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -335,6 +336,30 @@
     }
 
     @Override
+    protected void collectReferences(String source, FXOMObject scope, List<FXOMNode> result) {
+        if ((scope == null) || (scope != this)) {
+            for (FXOMProperty p : properties.values()) {
+                if (p instanceof FXOMPropertyC) {
+                    for (FXOMObject v : ((FXOMPropertyC)p).getValues()) {
+                        v.collectReferences(source, scope, result);
+                    }
+                } else if (p instanceof FXOMPropertyT) {
+                    final FXOMPropertyT pt = (FXOMPropertyT) p;
+                    final PrefixedValue pv = new PrefixedValue(pt.getValue());
+                    if (pv.isExpression()) {
+                        final String suffix = pv.getSuffix();
+                        if (JavaLanguage.isIdentifier(suffix)) {
+                            if ((source == null) || source.equals(suffix)) {
+                                result.add(pt);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
     protected void collectIncludes(String source, List<FXOMIntrinsic> result) {
         for (FXOMProperty p : properties.values()) {
             if (p instanceof FXOMPropertyC) {
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMIntrinsic.java	Mon Sep 01 19:32:54 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMIntrinsic.java	Tue Sep 02 12:53:35 2014 +0200
@@ -62,7 +62,7 @@
         this.sourceSceneGraphObject = targetSceneGraphObject;
     }
     
-    FXOMIntrinsic(FXOMDocument document, Type type, String source) {
+    public FXOMIntrinsic(FXOMDocument document, Type type, String source) {
         super(document, makeTagNameFromType(type));
         getGlueElement().getAttributes().put("source", source);
     }
@@ -205,6 +205,18 @@
     }
 
     @Override
+    protected void collectReferences(String source, FXOMObject scope, List<FXOMNode> result) {
+        assert result != null;
+        
+        if ((scope == null) || (scope != this)) {
+            if ((getType() == Type.FX_REFERENCE) 
+                    && ((source == null) || source.equals(getSource()))) {
+                result.add(this);
+            }
+        }
+    }
+
+    @Override
     protected void collectIncludes(String source, List<FXOMIntrinsic> result) {
         assert result != null;
         
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMObject.java	Mon Sep 01 19:32:54 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/fxom/FXOMObject.java	Tue Sep 02 12:53:35 2014 +0200
@@ -391,7 +391,19 @@
     }
     
     protected abstract void collectReferences(String source, List<FXOMIntrinsic> result);
-
+    
+    public List<FXOMNode> collectReferences(String source, FXOMObject scope) {
+        assert source != null;
+        
+        final List<FXOMNode> result = new ArrayList<>();
+        
+        collectReferences(source, scope, result);
+        
+        return result;
+    }
+    
+    protected abstract void collectReferences(String source, FXOMObject scope, List<FXOMNode> result);
+    
     public abstract FXOMNode lookupFirstReference(String fxId, FXOMObject scope);
 
     public List<FXOMIntrinsic> collectIncludes(String source) {