continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r585508 - in /maven/continuum/trunk/continuum-webapp/src/main: java/org/apache/maven/continuum/web/action/ProjectGroupAction.java webapp/WEB-INF/jsp/projectGroupSummary.jsp
Date Wed, 17 Oct 2007 13:49:19 GMT
Author: evenisse
Date: Wed Oct 17 06:49:18 2007
New Revision: 585508

URL: http://svn.apache.org/viewvc?rev=585508&view=rev
Log:
[CONTINUUM-1233] Reduce number of clicks to add a project

Modified:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java?rev=585508&r1=585507&r2=585508&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
Wed Oct 17 06:49:18 2007
@@ -115,6 +115,8 @@
 
     private int buildDefinitionId;
 
+    private String preferredExecutor = "maven2";
+
     public String summary()
         throws ContinuumException
     {
@@ -128,7 +130,7 @@
             return REQUIRES_AUTHORIZATION;
         }
 
-        projectGroup = getProjectGroup( projectGroupId );
+        projectGroup = getContinuum().getProjectGroupWithProjects( projectGroupId );
 
         List<BuildDefinition> projectGroupBuildDefs =
             getContinuum().getBuildDefinitionsForProjectGroup( projectGroupId );
@@ -153,6 +155,53 @@
             this.buildDefinitions = Collections.EMPTY_MAP;
         }
 
+        if ( projectGroup != null )
+        {
+            if ( projectGroup.getProjects() != null && projectGroup.getProjects().size()
> 0 )
+            {
+                int nbMaven2Projects = 0;
+                int nbMaven1Projects = 0;
+                int nbAntProjects = 0;
+                int nbShellProjects = 0;
+                for ( Object o : projectGroup.getProjects() )
+                {
+                    Project p = (Project) o;
+                    if ( "maven2".equals( p.getExecutorId() ) )
+                    {
+                        nbMaven2Projects += 1;
+                    }
+                    else if ( "maven-1".equals( p.getExecutorId() ) )
+                    {
+                        nbMaven1Projects += 1;
+                    }
+                    else if ( "ant".equals( p.getExecutorId() ) )
+                    {
+                        nbAntProjects += 1;
+                    }
+                    else if ( "shell".equals( p.getExecutorId() ) )
+                    {
+                        nbShellProjects += 1;
+                    }
+                }
+
+                int nbActualPreferredProject = nbMaven2Projects;
+                if ( nbMaven1Projects > nbActualPreferredProject )
+                {
+                    preferredExecutor = "maven-1";
+                    nbActualPreferredProject = nbMaven1Projects;
+                }
+                if ( nbAntProjects > nbActualPreferredProject )
+                {
+                    preferredExecutor = "ant";
+                    nbActualPreferredProject = nbAntProjects;
+                }
+                if ( nbShellProjects > nbActualPreferredProject )
+                {
+                    preferredExecutor = "shell";
+                }
+            }
+        }
+
         return SUCCESS;
     }
 
@@ -739,4 +788,8 @@
         this.buildDefinitionId = buildDefinitionId;
     }
 
+    public String getPreferredExecutor()
+    {
+        return preferredExecutor;
+    }
 }

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp?rev=585508&r1=585507&r2=585508&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp
Wed Oct 17 06:49:18 2007
@@ -32,27 +32,39 @@
     </title>
     <meta http-equiv="refresh" content="300"/>
     <script type="text/javascript">
+
+      <c:url var="addM2ProjectUrl" value="/addMavenTwoProject!input.action" />
+      <c:url var="addM1ProjectUrl" value="/addMavenOneProject!input.action" />
+      <c:url var="addProjectUrl" value="/addProjectInput.action" />
+
       function goToAddProject()
       {
-        var urls = document.getElementById( "projectTypes" );
-        var index = urls.selectedIndex;
+        var projectTypes = document.getElementById( "preferredExecutor" );
+        var type = projectTypes.value;
 
-        if ( index > 0 )
+        if ( type != '' )
         {
           var form = document.forms[ "addNewProject" ];
-          form.action = urls[ index ].value;
 
-          if ( index == 3 )
+          if ( type == 'maven2' )
           {
-            form.projectType.value = "ant";
+            form.action = '${addM2ProjectUrl}';
+            form.projectType.value = "";
           }
-          else if ( index == 4 )
+          else if ( type == 'maven-1' )
           {
-            form.projectType.value = "shell";
+            form.action = '${addM1ProjectUrl}';
+            form.projectType.value = "";
           }
-          else
+          else if ( type == 'ant' )
           {
-            form.projectType.value = "";
+            form.action = '${addProjectUrl}';
+            form.projectType.value = "ant";
+          }
+          else if ( type == 'shell' )
+          {
+            form.action = '${addProjectUrl}';
+            form.projectType.value = "shell";
           }
 
           form.submit();
@@ -138,17 +150,8 @@
                   <ww:hidden name="projectType" value=""/>
                 </ww:form>
 
-                <c:url var="addM2ProjectUrl" value="/addMavenTwoProject!input.action"
/>
-                <c:url var="addM1ProjectUrl" value="/addMavenOneProject!input.action"
/>
-                <c:url var="addProjectUrl" value="/addProjectInput.action" />
-
-                <select id="projectTypes">
-                  <option value=""><ww:text name="projectGroup.addProject.label"
/></option>
-                  <option value="${addM2ProjectUrl}">Add M2 Project</option>
-                  <option value="${addM1ProjectUrl}">Add M1 Project</option>
-                  <option value="${addProjectUrl}">Add Ant Project</option>
-                  <option value="${addProjectUrl}">Add Shell Project</option>
-                </select>
+                <ww:select theme="simple" name="preferredExecutor" list="#{'maven2' :
'Add M2 Project', 'maven-1' : 'Add M1 Project', 'ant' : 'Add Ant Project', 'shell' : 'Add
Shell Project'}"
+                    headerValue="Choose the project type" headerKey="" emptyOption="true"
/>
 
                 <input type="button" value="Add" onclick="goToAddProject()"/>
               </redback:ifAnyAuthorized>



Mime
View raw message