1 /*
2  * FileIconResourceCell.java
3  *
4  * Copyright (C) 2021 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant
7  * to the terms of a commercial license agreement with RStudio, then
8  * this program is licensed to you under the terms of version 3 of the
9  * GNU Affero General Public License. This program is distributed WITHOUT
10  * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
12  * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13  *
14  */
15 package org.rstudio.studio.client.common.filetypes;
16 
17 import com.google.gwt.cell.client.AbstractCell;
18 import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
19 
20 public class FileIconResourceCell extends AbstractCell<FileIcon>
21 {
22    private static FileIconRenderer renderer;
23 
24    /**
25     * Construct a new ImageResourceCell.
26     */
FileIconResourceCell()27    public FileIconResourceCell()
28    {
29       if (renderer == null)
30       {
31          renderer = new FileIconRenderer();
32       }
33    }
34 
35    @Override
render(Context context, FileIcon value, SafeHtmlBuilder sb)36    public void render(Context context, FileIcon value, SafeHtmlBuilder sb)
37    {
38       if (value != null)
39       {
40          sb.append(renderer.render(value));
41       }
42    }
43 }
44