001/* 002 * Copyright 2010-2015 Institut Pasteur. 003 * 004 * This file is part of Icy. 005 * 006 * Icy is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Icy is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Icy. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package icy.gui.menu.search; 020 021import icy.gui.util.ComponentUtil; 022import icy.search.SearchResultProducer; 023 024import java.awt.Component; 025 026import javax.swing.JTable; 027 028import org.pushingpixels.substance.api.renderers.SubstanceDefaultTableCellRenderer; 029 030public class SearchProducerTableCellRenderer extends SubstanceDefaultTableCellRenderer 031{ 032 /** 033 * 034 */ 035 private static final long serialVersionUID = -8677464337382665200L; 036 037 @Override 038 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, 039 int row, int column) 040 { 041 super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 042 043 if (value instanceof SearchResultProducer) 044 { 045 final SearchResultProducer producer = (SearchResultProducer) value; 046 047 setText(producer.getName()); 048 ComponentUtil.setFontBold(this); 049 setToolTipText(producer.getTooltipText()); 050 } 051 else 052 { 053 setText(null); 054 setToolTipText(null); 055 setIcon(null); 056 } 057 058 return this; 059 } 060}