flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [2/2] git commit: [flex-falcon] - Handle CSS in FalconJX
Date Wed, 24 Apr 2013 17:39:33 GMT
Handle CSS in FalconJX


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/6a164f39
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/6a164f39
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/6a164f39

Branch: refs/heads/develop
Commit: 6a164f397daf81c680ff65cb117f4b35127a1472
Parents: 9a416a2
Author: Alex Harui <aharui@apache.org>
Authored: Wed Apr 24 10:23:04 2013 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Wed Apr 24 10:23:04 2013 -0700

----------------------------------------------------------------------
 .../internal/codegen/mxml/MXMLBlockWalker.java     |   20 ++++++++
 .../codegen/mxml/flexjs/MXMLFlexJSPublisher.java   |   36 +++++++++++---
 .../internal/visitor/mxml/MXMLNodeSwitch.java      |    5 ++-
 .../compiler/visitor/mxml/IMXMLBlockVisitor.java   |    5 ++-
 4 files changed, 56 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6a164f39/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLBlockWalker.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLBlockWalker.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLBlockWalker.java
index f3d439f..9c968e9 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLBlockWalker.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLBlockWalker.java
@@ -23,6 +23,9 @@ import java.util.List;
 
 import org.apache.flex.compiler.codegen.as.IASEmitter;
 import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.css.ICSSDocument;
+import org.apache.flex.compiler.css.ICSSRule;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
 import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.projects.IASProject;
 import org.apache.flex.compiler.tree.as.IASNode;
@@ -43,6 +46,7 @@ import org.apache.flex.compiler.tree.mxml.IMXMLNumberNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLScriptNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLStringNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLStyleNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLStyleSpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLUintNode;
 import org.apache.flex.compiler.units.ICompilationUnit;
@@ -51,6 +55,8 @@ import org.apache.flex.compiler.visitor.IBlockWalker;
 import org.apache.flex.compiler.visitor.mxml.IMXMLBlockVisitor;
 import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
 
+import com.google.common.collect.ImmutableList;
+
 /**
  * @author Michael Schmalle
  * @author Erik de Bruin
@@ -253,6 +259,20 @@ public class MXMLBlockWalker implements IMXMLBlockVisitor, IMXMLBlockWalker
     }
 
     @Override
+    public void visitStyleBlock(IMXMLStyleNode node)
+    {
+        ICSSDocument css = node.getCSSDocument(errors);
+        StringBuilder sb = new StringBuilder();
+        ImmutableList<ICSSRule> rules = css.getRules();
+        for (ICSSRule rule : rules)
+        {
+            sb.append(rule.toString());
+            sb.append("\n\n");
+        }
+        ((FlexJSProject)project).cssDocument += sb.toString();
+    }
+    
+    @Override
     public void visitStyleSpecifier(IMXMLStyleSpecifierNode node)
     {
         debug("visitStyleSpecifier()");

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6a164f39/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
index 9f461fb..7636d9f 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
@@ -9,8 +9,12 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.io.filefilter.DirectoryFileFilter;
+import org.apache.commons.io.filefilter.FileFileFilter;
+import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.apache.commons.io.filefilter.IOFileFilter;
 import org.apache.commons.io.filefilter.RegexFileFilter;
 import org.apache.flex.compiler.codegen.js.IJSPublisher;
 import org.apache.flex.compiler.config.Configuration;
@@ -44,7 +48,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
     }
 
     private FlexJSProject project;
-    
+
     private boolean isMarmotinniRun;
 
     @Override
@@ -81,6 +85,9 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
     public void publish() throws IOException
     {
         final String intermediateDirPath = outputFolder.getPath();
+        final File intermediateDir = new File(intermediateDirPath);
+        File srcDir = new File(configuration.getTargetFile());
+        srcDir = srcDir.getParentFile();
 
         final String projectName = FilenameUtils.getBaseName(configuration
                 .getTargetFile());
@@ -157,6 +164,18 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
             copyFile(closureTPSrcLibDirPath, closureTPTgtLibDirPath);
         }
 
+        IOFileFilter pngSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
+                FileFilterUtils.suffixFileFilter(".png"));
+        IOFileFilter gifSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
+                FileFilterUtils.suffixFileFilter(".gif"));
+        IOFileFilter jpgSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
+                FileFilterUtils.suffixFileFilter(".jpg"));
+        IOFileFilter assetFiles = FileFilterUtils.or(pngSuffixFilter,
+                jpgSuffixFilter, gifSuffixFilter);
+
+        FileUtils.copyDirectory(srcDir, intermediateDir, assetFiles);
+        FileUtils.copyDirectory(srcDir, releaseDir, assetFiles);
+
         File srcDeps = new File(depsSrcFilePath);
 
         final List<SourceFile> deps = new ArrayList<SourceFile>();
@@ -263,7 +282,8 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         htmlFile.append("<head>\n");
         htmlFile.append("\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n");
         htmlFile.append("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
-        htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"" + projectName
+ ".css\">\n");
+        htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\""
+                + projectName + ".css\">\n");
 
         if (type == "intermediate")
         {
@@ -312,7 +332,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         htmlFile.append("\t\t\treturn value >>> 0;\n");
         htmlFile.append("\t\t};\n");
         htmlFile.append("\t\t\n");
-        
+
         htmlFile.append("\t\tnew ");
         htmlFile.append(projectName);
         htmlFile.append("()");
@@ -324,14 +344,14 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         writeFile(dirPath + File.separator + "index.html", htmlFile.toString(),
                 false);
     }
-    
+
     private void writeCSS(String projectName, String dirPath)
-    throws IOException
+            throws IOException
     {
         StringBuilder cssFile = new StringBuilder();
         cssFile.append(project.cssDocument);
-        
-        writeFile(dirPath + File.separator + projectName + ".css", cssFile.toString(),
-                false);
+
+        writeFile(dirPath + File.separator + projectName + ".css",
+                cssFile.toString(), false);
     }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6a164f39/compiler.jx/src/org/apache/flex/compiler/internal/visitor/mxml/MXMLNodeSwitch.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/visitor/mxml/MXMLNodeSwitch.java
b/compiler.jx/src/org/apache/flex/compiler/internal/visitor/mxml/MXMLNodeSwitch.java
index 51a4e23..2d26374 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/visitor/mxml/MXMLNodeSwitch.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/visitor/mxml/MXMLNodeSwitch.java
@@ -34,6 +34,7 @@ import org.apache.flex.compiler.tree.mxml.IMXMLNumberNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLScriptNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLStringNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLStyleNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLStyleSpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLUintNode;
 import org.apache.flex.compiler.visitor.IASNodeStrategy;
@@ -106,6 +107,9 @@ public class MXMLNodeSwitch implements IASNodeStrategy
         case MXMLUintID:
             visitor.visitUint((IMXMLUintNode) node);
             break;
+        case MXMLStyleID:
+            visitor.visitStyleBlock((IMXMLStyleNode)node);
+            break;
 
         case MXMLApplicationID:
         case MXMLBindingID:
@@ -140,7 +144,6 @@ public class MXMLNodeSwitch implements IASNodeStrategy
         //case MXMLRepeaterID:
         case MXMLResourceID:
         case MXMLStateID:
-        case MXMLStyleID:
         case MXMLVectorID:
         case MXMLWebServiceID:
         case MXMLWebServiceOperationID:

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6a164f39/compiler.jx/src/org/apache/flex/compiler/visitor/mxml/IMXMLBlockVisitor.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/visitor/mxml/IMXMLBlockVisitor.java
b/compiler.jx/src/org/apache/flex/compiler/visitor/mxml/IMXMLBlockVisitor.java
index 98c8958..4e347f0 100644
--- a/compiler.jx/src/org/apache/flex/compiler/visitor/mxml/IMXMLBlockVisitor.java
+++ b/compiler.jx/src/org/apache/flex/compiler/visitor/mxml/IMXMLBlockVisitor.java
@@ -34,6 +34,7 @@ import org.apache.flex.compiler.tree.mxml.IMXMLNumberNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLScriptNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLStringNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLStyleNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLStyleSpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLUintNode;
 import org.apache.flex.compiler.units.ICompilationUnit;
@@ -72,6 +73,8 @@ public interface IMXMLBlockVisitor extends IBlockVisitor
 
     void visitScript(IMXMLScriptNode node);
 
+    void visitStyleBlock(IMXMLStyleNode node);
+
     void visitStyleSpecifier(IMXMLStyleSpecifierNode node);
 
     //--------------------------------------------------------------------------
@@ -91,5 +94,5 @@ public interface IMXMLBlockVisitor extends IBlockVisitor
     //--------------------------------------------------------------------------
 
     void visitLiteral(IMXMLLiteralNode node);
-
+    
 }


Mime
View raw message