continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r170504 - in /maven/continuum/trunk/continuum-web/src/main: java/org/apache/maven/continuum/web/tool/FormicaTool.java resources/forms/continuumProject.xml resources/templates/screens/Summary.vm
Date Tue, 17 May 2005 02:50:11 GMT
Author: jvanzyl
Date: Mon May 16 19:50:11 2005
New Revision: 170504

URL: http://svn.apache.org/viewcvs?rev=170504&view=rev
Log:
o adding formicaTool.enableOperation() which determines if a summary 
  operation should be enabled. used in web summary view right now to 
  determines if the "Results" operation should be enabled.
  
o summary template changed to evaluate whether an operation should
  be enabled.
  
o continuumProject.xml form altered to have an enable expression
  for the "Results" operation.
  

Modified:
    maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/FormicaTool.java
    maven/continuum/trunk/continuum-web/src/main/resources/forms/continuumProject.xml
    maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/Summary.vm

Modified: maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/FormicaTool.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/FormicaTool.java?rev=170504&r1=170503&r2=170504&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/FormicaTool.java
(original)
+++ maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/FormicaTool.java
Mon May 16 19:50:11 2005
@@ -105,6 +105,56 @@
         return getItem( form, form.getElement( se.getId() ), item );
     }
 
+    public String getOperationUrl( Form form, Object item, Operation op )
+        throws FormToolException
+    {
+        String id = null;
+
+        String type = null;
+
+        // TODO; throw an exception if the expression key isn't there
+        try
+        {
+            id = (String) Ognl.getValue( form.getKeyExpression(), item );
+
+            type = (String) Ognl.getValue( form.getTypeExpression(), item );
+        }
+        catch ( OgnlException e )
+        {
+            throw new FormToolException( "Error retrieving expression:", e );
+        }
+
+        String s = StringUtils.replace( op.getAction(), "$id$", id );
+
+        s = StringUtils.replace( s, "$formId$", form.getId() );
+
+        s = StringUtils.replace( s, "$type$", type );
+
+        return s;
+    }
+
+    public boolean enableOperation( Form form, Operation operation, Object item )
+        throws FormToolException
+    {
+        if ( operation.getEnable() == null )
+        {
+            return true;
+        }
+
+        try
+        {
+            return ((Boolean)Ognl.getValue( operation.getEnable(), item )).booleanValue();
+        }
+        catch ( OgnlException e )
+        {
+            throw new FormToolException( "Cannot evaluate enable expression: " + operation.getEnable()
+ " on " + item );
+        }
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
     public String getItem( Form form, Element element, String id )
         throws FormToolException
     {
@@ -173,35 +223,6 @@
         }
 
         return o.toString();
-    }
-
-
-    public String getOperationUrl( Form form, Object item, Operation op )
-        throws FormToolException
-    {
-        String id = null;
-
-        String type = null;
-
-        // TODO; throw an exception if the expression key isn't there
-        try
-        {
-            id = (String) Ognl.getValue( form.getKeyExpression(), item );
-
-            type = (String) Ognl.getValue( form.getTypeExpression(), item );
-        }
-        catch ( OgnlException e )
-        {
-            throw new FormToolException( "Error retrieving expression:", e );
-        }
-
-        String s = StringUtils.replace( op.getAction(), "$id$", id );
-
-        s = StringUtils.replace( s, "$formId$", form.getId() );
-
-        s = StringUtils.replace( s, "$type$", type );
-
-        return s;
     }
 
     // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-web/src/main/resources/forms/continuumProject.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/forms/continuumProject.xml?rev=170504&r1=170503&r2=170504&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/forms/continuumProject.xml (original)
+++ maven/continuum/trunk/continuum-web/src/main/resources/forms/continuumProject.xml Mon
May 16 19:50:11 2005
@@ -84,6 +84,7 @@
       <operation>
         <name>Results</name>
         <action>ProjectBuilds.vm/view/ProjectBuilds/id/$id$</action>
+        <enable>getBuilds().size > 0</enable>
       </operation>
       <operation>
         <name>Edit</name>

Modified: maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/Summary.vm
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/Summary.vm?rev=170504&r1=170503&r2=170504&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/Summary.vm (original)
+++ maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/Summary.vm Mon
May 16 19:50:11 2005
@@ -19,7 +19,11 @@
         <td>$formtool.getSummaryItem( $form, $se, $item )</td>
         #end
         #foreach ( $operation in $form.summary.operations )
+        #if ( $formtool.enableOperation( $form, $operation, $item ) )
         <td><a href="$link.setPage( $formtool.getOperationUrl( $form, $item, $operation
) )">$operation.name</a></td>
+        #else
+        <td>$operation.name</td>
+        #end
         #end
       </tr>
       #end



Mime
View raw message