/**
   * Constructs cell renderer for the specified file list.
   *
   * @param fileList file list in which this cell renderer is used
   */
  public WebFileListCellRenderer(final WebFileList fileList) {
    super();

    this.fileList = fileList;

    iconLabel = new WebLabel();
    iconLabel.setHorizontalAlignment(JLabel.CENTER);
    iconLabel.setPreferredSize(new Dimension(imageSide, imageSide));

    nameLabel = new WebLabel();
    nameLabel.setFont(nameLabel.getFont().deriveFont(Font.PLAIN));
    nameLabel.setForeground(Color.BLACK);
    nameLabel.setVerticalAlignment(JLabel.CENTER);

    descriptionLabel = new WebLabel(WebLabel.LEADING);
    descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(Font.PLAIN));
    descriptionLabel.setForeground(Color.GRAY);

    sizeLabel = new WebLabel(WebLabel.LEADING);
    sizeLabel.setFont(sizeLabel.getFont().deriveFont(Font.PLAIN));
    sizeLabel.setForeground(new Color(49, 77, 179));

    setLayout(new FileCellLayout());
    add(iconLabel);
    add(nameLabel);
    add(descriptionLabel);
    add(sizeLabel);

    fileList.addPropertyChangeListener(
        WebLookAndFeel.COMPONENT_ENABLED_PROPERTY,
        new PropertyChangeListener() {
          @Override
          public void propertyChange(final PropertyChangeEvent evt) {
            final boolean enabled = fileList.isEnabled();
            iconLabel.setEnabled(enabled);
            nameLabel.setEnabled(enabled);
            descriptionLabel.setEnabled(enabled);
            sizeLabel.setEnabled(enabled);
          }
        });

    fileList.addPropertyChangeListener(
        WebLookAndFeel.COMPONENT_ORIENTATION_PROPERTY,
        new PropertyChangeListener() {
          @Override
          public void propertyChange(final PropertyChangeEvent evt) {
            final ComponentOrientation orientation = fileList.getComponentOrientation();
            nameLabel.setComponentOrientation(orientation);
            descriptionLabel.setComponentOrientation(orientation);
            sizeLabel.setComponentOrientation(orientation);
          }
        });

    updateFilesView();
  }
 /** Updates renderer elements view. */
 public void updateFilesView() {
   if (isTilesView()) {
     nameLabel.setHorizontalAlignment(JLabel.LEADING);
     fileList.setFixedCellWidth(tileCellSize.width);
     fileList.setFixedCellHeight(tileCellSize.height);
   } else {
     nameLabel.setHorizontalAlignment(JLabel.CENTER);
     fileList.setFixedCellWidth(iconCellSize.width);
     fileList.setFixedCellHeight(iconCellSize.height);
   }
 }
 /**
  * Returns whether list is currently displaying tiles or not.
  *
  * @return true if list is currently displaying tiles, false otherwise
  */
 protected boolean isTilesView() {
   return fileList.getFileListViewType().equals(FileListViewType.tiles);
 }
  /**
   * Returns list cell renderer component.
   *
   * @param list tree
   * @param value cell value
   * @param index cell index
   * @param isSelected whether cell is selected or not
   * @param cellHasFocus whether cell has focus or not
   * @return cell renderer component
   */
  @Override
  public Component getListCellRendererComponent(
      final JList list,
      final Object value,
      final int index,
      final boolean isSelected,
      final boolean cellHasFocus) {
    super.getListCellRendererComponent(list, "", index, isSelected, cellHasFocus);

    final FileElement element = (FileElement) value;
    final File file = element.getFile();

    // Proper margin
    setMargin(isTilesView() ? tileCellMargin : iconCellMargin);

    // Renderer icon
    String imageSize = null;
    if (iconLabel.isEnabled()) {
      // Thumbnail loading
      synchronized (thumbnailsLock) {
        if (!element.isThumbnailQueued() && !element.isDisabledThumbnailQueued()) {
          queueThumbnailLoad(element, false);
        }
      }

      // Image thumbnail
      final ImageIcon thumbnail = element.getEnabledThumbnail();
      iconLabel.setIcon(thumbnail);

      // Image description
      if (thumbnail != null) {
        imageSize = thumbnail.getDescription();
      }
    } else {
      // Disabled thumbnail loading
      synchronized (thumbnailsLock) {
        if (!element.isDisabledThumbnailQueued()) {
          queueThumbnailLoad(element, true);
        }
      }

      // Image disabled thumbnail
      iconLabel.setDisabledIcon(element.getDisabledThumbnail());
    }

    // Updating file description elements
    if (fileList.getEditedCell() != index) {
      // Settings description
      final FileDescription fileDescription = FileUtils.getFileDescription(file, imageSize);
      nameLabel.setText(fileDescription.getName());

      // Updating tile view additional description
      if (isTilesView()) {
        descriptionLabel.setText(fileDescription.getDescription());

        // Updating size label
        if (fileDescription.getSize() != null) {
          sizeLabel.setText(fileDescription.getSize());
        } else {
          sizeLabel.setText(null);
        }
      } else {
        descriptionLabel.setText(null);
        sizeLabel.setText(null);
      }
    } else {
      nameLabel.setText(null);
      descriptionLabel.setText(null);
      sizeLabel.setText(null);
    }

    return this;
  }