incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject svn commit: r1349560 [10/10] - in /incubator/flex/trunk: ./ frameworks/ frameworks/projects/airframework/ frameworks/projects/airframework/assets/ frameworks/projects/framework/ frameworks/projects/framework/assets/ frameworks/projects/framework/assets...
Date Tue, 12 Jun 2012 22:07:07 GMT
Modified: incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FXGCompiler.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FXGCompiler.java?rev=1349560&r1=1349559&r2=1349560&view=diff
==============================================================================
--- incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FXGCompiler.java (original)
+++ incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FXGCompiler.java Tue
Jun 12 22:06:59 2012
@@ -37,6 +37,7 @@ import com.adobe.fxg.dom.FXGNode;
 import com.adobe.fxg.util.FXGLocalizationUtil;
 import com.adobe.fxg.util.FXGLog;
 import com.adobe.fxg.util.FXGLogger;
+import com.adobe.internal.fxg.dom.GraphicNode;
 
 import flash.localization.LocalizationManager;
 import flash.util.FileUtils;
@@ -62,6 +63,7 @@ import flex2.compiler.mxml.reflect.TypeT
 import flex2.compiler.util.CompilerMessage;
 import flex2.compiler.util.MimeMappings;
 import flex2.compiler.util.MultiName;
+import flex2.compiler.util.NameFormatter;
 import flex2.compiler.util.NameMappings;
 import flex2.compiler.util.QName;
 import flex2.compiler.util.ThreadLocalToolkit;
@@ -564,10 +566,28 @@ public class FXGCompiler extends Abstrac
                 QName topLevelQName = getQNameFromSource(source);
                 unit.topLevelDefinitions.add(topLevelQName);
 
+                MultiName baseMultiName = MULTINAME_SPRITEVISUALELEMENT;
+                if (node instanceof GraphicNode)
+                {
+                	GraphicNode graphicNode = (GraphicNode)node;
+                	if (graphicNode.baseClassName != null)
+                	{
+                		String pkg = "";
+                		String baseClassName = graphicNode.baseClassName;
+                		String className = baseClassName;
+                		int lastDot = baseClassName.lastIndexOf(".");
+                		if (lastDot > -1)
+                		{
+                			pkg = baseClassName.substring(0, lastDot);
+                			className = baseClassName.substring(lastDot + 1);
+                		}
+                		baseMultiName = new MultiName(NameFormatter.toColon(pkg, className));
+                	}
+                }
                 // We add the base class for our generated skeleton here so that
                 // the type will be resolved after returning from parse1() and
                 // before we get to analyze2().
-                unit.inheritance.add(MULTINAME_SPRITEVISUALELEMENT);
+                unit.inheritance.add(baseMultiName);
             }
             catch (FXGException ex)
             {
@@ -600,6 +620,7 @@ public class FXGCompiler extends Abstrac
             // Determine whether we need to introduce text class dependencies
             FXGNode rootNode = (FXGNode)unit.getContext().getAttribute(FXG_DOM_ROOT);
             boolean hasTextGraphic = false;
+            String baseClassName = null;
             double version = 1.0;
 
             if (rootNode instanceof FlexGraphicNode)
@@ -608,11 +629,12 @@ public class FXGCompiler extends Abstrac
                 FXGVersion v = graphicNode.getVersion();
                 version = v != null ? v.asDouble() : 1.0;
                 hasTextGraphic = graphicNode.hasText;
+                baseClassName = graphicNode.baseClassName;
             }
 
             try
             {
-                generatedSource = generateSource(originalSource, symbolTable, version, hasTextGraphic);
+                generatedSource = generateSource(originalSource, symbolTable, version, hasTextGraphic,
baseClassName);
             }
             catch (IOException ex)
             {
@@ -689,7 +711,7 @@ public class FXGCompiler extends Abstrac
          * @param hasText - whether the document made use of text 
          */
         private Source generateSource(Source originalSource, SymbolTable symbolTable,
-                double version, boolean hasText) throws IOException
+                double version, boolean hasText, String baseClassName) throws IOException
         {
             // Derive package/class names from source name and location
             String className = originalSource.getShortName();
@@ -715,8 +737,20 @@ public class FXGCompiler extends Abstrac
                 buf.append("import spark.components.RichText;\n");
             }
 
-            buf.append("import spark.core.SpriteVisualElement;\n\n");
-            buf.append("public class ").append(className).append(" extends SpriteVisualElement\n{\n");
+            if (baseClassName != null)
+            {
+                buf.append("import ");
+                buf.append(baseClassName);
+                buf.append(";\n\n");
+                buf.append("public class ").append(className).append(" extends ");
+                buf.append(baseClassName);
+                buf.append("\n{\n");            	
+            }
+            else
+            {
+                buf.append("import spark.core.SpriteVisualElement;\n\n");
+                buf.append("public class ").append(className).append(" extends SpriteVisualElement\n{\n");
           	
+            }
             buf.append("    public function ").append(className).append("()\n");
             buf.append("    {\n");
             buf.append("        super();\n");

Modified: incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java?rev=1349560&r1=1349559&r2=1349560&view=diff
==============================================================================
--- incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java
(original)
+++ incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java
Tue Jun 12 22:06:59 2012
@@ -135,13 +135,29 @@ public class FlexFXG2SWFTranscoder exten
 
             DefineSprite sprite = (DefineSprite)transcode(graphicNode);
             graphicClass.setSymbol(sprite);
+            
+            // use specified className if specified
+            if (graphicNode.className != null)
+            	sprite.name = graphicNode.className;
 
             // Create a new sprite class to map to this Graphic's DefineSprite
             StringBuilder buf = new StringBuilder(512);
             buf.append("package ").append(packageName).append("\n");
             buf.append("{\n\n");
-            buf.append("import spark.core.SpriteVisualElement;\n\n");
-            buf.append("public class ").append(className).append(" extends SpriteVisualElement\n");
+            if (graphicNode.baseClassName != null)
+            {
+            	buf.append("import ");
+            	buf.append(graphicNode.baseClassName);
+            	buf.append(";\n\n");
+            	buf.append("public class ").append(className).append(" extends ");
+            	buf.append(graphicNode.baseClassName);
+            	buf.append("\n");
+            }
+            else
+            {
+            	buf.append("import spark.core.SpriteVisualElement;\n\n");
+            	buf.append("public class ").append(className).append(" extends SpriteVisualElement\n");
+            }
             buf.append("{\n");
             buf.append("    public function ").append(className).append("()\n");
             buf.append("    {\n");

Modified: incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/dom/GraphicNode.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/dom/GraphicNode.java?rev=1349560&r1=1349559&r2=1349560&view=diff
==============================================================================
--- incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/dom/GraphicNode.java
(original)
+++ incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/dom/GraphicNode.java
Tue Jun 12 22:06:59 2012
@@ -39,6 +39,9 @@ import com.adobe.internal.fxg.dom.types.
  */
 public class GraphicNode extends AbstractFXGNode implements MaskableNode
 {
+	public static final String APACHE_FLEX_CLASSNAME = "className";
+	public static final String APACHE_FLEX_BASECLASSNAME = "baseClassName";
+	
     private FXGVersion compilerVersion = null; // The version of FXG compiler.
     private String profile;
     private String documentName = null;
@@ -74,6 +77,12 @@ public class GraphicNode extends Abstrac
     
     /** The view height. */
     public double viewHeight = Double.NaN;
+
+    /** an optional class name */
+    public String className = null;
+    
+    /** an optional base class name */
+    public String baseClassName = null;
     
     /** The mask type. */
     public MaskType maskType = MaskType.CLIP;
@@ -358,6 +367,14 @@ public class GraphicNode extends Abstrac
         {
             luminosityClip = DOMParserHelper.parseBoolean(this, value, name); 
         }        
+        else if (APACHE_FLEX_CLASSNAME.equals(name))
+        {
+            className = value; 
+        }        
+        else if (APACHE_FLEX_BASECLASSNAME.equals(name))
+        {
+            baseClassName = value; 
+        }        
         else
         {
             super.setAttribute(name, value);

Modified: incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/sax/FXGSAXScanner.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/sax/FXGSAXScanner.java?rev=1349560&r1=1349559&r2=1349560&view=diff
==============================================================================
--- incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/sax/FXGSAXScanner.java
(original)
+++ incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/sax/FXGSAXScanner.java
Tue Jun 12 22:06:59 2012
@@ -55,6 +55,9 @@ import static com.adobe.fxg.FXGConstants
  */
 public class FXGSAXScanner extends DefaultHandler
 {
+    // Namespaces
+    public static final String APACHE_FLEX_NAMESPACE = "http://ns.apache.org/flex/2012";
+    
     private static boolean REJECT_MAJOR_VERSION_MISMATCH = false;
     
     // A special case needed to short circuit GroupNode creation inside a
@@ -224,7 +227,9 @@ public class FXGSAXScanner extends Defau
         for (int i = 0; i < attributes.getLength(); i++)
         {
             String attributeURI = attributes.getURI(i);
-            if (attributeURI == null || attributeURI == "" || isFXGNamespace(attributeURI))
+            if (attributeURI == null || attributeURI == "" || 
+            		isFXGNamespace(attributeURI) || 
+            		isApacheFlexNamespace(attributeURI))
             {
                 String attributeName = attributes.getLocalName(i);
                 String attributeValue = attributes.getValue(i);
@@ -402,6 +407,15 @@ public class FXGSAXScanner extends Defau
     }
 
     /**
+     * @param uri - the namespace URI to check
+     * @return whether the given namespace URI is considered an Apache Flex namespace. 
+     */
+    protected boolean isApacheFlexNamespace(String uri)
+    {
+        return APACHE_FLEX_NAMESPACE.equals(uri);
+    }
+
+    /**
      * Specifies that a particular element should be skipped while scanning for
      * tokens in an FXG document. All of the element's attributes and child
      * nodes will be skipped too.



Mime
View raw message