/** * Returns the value currently selected. * * @return the value currently selected */ public E getValue() { ImageIcon icon = (ImageIcon) getSelectedItem(); return E.valueOf(enumeration, icon.getDescription()); }
/** * 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; }