package org.apache.maven.continuum.web.view;

/*
 * Copyright 2004-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.apache.maven.continuum.web.model.SummaryProjectModel;
import org.apache.maven.continuum.web.util.StateGenerator;

import org.extremecomponents.table.bean.Column;
import org.extremecomponents.table.cell.DisplayCell;
import org.extremecomponents.table.core.BaseModel;

/**
 * Used in Summary view
 *
 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
 * @version $Id$
 */
public class BuildCell
    extends DisplayCell
{
    public void init(BaseModel model, Column column)
    {
        super.init(model, column);

        SummaryProjectModel project = (SummaryProjectModel) model.getCurrentCollectionBean();

        int buildNumber = project.getBuildNumber();

        if ( project.isInQueue() )
        {
            column.setValue( "In&nbsp;queue" );
        }
        else if ( project.getState() == 1 || project.getState() == 2 || project.getState() == 3 || project.getState() == 4 )
        {
            if ( project.getBuildNumber() > 0 )
            {
                column.setValue( "<a href=\"TO_BE_DEFINE\">" + project.getBuildNumber() + "</a>" );
            }
            else
            {
                column.setValue( "&nbsp;" );
            }
        }
        else
        {
            column.setValue( "In&nbsp;progress" );
        }
    }
}

@@ -939,16 +939,192 @@
 Model;%0A%0A
+import com.opensymphony.webwork.views.util.UrlHelper;%0A%0Aimport java.util.HashMap;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0A
 /**%0A * U
@@ -1820,32 +1820,606 @@
 )%0A            %7B%0A
+                HashMap params = new HashMap();%0A%0A                params.put( %22projectId%22, new Integer( project.getId() ) );%0A%0A                params.put( %22projectName%22, project.getName() );%0A%0A                params.put( %22buildId%22, new Integer( buildNumber ) );%0A%0A                HttpServletRequest request = (HttpServletRequest) model.getPageContext().getRequest();%0A%0A                HttpServletResponse response = (HttpServletResponse) model.getPageContext().getResponse();%0A%0A                String url = UrlHelper.buildUrl( %22/buildResult.action%22, request, response, params );%0A%0A
                 
@@ -2450,21 +2450,18 @@
 f=%5C%22
-TO_BE_DEFINE%5C
+%22 + url + 
 %22%3E%22 

Fix build result url