package org.ssgwt.client.ui.datagrid.column;

import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;

/**
 * A boolean cell that will display a image in a cell
 *
 * @author Alec Erasmus <alec.erasmus@a24group.com>
 * @since 02 April 2013
 */
public class SSBooleanImageCell extends AbstractCell<Boolean> {

    /**
     * The url of the image being displayed if the boolean value is true
     */
    private final String tImageUrl;

    /**
     * The url of the image being displayed if the boolean value is false
     */
    private final String fImageUrl;

    /**
     * The SSBooleanImageCell constructor
     *
     * @author Alec Erasmus <alec.erasmus@a24group.com>
     * @since 02 April 2013
     *
     * @param tImageUrl - The image to display if the the boolean value is true
     * @param fImageUrl - The image to display if the the boolean value is false
     */
    public SSBooleanImageCell(String tImageUrl, String fImageUrl) {
        super();
        this.tImageUrl = tImageUrl;
        this.fImageUrl = fImageUrl;
    }

    /**
     * This will create a image with the url passed in by the constructor
     *
     * @author Alec Erasmus <alec.erasmus@a24group.com>
     * @since 02 April 2013
     *
     * @param context -The context the cell is in
     * @param value - The value to be added in the cell but not the image thats going to be displayed
     * @param sb -The safe html builder.
     */
    @Override
    public void render(Context context, Boolean value, SafeHtmlBuilder sb) {
        String columnString;
        if (value == null) {
            value = false;
        }
        if (value) {
            if (tImageUrl == null) {
                columnString = "<div title=\"" + value + "\" ></div>";
            } else {
                columnString = "<div title=\"" + value + "\" > <img src='" + tImageUrl + "' /> </div>";
            }
        } else {
            if (fImageUrl == null) {
                columnString = "<div title=\"" + value + "\" ></div>";
            } else {
                columnString = "<div title=\"" + value + "\" > <img src='" + fImageUrl + "' /> </div>";
            }
        }
        sb.appendHtmlConstant(columnString);
    }

}

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

Update copyright