Author: simoneg
Date: Wed Jul 14 02:48:52 2010
New Revision: 963929

URL: http://svn.apache.org/viewvc?rev=963929&view=rev
Log:
Support for better discovery of nested HtmlProducers
More modularized functions for compounds

Modified:
    
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/CompoundableProducer.java
    
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/CompoundableProducerImpl.aj

Modified: 
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/CompoundableProducer.java
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/CompoundableProducer.java?rev=963929&r1=963928&r2=963929&view=diff
==============================================================================
--- 
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/CompoundableProducer.java
 (original)
+++ 
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/CompoundableProducer.java
 Wed Jul 14 02:48:52 2010
@@ -18,7 +18,7 @@ package org.apache.magma.website;
 
 import java.util.List;
 
-public interface CompoundableProducer {
+public interface CompoundableProducer extends ProducerWithChildren<Producer> {
        
        public CompoundableProducer compoundWith(Producer other, CompoundType 
type);
        public CompoundableProducer compoundCssClass(String cssClass, 
CompoundType type);

Modified: 
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/CompoundableProducerImpl.aj
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/CompoundableProducerImpl.aj?rev=963929&r1=963928&r2=963929&view=diff
==============================================================================
--- 
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/CompoundableProducerImpl.aj
 (original)
+++ 
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/CompoundableProducerImpl.aj
 Wed Jul 14 02:48:52 2010
@@ -55,6 +55,7 @@ public aspect CompoundableProducerImpl {
                rel.type = t;
                if (compound == null) compound = new 
ArrayList<CompoundRelation>();
                compound.add(rel);
+               addChild(p);
                return this;
        }
        
@@ -72,12 +73,16 @@ public aspect CompoundableProducerImpl {
                Iterator<CompoundRelation> iter = compound.iterator();
                while (iter.hasNext()) {
                        CompoundRelation rel = iter.next();
-                       if (rel.type == type) iter.remove();
+                       if (rel.type == type) {
+                               removeChild(rel.prod);
+                               iter.remove();
+                       }
                }
        }
        
        public void CompoundableProducer.removeCompounded(Producer producer) {
                if (compound == null) return;
+               removeChild(producer);
                Iterator<CompoundRelation> iter = compound.iterator();
                while (iter.hasNext()) {
                        CompoundRelation rel = iter.next();
@@ -151,7 +156,7 @@ public aspect CompoundableProducerImpl {
                }
        }
        
-       private void compoundZone(CompoundableProducer prod, CompoundType side, 
Writer stream) throws IOException {
+       public void compoundZone(CompoundableProducer prod, CompoundType side, 
Writer stream) throws IOException {
                List<Producer> list = prod.findCompoundedOn(side);
                if (!list.isEmpty()) {
                        String addcss = null;
@@ -161,28 +166,58 @@ public aspect CompoundableProducerImpl {
                        openWrapper(addcss, stream, side);
                        for (Producer producer : list) {
                                if (producer instanceof HtmlProducer) {
-                                       if (producer instanceof ContextOwner) {
-                                               SubRunningContext context = 
((ContextOwner)producer).getContext();
-                                               context.push("CompoundZone");
-                                               context.push(side.name());
-                                       }
-                                       try {
-                                               openWrapper((HtmlProducer) 
producer, stream, side);
-                                               
((HtmlProducer)producer).produce(stream);
-                                               closeWrapper(stream);
-                                       } finally {
-                                               if (producer instanceof 
ContextOwner) {
-                                                       SubRunningContext 
context = ((ContextOwner)producer).getContext();
-                                                       context.popString();
-                                                       context.popString();
-                                               }
-                                       }
+                                       sendCompounded((HtmlProducer)producer, 
side, stream);
                                }
                        }
                        closeWrapper(stream);
                }
        }
        
+       public void sendCompounded(HtmlProducer producer, CompoundType side, 
Writer stream) throws IOException {
+               if (producer instanceof ContextOwner) {
+                       SubRunningContext context = 
((ContextOwner)producer).getContext();
+                       context.push("CompoundZone");
+                       context.push(side.name());
+               }
+               try {
+                       openWrapper((HtmlProducer) producer, stream, side);
+                       ((HtmlProducer)producer).produce(stream);
+                       closeWrapper(stream);
+               } finally {
+                       if (producer instanceof ContextOwner) {
+                               SubRunningContext context = 
((ContextOwner)producer).getContext();
+                               context.popString();
+                               context.popString();
+                       }
+               }
+               
+       }
+       
+       public void HtmlProducer.produceWithoutCompound(Writer out) throws 
IOException {
+               // Hack to avoid compounding on ajax requests
+               this.compounding = true;
+               try {
+                       this.produce(out);
+               } finally {
+                       this.compounding = false;                       
+               }
+       }
+
+       public void Producer.produceWithoutCompound(OutputStream out) throws 
IOException {
+               if (!(this instanceof CompoundableProducer)) {
+                       this.produce(out);
+                       return;
+               }
+               CompoundableProducer comp = (CompoundableProducer)this;
+               // Hack to avoid compounding on ajax requests
+               comp.compounding = true;
+               try {
+                       this.produce(out);
+               } finally {
+                       comp.compounding = false;                       
+               }
+       }
+       
        void around(HtmlProducer orig, Writer stream) throws IOException : 
execution(void HtmlProducer+.produce(Writer)) && args(stream) && this(orig) {
                if (!(orig instanceof CompoundableProducer)) {
                        proceed(orig, stream);
@@ -254,17 +289,17 @@ public aspect CompoundableProducerImpl {
        }
        
        
-       protected void openWrapper(HtmlProducer prod, Writer out, CompoundType 
type) throws IOException {
+       public void openWrapper(HtmlProducer prod, Writer out, CompoundType 
type) throws IOException {
                out.write("<div class=\"" + 
Template.computePartialProducerClasses(prod) + type.name() + "\">");
        }
 
-       protected void openWrapper(String additionalClasses, Writer out, 
CompoundType type) throws IOException {
+       public void openWrapper(String additionalClasses, Writer out, 
CompoundType type) throws IOException {
                if (additionalClasses == null) additionalClasses = "";
                out.write("<div class=\"CompoundZone " + type.name() + " " + 
additionalClasses + "\">");
        }
        
        
-       protected void closeWrapper(Writer out) throws IOException {
+       public void closeWrapper(Writer out) throws IOException {
                out.write("</div>");
        }
        



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to